diff --git a/app/build.gradle b/app/build.gradle index ed3d2355ae..2b77401b74 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId 'com.github.doomsdayrs.apps.shosetsu' minSdkVersion 22 targetSdkVersion 29 - versionCode 22 - versionName "v1.0.0" + versionCode 23 + versionName "v1.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/DownloadManager.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/DownloadManager.kt index 9398b91a38..b64ef73879 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/DownloadManager.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/DownloadManager.kt @@ -48,7 +48,6 @@ object DownloadManager { /** * Initializes download manager */ - @JvmStatic fun initDownloadManager(activity: Activity) { if (downloadTask.isCanceled) downloadTask = DownloadTask(activity) if (Database.DatabaseDownloads.getDownloadCount() >= 1) @@ -61,7 +60,6 @@ object DownloadManager { * * @param downloadItem download item to add */ - @JvmStatic fun addToDownload(activity: Activity?, downloadItem: DownloadItem) { if (!Database.DatabaseDownloads.inDownloads(downloadItem)) { Database.DatabaseDownloads.addToDownloads(downloadItem) @@ -79,7 +77,6 @@ object DownloadManager { * @param downloadItem download item to remove * @return if downloaded */ - @JvmStatic fun delete(context: Context?, downloadItem: DownloadItem): Boolean { Log.d("DeletingChapter", downloadItem.toString()) val file = File(Utilities.shoDir + "/download/" + downloadItem.formatter.formatterID + "/" + downloadItem.novelName + "/" + downloadItem.chapterName + ".txt") diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/UpdateManager.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/UpdateManager.kt index 26e68ef081..ed3489a848 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/UpdateManager.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/UpdateManager.kt @@ -31,7 +31,6 @@ import java.util.* */ object UpdateManager { private var chapterUpdater: ChapterUpdater? = null - @JvmStatic fun init(novelCards: ArrayList, context: Context) { if (chapterUpdater == null) { chapterUpdater = ChapterUpdater(novelCards, context) diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/Utilities.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/Utilities.kt index cc38a19e4e..540e23282e 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/Utilities.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/Utilities.kt @@ -12,6 +12,8 @@ import android.util.Log import android.view.MenuItem import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import com.github.doomsdayrs.api.shosetsu.services.core.objects.Novel import com.github.doomsdayrs.api.shosetsu.services.core.objects.NovelChapter import com.github.doomsdayrs.api.shosetsu.services.core.objects.NovelStatus import com.github.doomsdayrs.apps.shosetsu.R @@ -29,6 +31,7 @@ import com.github.doomsdayrs.apps.shosetsu.variables.enums.Status import java.io.* import java.util.* import java.util.concurrent.TimeUnit +import kotlin.collections.ArrayList /* * This file is part of Shosetsu. @@ -64,6 +67,14 @@ object Utilities { lateinit var trackingPreferences: SharedPreferences lateinit var backupPreferences: SharedPreferences + fun convertNovelArrayToString2DArray(array: List): ArrayList> { + val a: ArrayList> = ArrayList() + for (novel in array) { + a.add(arrayOf(novel.title, novel.link, novel.imageURL)) + } + return a + } + fun regret(context: Context) { Toast.makeText(context, context.getString(R.string.regret), Toast.LENGTH_LONG).show() } @@ -91,7 +102,6 @@ object Utilities { * @param input String to clean * @return string without specials */ - @JvmStatic fun cleanString(input: String): String { return input.replace("[^A-Za-z0-9]".toRegex(), "_") } @@ -140,14 +150,14 @@ object Utilities { return null } - /** - * Checks string before deserialization - * If null or empty, returns "". Else deserializes the string and returns - * - * @param string String to be checked - * @return Completed String - */ @JvmStatic + /** + * Checks string before deserialization + * If null or empty, returns "". Else deserializes the string and returns + * + * @param string String to be checked + * @return Completed String + */ fun checkStringDeserialize(string: String): String { if (string.isEmpty()) { return "" @@ -164,14 +174,14 @@ object Utilities { return "" } - /** - * Checks string before serialization - * If null or empty, returns "". Else serializes the string and returns - * - * @param string String to be checked - * @return Completed String - */ @JvmStatic + /** + * Checks string before serialization + * If null or empty, returns "". Else serializes the string and returns + * + * @param string String to be checked + * @return Completed String + */ fun checkStringSerialize(string: String?): String { if (string == null || string.isEmpty()) { return "" @@ -185,13 +195,13 @@ object Utilities { return "" } - /** - * Converts String Stati back into Stati - * - * @param s String title - * @return Stati - */ @JvmStatic + /** + * Converts String Stati back into Stati + * + * @param s String title + * @return Stati + */ fun convertStringToStati(s: String): NovelStatus { return when (s) { "Publishing" -> NovelStatus.PUBLISHING @@ -202,13 +212,13 @@ object Utilities { } } - /** - * Converts Array of Strings into a String - * - * @param a array of strings - * @return String Array - */ @JvmStatic + /** + * Converts Array of Strings into a String + * + * @param a array of strings + * @return String Array + */ fun convertArrayToString(a: Array?): String { if (a != null && a.isNotEmpty()) { for (x in a.indices) { @@ -219,13 +229,13 @@ object Utilities { return "[]" } - /** - * Converts a String Array back into an Array of Strings - * - * @param s String array - * @return Array of Strings - */ @JvmStatic + /** + * Converts a String Array back into an Array of Strings + * + * @param s String array + * @return Array of Strings + */ fun convertStringToArray(s: String): Array { val a = s.substring(1, s.length - 1).split(", ".toRegex()).toTypedArray() for (x in a.indices) { @@ -323,23 +333,19 @@ object Utilities { return if (activeNetwork != null) activeNetwork.type == ConnectivityManager.TYPE_WIFI || activeNetwork.type == ConnectivityManager.TYPE_MOBILE else false }//TODO: Check this also, this doesn't seem to be a nice way to do things. - /** - * Is reader in night mode - * - * @return true if so, otherwise false - */ - val isReaderNightMode: Boolean - get() =//TODO: Check this also, this doesn't seem to be a nice way to do things. - Settings.ReaderTextColor == Color.WHITE fun setNightNode() { setReaderColor(Color.WHITE, Color.BLACK) } - fun unsetNightMode() { + fun setLightMode() { setReaderColor(Color.BLACK, Color.WHITE) } + fun setSepiaMode(context: Context) { + setReaderColor(Color.BLACK, ContextCompat.getColor(context, R.color.wheat)) + } + /** * Sets the reader color * @@ -355,14 +361,20 @@ object Utilities { .apply() } - /** - * Swaps the reader colors - */ - fun swapReaderColor() { - if (isReaderNightMode) { - setReaderColor(Color.BLACK, Color.WHITE) - } else { - setReaderColor(Color.WHITE, Color.BLACK) + fun getReaderColor(context: Context): Int { + return when (Settings.ReaderTextBackgroundColor) { + Color.WHITE -> { + 1 + } + Color.BLACK -> { + 0 + } + ContextCompat.getColor(context, R.color.wheat) -> { + 2 + } + else -> { + 1 + } } } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/Database.java b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/Database.java index 0ac2cec151..6e2f08df21 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/Database.java +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/Database.java @@ -397,7 +397,7 @@ public static ArrayList getDownloadList() { String nName = cursor.getString(cursor.getColumnIndex(Columns.NOVEL_NAME.toString())); String cName = cursor.getString(cursor.getColumnIndex(Columns.CHAPTER_NAME.toString())); int formatter = DatabaseIdentification.getFormatterIDFromChapterID(id); - downloadItems.add(new DownloadItem(Objects.requireNonNull(DefaultScrapers.getByID(formatter)), nName, cName, id)); + downloadItems.add(new DownloadItem(Objects.requireNonNull(DefaultScrapers.Companion.getByID(formatter)), nName, cName, id)); } cursor.close(); @@ -422,7 +422,7 @@ public static DownloadItem getFirstDownload() { String cName = cursor.getString(cursor.getColumnIndex(Columns.CHAPTER_NAME.toString())); int formatter = getFormatterIDFromChapterID(id); cursor.close(); - return new DownloadItem(Objects.requireNonNull(DefaultScrapers.getByID(formatter)), nName, cName, id); + return new DownloadItem(Objects.requireNonNull(DefaultScrapers.Companion.getByID(formatter)), nName, cName, id); } } @@ -432,7 +432,7 @@ public static DownloadItem getFirstDownload() { * @param downloadItem download item to remove */ public static void removeDownload(@NonNull DownloadItem downloadItem) { - sqLiteDatabase.delete(Tables.DOWNLOADS.toString(), Columns.PARENT_ID + "=" + DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.chapterURL) + "", null); + sqLiteDatabase.delete(Tables.DOWNLOADS.toString(), Columns.PARENT_ID + "=" + DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.getChapterURL()) + "", null); } /** @@ -447,9 +447,9 @@ public static void addToDownloads(@NonNull DownloadItem downloadItem) { Columns.CHAPTER_NAME + "," + Columns.PAUSED + ") " + "values (" + - DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.chapterURL) + ",'" + - DownloadItem.cleanse(downloadItem.novelName) + "','" + - DownloadItem.cleanse(downloadItem.chapterName) + "'," + 0 + ")"); + DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.getChapterURL()) + ",'" + + DownloadItem.Companion.cleanse(downloadItem.getNovelName()) + "','" + + DownloadItem.Companion.cleanse(downloadItem.getChapterName()) + "'," + 0 + ")"); } /** @@ -459,7 +459,7 @@ public static void addToDownloads(@NonNull DownloadItem downloadItem) { * @return if is in list */ public static boolean inDownloads(@NonNull DownloadItem downloadItem) { - Cursor cursor = sqLiteDatabase.rawQuery("SELECT " + Columns.PARENT_ID + " from " + Tables.DOWNLOADS + " where " + Columns.PARENT_ID + " = " + DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.chapterURL) + "", null); + Cursor cursor = sqLiteDatabase.rawQuery("SELECT " + Columns.PARENT_ID + " from " + Tables.DOWNLOADS + " where " + Columns.PARENT_ID + " = " + DatabaseIdentification.getChapterIDFromChapterURL(downloadItem.getChapterURL()) + "", null); int a = cursor.getCount(); cursor.close(); return !(a <= 0); diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/objects/base/Base.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/objects/base/Base.kt deleted file mode 100644 index c18dd57e64..0000000000 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/database/objects/base/Base.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.github.doomsdayrs.apps.shosetsu.backend.database.objects.base - -import java.io.Serializable - -/* - * This file is part of Shosetsu. - * - * Shosetsu is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Shosetsu is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Shosetsu. If not, see . - * ==================================================================== - * shosetsu - * 27 / 07 / 2019 - * - * @author github.com/doomsdayrs - */ -open class Base internal constructor(val NOVEL_URL: String) : Serializable { - override fun toString(): String { - return "Base{" + - "NOVEL_URL='" + NOVEL_URL + '\'' + - '}' - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt index 73257864d2..fc2cd84980 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/backend/scraper/WebViewScrapper.kt @@ -67,7 +67,6 @@ object WebViewScrapper { * @param url URL to retrieve; * @return Document of the URL */ - @JvmStatic fun docFromURL(url: String?, cloudflare: Boolean): Document? { if (url != null) { Log.i("URL load", url) diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/catalogue/listeners/CatalogueSearchQuery.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/catalogue/listeners/CatalogueSearchQuery.kt index f2ca7d9f04..b0634f5ab3 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/catalogue/listeners/CatalogueSearchQuery.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/catalogue/listeners/CatalogueSearchQuery.kt @@ -51,10 +51,10 @@ class CatalogueSearchQuery(private val catalogueFragment: CatalogueFragment) : S catalogueFragment.isQuery = true val recycleCards = ArrayList(catalogueFragment.catalogueNovelCards) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - recycleCards.removeIf { recycleCard: CatalogueNovelCard? -> !recycleCard!!.title.toLowerCase().contains(newText.toLowerCase()) } + recycleCards.removeIf { recycleCard: CatalogueNovelCard? -> !recycleCard!!.title.toLowerCase(Locale.ROOT).contains(newText.toLowerCase(Locale.ROOT)) } } else { for (x in recycleCards.indices.reversed()) { - if (!recycleCards[x]!!.title.toLowerCase().contains(newText.toLowerCase())) { + if (!recycleCards[x]!!.title.toLowerCase(Locale.ROOT).contains(newText.toLowerCase(Locale.ROOT))) { recycleCards.removeAt(x) } } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/NovelFragment.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/NovelFragment.kt index 02814f8007..b525d86966 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/NovelFragment.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/NovelFragment.kt @@ -13,7 +13,9 @@ import com.github.doomsdayrs.api.shosetsu.services.core.objects.NovelPage import com.github.doomsdayrs.apps.shosetsu.R import com.github.doomsdayrs.apps.shosetsu.backend.Utilities import com.github.doomsdayrs.apps.shosetsu.backend.database.Database -import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseChapter +import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseChapter.getChapter +import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseChapter.getStatus +import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseIdentification.getChapterIDFromChapterURL import com.github.doomsdayrs.apps.shosetsu.ui.novel.adapters.NovelPagerAdapter import com.github.doomsdayrs.apps.shosetsu.ui.novel.async.NovelLoader import com.github.doomsdayrs.apps.shosetsu.ui.novel.pages.NovelFragmentChapters @@ -26,6 +28,7 @@ import com.google.android.material.tabs.TabLayout.TabLayoutOnPageChangeListener import kotlinx.android.synthetic.main.fragment_novel.* import java.util.* + /* * This file is part of Shosetsu. * @@ -68,7 +71,7 @@ class NovelFragment : Fragment() { return if (novelChapters.isNotEmpty()) { if (!novelFragmentChapters?.reversed!!) { for (x in novelChapters.indices.reversed()) { - when (DatabaseChapter.getStatus(Database.DatabaseIdentification.getChapterIDFromChapterURL(novelChapters[x].link))) { + when (getStatus(getChapterIDFromChapterURL(novelChapters[x].link))) { Status.READ -> return x + 1 Status.READING -> return x else -> { @@ -77,7 +80,7 @@ class NovelFragment : Fragment() { } } else { for (x in novelChapters.indices) { - when (DatabaseChapter.getStatus(Database.DatabaseIdentification.getChapterIDFromChapterURL(novelChapters[x].link))) { + when (getStatus(getChapterIDFromChapterURL(novelChapters[x].link))) { Status.READ -> return x - 1 Status.READING -> return x else -> { @@ -89,7 +92,6 @@ class NovelFragment : Fragment() { } else -2 } - @JvmField var novelFragmentInfo: NovelFragmentInfo? = null var novelFragmentChapters: NovelFragmentChapters? = null @@ -115,15 +117,14 @@ class NovelFragment : Fragment() { novelFragmentInfo = NovelFragmentInfo() novelFragmentInfo!!.novelFragment = (this) novelFragmentChapters = NovelFragmentChapters() - novelFragmentChapters!!.setNovelFragment(this) + novelFragmentChapters!!.novelFragment = (this) } //TODO FINISH TRACKING //boolean track = SettingsController.isTrackingEnabled(); if (savedInstanceState == null) { if (Utilities.isOnline && Database.DatabaseNovels.isNotInNovels(novelID)) { setViewPager() - if (formatter != null) - fragment_novel_tabLayout!!.post { NovelLoader(novelURL, novelID, formatter, this, true).execute() } + fragment_novel_tabLayout!!.post { NovelLoader(novelURL, novelID, formatter, this, true).execute() } } else { novelPage = Database.DatabaseNovels.getNovelPage(novelID) new = false @@ -153,9 +154,9 @@ class NovelFragment : Fragment() { fragments.add(novelFragmentChapters!!) } val pagerAdapter = NovelPagerAdapter(childFragmentManager, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT, fragments) - fragment_novel_viewpager!!.adapter = pagerAdapter - fragment_novel_viewpager!!.addOnPageChangeListener(TabLayoutOnPageChangeListener(fragment_novel_tabLayout)) - fragment_novel_tabLayout!!.addOnTabSelectedListener(object : OnTabSelectedListener { + fragment_novel_viewpager?.adapter = pagerAdapter + fragment_novel_viewpager?.addOnPageChangeListener(TabLayoutOnPageChangeListener(fragment_novel_tabLayout)) + fragment_novel_tabLayout?.addOnTabSelectedListener(object : OnTabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { fragment_novel_viewpager!!.currentItem = tab.position } @@ -163,28 +164,58 @@ class NovelFragment : Fragment() { override fun onTabUnselected(tab: TabLayout.Tab) {} override fun onTabReselected(tab: TabLayout.Tab) {} }) - fragment_novel_tabLayout!!.post { fragment_novel_tabLayout!!.setupWithViewPager(fragment_novel_viewpager) } + fragment_novel_tabLayout?.post { fragment_novel_tabLayout?.setupWithViewPager(fragment_novel_viewpager) } } @Suppress("unused") - /** * @param chapterURL Current chapter URL * @return chapter after the input, returns the current chapter if no more */ fun getNextChapter(chapterURL: Int, novelChapters: IntArray?): NovelChapter? { - if (novelChapters != null && novelChapters.isNotEmpty()) for (x in novelChapters.indices) { - if (novelChapters[x] == chapterURL) { - return if (novelFragmentChapters?.reversed!!) { - if (x - 1 != -1) DatabaseChapter.getChapter(novelChapters[x - 1]) else DatabaseChapter.getChapter(novelChapters[x]) - } else { - if (x + 1 != novelChapters.size) DatabaseChapter.getChapter(novelChapters[x + 1]) else DatabaseChapter.getChapter(novelChapters[x]) + if (novelChapters != null && novelChapters.isNotEmpty()) + for (x in novelChapters.indices) { + if (novelChapters[x] == chapterURL) { + return if (novelFragmentChapters?.reversed!!) { + if (x - 1 != -1) getChapter(novelChapters[x - 1]) else getChapter(novelChapters[x]) + } else { + if (x + 1 != novelChapters.size) getChapter(novelChapters[x + 1]) else getChapter(novelChapters[x]) + } + } + } + return null + } + + fun getNextChapter(chapterURL: String, novelChapters: List): NovelChapter? { + if (novelChapters.isNotEmpty()) + for (x in novelChapters.indices) { + if (novelChapters[x].link == chapterURL) { + return if (novelFragmentChapters?.reversed!!) { + if (x - 1 != -1) getChapter(getChapterIDFromChapterURL(novelChapters[x - 1].link)) else getChapter(getChapterIDFromChapterURL(novelChapters[x].link)) + } else { + if (x + 1 != novelChapters.size) getChapter(getChapterIDFromChapterURL(novelChapters[x + 1].link)) else getChapter(getChapterIDFromChapterURL(novelChapters[x].link)) + } } } - } return null } + fun getLastRead(): NovelChapter? { + if (!novelChapters.isNullOrEmpty()) + if (!novelFragmentChapters!!.reversed) + for (x in novelChapters.size - 1 downTo 0) { + val stat = getStatus(getChapterIDFromChapterURL(novelChapters[x].link)) + if (stat == Status.READ || stat == Status.READING) + return novelChapters[x] + } + else for (x in novelChapters) { + val stat = getStatus(getChapterIDFromChapterURL(x.link)) + if (stat == Status.READ || stat == Status.READING) + return x + } + return if (novelFragmentChapters!!.reversed) novelChapters[0] else novelChapters[novelChapters.size - 1] + } + init { setHasOptionsMenu(true) } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/adapters/ChaptersAdapter.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/adapters/ChaptersAdapter.kt index 9e6b551f50..af875ec05d 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/adapters/ChaptersAdapter.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/adapters/ChaptersAdapter.kt @@ -130,7 +130,6 @@ class ChaptersAdapter(private val novelFragmentChapters: NovelFragmentChapters) } companion object { - @JvmField var DefaultTextColor = 0 private var set = false } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/pages/NovelFragmentChapters.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/pages/NovelFragmentChapters.kt index 8440f384a8..f4c62dcde1 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/pages/NovelFragmentChapters.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/novel/pages/NovelFragmentChapters.kt @@ -1,5 +1,6 @@ package com.github.doomsdayrs.apps.shosetsu.ui.novel.pages +import android.app.AlertDialog import android.os.Bundle import android.util.Log import android.view.* @@ -12,12 +13,13 @@ import androidx.recyclerview.widget.RecyclerView import com.github.doomsdayrs.api.shosetsu.services.core.objects.NovelChapter import com.github.doomsdayrs.apps.shosetsu.R import com.github.doomsdayrs.apps.shosetsu.backend.DownloadManager +import com.github.doomsdayrs.apps.shosetsu.backend.Utilities import com.github.doomsdayrs.apps.shosetsu.backend.Utilities.openChapter import com.github.doomsdayrs.apps.shosetsu.backend.async.ChapterLoader import com.github.doomsdayrs.apps.shosetsu.backend.async.ChapterLoader.ChapterLoaderAction import com.github.doomsdayrs.apps.shosetsu.backend.database.Database import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseChapter.* -import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseIdentification +import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseIdentification.getChapterIDFromChapterURL import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseUpdates.addToUpdates import com.github.doomsdayrs.apps.shosetsu.ui.novel.NovelFragment import com.github.doomsdayrs.apps.shosetsu.ui.novel.adapters.ChaptersAdapter @@ -107,14 +109,11 @@ class NovelFragmentChapters : Fragment() { } private var currentMaxPage = 1 - @JvmField var selectedChapters = ArrayList() var adapter: ChaptersAdapter? = ChaptersAdapter(this) - @JvmField var novelFragment: NovelFragment? = null - @JvmField var menu: Menu? = null operator fun contains(novelChapter: NovelChapter): Boolean { @@ -134,9 +133,6 @@ class NovelFragmentChapters : Fragment() { return max } - fun setNovelFragment(novelFragment: NovelFragment?) { - this.novelFragment = novelFragment - } override fun onDestroy() { super.onDestroy() @@ -180,7 +176,7 @@ class NovelFragmentChapters : Fragment() { resume.visibility = GONE if (novelFragment != null) fragment_novel_chapters_refresh.setOnRefreshListener { - if (novelFragment != null && novelFragment!!.formatter != null && novelFragment!!.novelURL.isNotEmpty()) + if (novelFragment != null && novelFragment!!.novelURL.isNotEmpty()) ChapterLoader(chaptersLoadedAction, novelFragment!!.formatter, novelFragment!!.novelURL).execute() } if (savedInstanceState != null) { @@ -191,7 +187,7 @@ class NovelFragmentChapters : Fragment() { resume.setOnClickListener { val i = novelFragment!!.lastRead() if (i != -1 && i != -2) { - if (activity != null && novelFragment!!.formatter != null) openChapter(activity!!, novelFragment!!.novelChapters[i], novelFragment!!.novelID, novelFragment!!.formatter.formatterID) + if (activity != null) openChapter(activity!!, novelFragment!!.novelChapters[i], novelFragment!!.novelID, novelFragment!!.formatter.formatterID) } else Toast.makeText(context, "No chapters! How did you even press this!", Toast.LENGTH_SHORT).show() } } @@ -222,60 +218,104 @@ class NovelFragmentChapters : Fragment() { } override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { + return when (item.itemId) { + R.id.download -> { + val builder = AlertDialog.Builder(activity!!) + builder.setTitle(R.string.download) + .setItems(R.array.chapters_download_options) { dialog, which -> + when (which) { + 0 -> { + // All + for (chapter in novelFragment?.novelChapters!!) + DownloadManager.addToDownload(activity!!, DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, chapter.title, getChapterIDFromChapterURL(chapter.link))) + } + 1 -> { + // Unread + for (chapter in novelFragment?.novelChapters!!) { + val id = getChapterIDFromChapterURL(chapter.link) + if (getStatus(id) == (Status.UNREAD)) + DownloadManager.addToDownload(activity!!, DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, chapter.title, id)) + } + } + 2 -> { + // TODO Custom + Utilities.regret(context!!) + } + 3 -> { + // TODO Next 10 + Utilities.regret(context!!) + } + 4 -> { + // TODO Next 5 + Utilities.regret(context!!) + } + 5 -> { + // Download next + val last = novelFragment!!.getLastRead() + if (last != null) { + val next = novelFragment!!.getNextChapter(last.link, novelFragment!!.novelChapters) + if (next != null) + DownloadManager.addToDownload(activity!!, DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, next.title, getChapterIDFromChapterURL(next.link))) + } + } + } + } + builder.create().show() + true + } R.id.chapter_select_all -> { for (novelChapter in novelFragment!!.novelChapters) if (!contains(novelChapter)) selectedChapters.add(novelChapter) updateAdapter() - return true + true } R.id.chapter_download_selected -> { for (novelChapter in selectedChapters) { - val chapterID = DatabaseIdentification.getChapterIDFromChapterURL(novelChapter.link) - if (!Database.DatabaseChapter.isSaved(chapterID)) { + val chapterID = getChapterIDFromChapterURL(novelChapter.link) + if (!isSaved(chapterID)) { val downloadItem = DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, novelChapter.title, chapterID) DownloadManager.addToDownload(activity, downloadItem) } } updateAdapter() - return true + true } R.id.chapter_delete_selected -> { for (novelChapter in selectedChapters) { - val chapterID = DatabaseIdentification.getChapterIDFromChapterURL(novelChapter.link) - if (Database.DatabaseChapter.isSaved(chapterID)) DownloadManager.delete(context, DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, novelChapter.title, chapterID)) + val chapterID = getChapterIDFromChapterURL(novelChapter.link) + if (isSaved(chapterID)) DownloadManager.delete(context, DownloadItem(novelFragment!!.formatter, novelFragment!!.novelPage.title, novelChapter.title, chapterID)) } updateAdapter() - return true + true } R.id.chapter_deselect_all -> { selectedChapters = ArrayList() updateAdapter() if (inflater != null) activity?.invalidateOptionsMenu() - return true + true } R.id.chapter_mark_read -> { for (novelChapter in selectedChapters) { - val chapterID = DatabaseIdentification.getChapterIDFromChapterURL(novelChapter.link) - if (Database.DatabaseChapter.getStatus(chapterID).a != 2) Database.DatabaseChapter.setChapterStatus(chapterID, Status.READ) + val chapterID = getChapterIDFromChapterURL(novelChapter.link) + if (getStatus(chapterID).a != 2) setChapterStatus(chapterID, Status.READ) } updateAdapter() - return true + true } R.id.chapter_mark_unread -> { for (novelChapter in selectedChapters) { - val chapterID = DatabaseIdentification.getChapterIDFromChapterURL(novelChapter.link) - if (Database.DatabaseChapter.getStatus(chapterID).a != 0) Database.DatabaseChapter.setChapterStatus(chapterID, Status.UNREAD) + val chapterID = getChapterIDFromChapterURL(novelChapter.link) + if (getStatus(chapterID).a != 0) setChapterStatus(chapterID, Status.UNREAD) } updateAdapter() - return true + true } R.id.chapter_mark_reading -> { for (novelChapter in selectedChapters) { - val chapterID = DatabaseIdentification.getChapterIDFromChapterURL(novelChapter.link) - if (Database.DatabaseChapter.getStatus(chapterID).a != 0) Database.DatabaseChapter.setChapterStatus(chapterID, Status.READING) + val chapterID = getChapterIDFromChapterURL(novelChapter.link) + if (getStatus(chapterID).a != 0) setChapterStatus(chapterID, Status.READING) } updateAdapter() - return true + true } R.id.chapter_select_between -> { val min = findMinPosition() @@ -286,15 +326,15 @@ class NovelFragmentChapters : Fragment() { x++ } updateAdapter() - return true + true } R.id.chapter_filter -> { novelFragment!!.novelChapters = novelFragment!!.novelChapters.reversed() reversed = !reversed return updateAdapter() } + else -> false } - return false } override fun onResume() { @@ -314,7 +354,6 @@ class NovelFragmentChapters : Fragment() { if (selectedChapters.size <= 0) inflater.inflate(R.menu.toolbar_chapters, menu) else inflater.inflate(R.menu.toolbar_chapters_selected, menu) } - @JvmField var reversed = false /** diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/demarkActions/ThemeChange.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/demarkActions/ThemeChange.kt new file mode 100644 index 0000000000..9f33ed926f --- /dev/null +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/demarkActions/ThemeChange.kt @@ -0,0 +1,48 @@ +package com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions + +import com.github.doomsdayrs.apps.shosetsu.backend.Utilities +import com.github.doomsdayrs.apps.shosetsu.ui.reader.fragments.ChapterView + +/* + * This file is part of shosetsu. + * + * shosetsu is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * shosetsu is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with shosetsu. If not, see . + * ==================================================================== + */ + +/** + * shosetsu + * 01 / 01 / 2020 + * + * @author github.com/doomsdayrs + */ + +class ThemeChange(private val chapterReader: ChapterView) : Utilities.DeMarkAction { + + override fun action(spared: Int) { + when (spared) { + 0 -> { + Utilities.setNightNode() + } + 1 -> { + Utilities.setLightMode() + } + 2 -> { + Utilities.setSepiaMode(chapterReader.context!!) + } + } + chapterReader.setUpReader() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/fragments/ChapterView.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/fragments/ChapterView.kt index ac7d71ec5b..a749ddf3aa 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/fragments/ChapterView.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/reader/fragments/ChapterView.kt @@ -12,10 +12,7 @@ import com.github.doomsdayrs.apps.shosetsu.backend.database.Database import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseIdentification import com.github.doomsdayrs.apps.shosetsu.ui.reader.ChapterReader import com.github.doomsdayrs.apps.shosetsu.ui.reader.async.ChapterViewLoader -import com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions.IndentChange -import com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions.ParaSpacingChange -import com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions.ReaderChange -import com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions.TextSizeChange +import com.github.doomsdayrs.apps.shosetsu.ui.reader.demarkActions.* import com.github.doomsdayrs.apps.shosetsu.ui.reader.listeners.ToolbarHideOnClickListener import com.github.doomsdayrs.apps.shosetsu.variables.Settings import com.github.doomsdayrs.apps.shosetsu.variables.enums.Status @@ -45,7 +42,11 @@ import kotlinx.android.synthetic.main.chapter_view.* * @author github.com/doomsdayrs */ class ChapterView : Fragment() { - private val demarkActions = arrayOf(TextSizeChange(this), ParaSpacingChange(this), IndentChange(this), ReaderChange(this)) + private val demarkActions = arrayOf(TextSizeChange(this), ParaSpacingChange(this), IndentChange(this), ReaderChange(this), ThemeChange(this)) + + // Order of values. Night, Light, Sepia + private lateinit var themes: Array + // Order of values. Small,Medium,Large private lateinit var textSizes: Array // Order of values. Non,Small,Medium,Large @@ -85,7 +86,27 @@ class ChapterView : Fragment() { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.toolbar_chapter_view, menu) // Night mode - menu.findItem(R.id.chapter_view_nightMode).isChecked = Utilities.isReaderNightMode + run { + themes = arrayOf( + menu.findItem(R.id.chapter_view_reader_night), + menu.findItem(R.id.chapter_view_reader_light), + menu.findItem(R.id.chapter_view_reader_sepia)) + when (Utilities.getReaderColor(context!!)) { + 0 -> { + themes[0].setChecked(true) + } + 1 -> { + themes[1].setChecked(true) + } + 2 -> { + themes[2].setChecked(true) + } + else -> { + Utilities.setLightMode() + themes[1].setChecked(true) + } + } + } // Bookmark run { bookmark = menu.findItem(R.id.chapter_view_bookmark) @@ -168,19 +189,22 @@ class ChapterView : Fragment() { override fun onOptionsItemSelected(item: MenuItem): Boolean { Log.d("item", item.toString()) return when (item.itemId) { - R.id.chapter_view_nightMode -> { - if (!item.isChecked) { - Utilities.swapReaderColor() - setUpReader() - } else { - Utilities.swapReaderColor() - setUpReader() - } - item.isChecked = !item.isChecked + R.id.chapter_view_reader_night -> { + Utilities.unmarkMenuItems(themes, 0, demarkActions[4]) + true + } + + R.id.chapter_view_reader_light -> { + Utilities.unmarkMenuItems(themes, 1, demarkActions[4]) + true + } + R.id.chapter_view_reader_sepia -> { + Utilities.unmarkMenuItems(themes, 2, demarkActions[4]) true } R.id.tap_to_scroll -> { - tapToScroll!!.isChecked = Utilities.toggleTapToScroll() + Utilities.regret(context!!) + // tapToScroll!!.isChecked = Utilities.toggleTapToScroll() true } R.id.chapter_view_bookmark -> { @@ -241,11 +265,13 @@ class ChapterView : Fragment() { true } R.id.reader_0 -> { - Utilities.unmarkMenuItems(readers, 0, demarkActions[3]) + Utilities.regret(context!!) + //Utilities.unmarkMenuItems(readers, 0, demarkActions[3]) true } R.id.reader_1 -> { - Utilities.unmarkMenuItems(readers, 1, demarkActions[3]) + Utilities.regret(context!!) + //Utilities.unmarkMenuItems(readers, 1, demarkActions[3]) true } else -> false diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/SearchFragment.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/SearchFragment.kt index 2ac4512820..08b099329d 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/SearchFragment.kt @@ -6,12 +6,12 @@ import android.view.* import android.widget.SearchView import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager -import com.github.doomsdayrs.api.shosetsu.services.core.objects.Novel import com.github.doomsdayrs.apps.shosetsu.R import com.github.doomsdayrs.apps.shosetsu.R.layout.search_activity import com.github.doomsdayrs.apps.shosetsu.backend.Utilities.setActivityTitle import com.github.doomsdayrs.apps.shosetsu.ui.search.adapters.SearchAdapter import kotlinx.android.synthetic.main.search_activity.* +import java.io.Serializable /* * This file is part of Shosetsu. @@ -56,8 +56,9 @@ class SearchFragment : Fragment() { return StoredData(id) } - class StoredData(val id: Int) { - var novelArray: List = arrayListOf() + class StoredData(val id: Int) : Serializable { + //TODO This is dirty, Maybe replace with CatalogueNovelCard later + var novelArray: List> = arrayListOf() var intArray: List = arrayListOf() } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/adapters/SearchResultsAdapter.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/adapters/SearchResultsAdapter.kt index a00b1e1b84..b9700ee1c7 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/adapters/SearchResultsAdapter.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/adapters/SearchResultsAdapter.kt @@ -4,7 +4,6 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.doomsdayrs.api.shosetsu.services.core.dep.Formatter -import com.github.doomsdayrs.api.shosetsu.services.core.objects.Novel import com.github.doomsdayrs.apps.shosetsu.R import com.github.doomsdayrs.apps.shosetsu.backend.database.Database import com.github.doomsdayrs.apps.shosetsu.ui.main.MainActivity @@ -41,13 +40,13 @@ import com.squareup.picasso.Picasso */ class SearchResultsAdapter(private val searchViewHolder: SearchViewHolder) : RecyclerView.Adapter() { private var intArray: ArrayList = arrayListOf(-1) - private var novelArray: List = arrayListOf() + private var novelArray: List> = arrayListOf() constructor(array: ArrayList, searchViewHolder: SearchViewHolder) : this(searchViewHolder) { this.intArray = array } - constructor(array: List, searchViewHolder: SearchViewHolder) : this(searchViewHolder) { + constructor(array: List>, searchViewHolder: SearchViewHolder) : this(searchViewHolder) { novelArray = array } @@ -68,10 +67,10 @@ class SearchResultsAdapter(private val searchViewHolder: SearchViewHolder) : Rec val id: Int if (isWebsiteSearch()) { - val novel: Novel = novelArray[position] - title = novel.title - url = novel.link - imageURL = novel.imageURL + val novel: Array = novelArray[position] + title = novel[0] + url = novel[1] + imageURL = novel[2] formatter = searchViewHolder.formatter id = Database.DatabaseIdentification.getNovelIDFromNovelURL(imageURL) } else { diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/async/SearchLoader.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/async/SearchLoader.kt index f3ad4148f8..1e7ee8e032 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/async/SearchLoader.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/async/SearchLoader.kt @@ -3,6 +3,7 @@ package com.github.doomsdayrs.apps.shosetsu.ui.search.async import android.os.AsyncTask import android.view.View import com.github.doomsdayrs.api.shosetsu.services.core.objects.Novel +import com.github.doomsdayrs.apps.shosetsu.backend.Utilities import com.github.doomsdayrs.apps.shosetsu.backend.async.CatalogueLoader import com.github.doomsdayrs.apps.shosetsu.ui.search.SearchFragment import com.github.doomsdayrs.apps.shosetsu.ui.search.adapters.SearchResultsAdapter @@ -33,7 +34,7 @@ import com.github.doomsdayrs.apps.shosetsu.ui.search.viewHolders.SearchViewHolde * @author github.com/doomsdayrs */ class SearchLoader(private val searchViewHolder: SearchViewHolder) : AsyncTask() { - var array: List = arrayListOf() + var array: List> = arrayListOf() override fun onPreExecute() { super.onPreExecute() @@ -44,8 +45,10 @@ class SearchLoader(private val searchViewHolder: SearchViewHolder) : AsyncTask? = CatalogueLoader(searchViewHolder.query, searchViewHolder.formatter).execute() - if (a != null) - array = a + val correct: ArrayList> = if (a != null) + Utilities.convertNovelArrayToString2DArray(a) + else ArrayList() + array = correct return true } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/viewHolders/SearchViewHolder.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/viewHolders/SearchViewHolder.kt index 224cf8cfde..c930213324 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/viewHolders/SearchViewHolder.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/search/viewHolders/SearchViewHolder.kt @@ -62,7 +62,7 @@ class SearchViewHolder(itemView: View, val searchFragment: SearchFragment) : Rec if (!searchFragment.containsData(id)) { val intArray: ArrayList = getIntLibrary() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - intArray.removeIf { novelID: Int? -> !DatabaseNovels.getNovelTitle(novelID!!).toLowerCase().contains(query.toLowerCase(Locale.ROOT)) } + intArray.removeIf { novelID: Int? -> !DatabaseNovels.getNovelTitle(novelID!!).toLowerCase(Locale.ROOT).contains(query.toLowerCase(Locale.ROOT)) } } else { for (x in intArray.indices.reversed()) if (!DatabaseNovels.getNovelTitle(intArray[x]).toLowerCase(Locale.ROOT).contains(query.toLowerCase(Locale.ROOT))) intArray.removeAt(x) } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/settings/subFragments/ViewSettings.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/settings/subFragments/ViewSettings.kt index 7e3dcb0cfe..86e34a9c56 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/settings/subFragments/ViewSettings.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/settings/subFragments/ViewSettings.kt @@ -116,12 +116,27 @@ class ViewSettings : Fragment() { } }), - SettingsItemData(SettingsType.SWITCH) - .setTitle(R.string.reader_night_mode) - .setSwitchIsChecked(Utilities.isReaderNightMode) - .setSwitchOnCheckedListner(CompoundButton.OnCheckedChangeListener { _, p1 -> - Log.d("NightMode", p1.toString()) - if (!Utilities.isReaderNightMode) Utilities.setNightNode() else Utilities.unsetNightMode() + SettingsItemData(SettingsType.SPINNER) + .setTitle(R.string.reader_theme) + .setOnItemSelectedListener(object : OnItemSelectedListener { + override fun onNothingSelected(p0: AdapterView<*>?) {} + override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) { + Log.d("NightMode", p1.toString()) + when (p2) { + 0 -> { + Utilities.setNightNode() + } + 1 -> { + Utilities.setLightMode() + } + 2 -> { + p1?.context?.let { Utilities.setSepiaMode(it) } + } + else -> { + Log.e("NightMode", "UnknownType") + } + } + } }), SettingsItemData(SettingsType.SWITCH) @@ -131,7 +146,7 @@ class ViewSettings : Fragment() { Log.d("Tap to scroll", p1.toString()) Utilities.toggleTapToScroll() }) - ) + ) val adapter: SettingItemsAdapter = SettingItemsAdapter(settings) private fun findDataByID(@StringRes id: Int): Int { @@ -160,15 +175,21 @@ class ViewSettings : Fragment() { } } + run { + val x = findDataByID(R.string.reader_theme) + settings[x].adapter = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.reader_themes)) + settings[x].spinnerSelection = Utilities.getReaderColor(context!!) + } + run { val x = findDataByID(R.string.spacing) - settings[x].adapter = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.sizes_with_none)) + settings[x].adapter = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.sizes_with_none)) settings[x].spinnerSelection = Settings.paragraphSpacing } run { val x = findDataByID(R.string.indent_size) - settings[x].adapter = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.sizes_with_none)) + settings[x].adapter = ArrayAdapter(context!!, android.R.layout.simple_spinner_item, resources.getStringArray(R.array.sizes_with_none)) settings[x].spinnerSelection = (Settings.indentSize) } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdateFragment.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdateFragment.kt index 47d6bbef6c..1c3ed1d480 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdateFragment.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdateFragment.kt @@ -37,7 +37,6 @@ import java.util.* * @author github.com/doomsdayrs */ class UpdateFragment : Fragment() { - @JvmField var date: Long = -1 private val novels = ArrayList() private var updates = ArrayList() @@ -47,10 +46,6 @@ class UpdateFragment : Fragment() { outState.putLong("date", date) } - fun setDate(date: Long) { - this.date = date - } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.updates_list, container, false) if (date == -1L) if (savedInstanceState != null) date = savedInstanceState.getLong("date") diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdatesFragment.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdatesFragment.kt index 6adca2cea7..faf183ae76 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdatesFragment.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/updates/UpdatesFragment.kt @@ -74,7 +74,7 @@ class UpdatesFragment : Fragment() { Log.d("StartingDay", DateTime(startTime).toString()) for (x in 0 until days) { val updateFragment = UpdateFragment() - updateFragment.setDate(startTime) + updateFragment.date = (startTime) startTime += 86400000 updatesFragments.add(updateFragment) } @@ -92,7 +92,7 @@ class UpdatesFragment : Fragment() { } // TODAY val updateFragment = UpdateFragment() - updateFragment.setDate(DatabaseUpdates.trimDate(DateTime(System.currentTimeMillis())).millis) + updateFragment.date = (DatabaseUpdates.trimDate(DateTime(System.currentTimeMillis())).millis) updatesFragments.add(updateFragment) updatesFragments.reverse() val pagerAdapter = UpdatedDaysPager(childFragmentManager, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT, updatesFragments) @@ -102,6 +102,7 @@ class UpdatesFragment : Fragment() { override fun onTabSelected(tab: TabLayout.Tab) { viewpager!!.currentItem = tab.position } + override fun onTabUnselected(tab: TabLayout.Tab) {} override fun onTabReselected(tab: TabLayout.Tab) {} }) diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/webView/Actions.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/webView/Actions.kt index 99a19ee3ed..440ff8faf2 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/webView/Actions.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/ui/webView/Actions.kt @@ -27,7 +27,6 @@ enum class Actions(val action: Int) { VIEW(0), CLOUD_FLARE(1); companion object { - @kotlin.jvm.JvmField val actions = ArrayList() init { diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DefaultScrapers.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DefaultScrapers.kt index 9ae7b7ae3f..58a66b0a06 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DefaultScrapers.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DefaultScrapers.kt @@ -48,7 +48,6 @@ enum class DefaultScrapers(private val formatter: Formatter) : Formatter { companion object { val formatters = ArrayList() - @JvmStatic fun getByID(ID: Int): Formatter? { for (formatter in formatters) { if (formatter.formatterID == ID) return formatter @@ -56,7 +55,6 @@ enum class DefaultScrapers(private val formatter: Formatter) : Formatter { return null } - @JvmStatic val asCatalogue: ArrayList get() { val catalogueCards = ArrayList() diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DownloadItem.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DownloadItem.kt index 2c6fdef14f..0d4e1df672 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DownloadItem.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/DownloadItem.kt @@ -30,11 +30,8 @@ import com.github.doomsdayrs.apps.shosetsu.backend.database.Database.DatabaseIde * These items symbolize download items and their data */ class DownloadItem(val formatter: Formatter, novelName: String, chapterName: String, chapterID: Int) { - @JvmField val novelName: String - @JvmField val chapterName: String - @JvmField val chapterURL: String? val chapterID: Int @@ -48,7 +45,6 @@ class DownloadItem(val formatter: Formatter, novelName: String, chapterName: Str * @param s string to clean * @return cleaned string */ - @JvmStatic fun cleanse(s: String): String { //Log.d("Cleaning", s); var s = s s = s.replace("'".toRegex(), "_").replace("\"".toRegex(), "_") @@ -61,8 +57,8 @@ class DownloadItem(val formatter: Formatter, novelName: String, chapterName: Str init { this.novelName = cleanse(novelName) this.chapterName = cleanse(chapterName) - val novelID = DatabaseIdentification.getNovelIDFromChapterID(chapterID) - val novelURL = DatabaseIdentification.getNovelURLfromNovelID(novelID) + // val novelID = DatabaseIdentification.getNovelIDFromChapterID(chapterID) + //val novelURL = DatabaseIdentification.getNovelURLfromNovelID(novelID) chapterURL = DatabaseIdentification.getChapterURLFromChapterID(chapterID) this.chapterID = chapterID } diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/Settings.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/Settings.kt index 5359e24516..91026ba72a 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/Settings.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/Settings.kt @@ -31,7 +31,6 @@ object Settings { /** * How to mark a chapter as reading */ - @JvmField var ReaderMarkingType: Int = MarkingTypes.ONVIEW.i enum class MarkingTypes(val i: Int) { @@ -43,7 +42,6 @@ object Settings { /** * Reader text size */ - @JvmField var ReaderTextSize: Float = TextSizes.SMALL.i.toFloat() @Suppress("unused") @@ -58,31 +56,26 @@ object Settings { /** * Reader text color */ - @JvmField var ReaderTextColor = Color.BLACK /** * Reader background color */ - @JvmField var ReaderTextBackgroundColor = Color.WHITE /** * global connectivity manager variable */ - @JvmField var connectivityManager: ConnectivityManager? = null /** * If download manager is paused */ - @JvmField var downloadPaused = false /** * Current theme to use */ - @JvmField var themeMode = Themes.LIGHT.id //TODO Use this @@ -92,9 +85,7 @@ object Settings { DARK(2) } - @JvmField var paragraphSpacing = 0 - @JvmField var indentSize = 0 } \ No newline at end of file diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/CatalogueNovelCard.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/CatalogueNovelCard.kt index 7e22652636..e1b9b1bd19 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/CatalogueNovelCard.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/CatalogueNovelCard.kt @@ -23,19 +23,4 @@ import java.io.Serializable * * @author github.com/doomsdayrs */ -class CatalogueNovelCard -/** - * Constructor - * @param imageURL image chapterURL - * @param title title - * @param novelID id of novel - * @param novelURL novelURL - */( - /** - * Image novelURL - */ - val imageURL: String, title: String, val novelID: Int, - /** - * link to the novel - */ - val novelURL: String) : RecycleCard(title), Serializable \ No newline at end of file +class CatalogueNovelCard(val imageURL: String, title: String, val novelID: Int, val novelURL: String) : RecycleCard(title), Serializable \ No newline at end of file diff --git a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/NovelCard.kt b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/NovelCard.kt index 53eccb612a..de5bc16a40 100644 --- a/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/NovelCard.kt +++ b/app/src/main/java/com/github/doomsdayrs/apps/shosetsu/variables/recycleObjects/NovelCard.kt @@ -21,25 +21,4 @@ package com.github.doomsdayrs.apps.shosetsu.variables.recycleObjects * * @author github.com/doomsdayrs */ -class NovelCard -/** - * Constructor - * - * @param title title - * @param novelID novel ID - * @param novelURL novelURL - * @param imageURL imageURL - * @param formatterID id of formatter - */(title: String, val novelID: Int, - /** - * NovelURL - */ - val novelURL: String, - /** - * ImageURL - */ - val imageURL: String, - /** - * ID of formatter - */ - val formatterID: Int) : RecycleCard(title) \ No newline at end of file +class NovelCard(title: String, val novelID: Int, val novelURL: String, val imageURL: String, val formatterID: Int) : RecycleCard(title) \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_catalogue.xml b/app/src/main/res/layout/fragment_catalogue.xml index e195a8333e..8c78a0dfd2 100644 --- a/app/src/main/res/layout/fragment_catalogue.xml +++ b/app/src/main/res/layout/fragment_catalogue.xml @@ -44,7 +44,6 @@ @@ -82,7 +81,8 @@ android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + app:layout_constraintStart_toStartOf="parent" + android:contentDescription="@string/todo" /> diff --git a/app/src/main/res/menu/toolbar_chapter_view.xml b/app/src/main/res/menu/toolbar_chapter_view.xml index fc18fca5c5..d01801fee5 100644 --- a/app/src/main/res/menu/toolbar_chapter_view.xml +++ b/app/src/main/res/menu/toolbar_chapter_view.xml @@ -11,10 +11,23 @@ app:showAsAction="never" /> + android:title="@string/reader_theme" + app:showAsAction="never"> + + + + + + diff --git a/app/src/main/res/menu/toolbar_chapters.xml b/app/src/main/res/menu/toolbar_chapters.xml index 5b159ea0f5..dabca735a3 100644 --- a/app/src/main/res/menu/toolbar_chapters.xml +++ b/app/src/main/res/menu/toolbar_chapters.xml @@ -9,6 +9,7 @@ app:showAsAction="ifRoom" /> \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png deleted file mode 100644 index 3b337c37a5..0000000000 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png deleted file mode 100644 index eea1ec7bc6..0000000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png deleted file mode 100644 index fca3f51320..0000000000 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 90a410db9e..0000000000 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png deleted file mode 100644 index 6762eb478b..0000000000 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and /dev/null differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c902e8282e..a3ed63e8fc 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -13,6 +13,7 @@ #80000000 + #F5DEB3 #00000000 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 65dcbe0514..a546f45c64 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,7 +14,7 @@ filter - Reader Night mode + Reader Theme Text size Paragraph spacing Paragraph indent @@ -22,9 +22,7 @@ Novel Title: Novel Author(s): Novel Description - Anilist Download - Myanimelist Download directory Position: Backup Now @@ -134,10 +132,38 @@ Maybe later Huh, not interested + + Night + Light + Sepia + + + @string/night + @string/light + @string/sepia + + Check for updates Global search… + + Download next chapter + Download next 5 chapters + Download next 10 chapters + Download custom + Download all + Download unread + + + @string/download_all_chapters + @string/download_unread_chapters + @string/download_custom_chapters + @string/download_next_10_chapters + @string/download_next_5_chapters + @string/download_next_chapter + + Processing data This feature have not been reintroduced yet due to time constraints :( diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 01671879f7..200bb6e3e5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -4,6 +4,8 @@ diff --git a/app/update.xml b/app/update.xml index 6654ffc23f..d280fd5108 100644 --- a/app/update.xml +++ b/app/update.xml @@ -1,15 +1,11 @@ - 1.0.0 - 22 + 1.1.0 + 23 https://github.com/Doomsdayrs/shosetsu/releases - - New DB structure, Incompatible to old releases - - Some UI differences - - New App icon - - Settings redesign - - Some features disabled for due to being untested with new DB + - Spoooood update :D diff --git a/build.gradle b/build.gradle index 4fda55a999..74a12d3e07 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.0.0-alpha06' + classpath 'com.android.tools.build:gradle:4.0.0-alpha07' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files