From 9fc80d63974d067d0e605197ef413cfcec69ccc5 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 00:44:08 -0600 Subject: [PATCH 01/12] beta version update --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 240a28a1ff..26ae7772e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,7 +21,7 @@ android { minSdk 23 targetSdk 34 versionCode ((System.currentTimeMillis() / 60000).toInteger()) - versionName "2.0.0" + versionName "2.0.0-beta00" signingConfig signingConfigs.debug } From 876304065de88dc9776021101d36fb69a0f17822 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:19:14 -0600 Subject: [PATCH 02/12] fix for SettingsDialogFragment. [] --- .../download/manga/OfflineMangaFragment.kt | 12 +++++--- .../ani/dantotsu/home/AnimePageAdapter.kt | 7 ++--- .../java/ani/dantotsu/home/HomeFragment.kt | 28 +++++++++---------- .../ani/dantotsu/home/MangaPageAdapter.kt | 7 ++--- .../settings/SettingsDialogFragment.kt | 16 ++++++++++- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt index 3809dc9e95..e81d2817cf 100644 --- a/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt +++ b/app/src/main/java/ani/dantotsu/download/manga/OfflineMangaFragment.kt @@ -69,10 +69,14 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener { val animeUserAvatar = view.findViewById(R.id.offlineMangaUserAvatar) animeUserAvatar.setSafeOnClickListener { - SettingsDialogFragment(SettingsDialogFragment.Companion.PageType.HOME).show( - (it.context as AppCompatActivity).supportFragmentManager, - "dialog" - ) + animeUserAvatar.setSafeOnClickListener { + val dialogFragment = SettingsDialogFragment.newInstance(SettingsDialogFragment.Companion.PageType.HOME) + dialogFragment.show( + (it.context as AppCompatActivity).supportFragmentManager, + "dialog" + ) + } + } val colorOverflow = currContext()?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE) diff --git a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt index 63ee9b84cb..65b698606c 100644 --- a/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt @@ -98,10 +98,9 @@ class AnimePageAdapter : RecyclerView.Adapter= Build.VERSION_CODES.M) { - binding.homeScroll.setOnScrollChangeListener { _, _, _, _, _ -> - if (!binding.homeScroll.canScrollVertically(1)) { - reached = true - bottomBar.animate().translationZ(0f).setDuration(duration).start() - ObjectAnimator.ofFloat(bottomBar, "elevation", 4f, 0f).setDuration(duration) + binding.homeScroll.setOnScrollChangeListener { _, _, _, _, _ -> + if (!binding.homeScroll.canScrollVertically(1)) { + reached = true + bottomBar.animate().translationZ(0f).setDuration(duration).start() + ObjectAnimator.ofFloat(bottomBar, "elevation", 4f, 0f).setDuration(duration) + .start() + } else { + if (reached) { + bottomBar.animate().translationZ(12f).setDuration(duration).start() + ObjectAnimator.ofFloat(bottomBar, "elevation", 0f, 4f).setDuration(duration) .start() - } else { - if (reached) { - bottomBar.animate().translationZ(12f).setDuration(duration).start() - ObjectAnimator.ofFloat(bottomBar, "elevation", 0f, 4f).setDuration(duration) - .start() - } } } } diff --git a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt index 7053df8ab6..17c0bf06bb 100644 --- a/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt +++ b/app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt @@ -93,10 +93,9 @@ class MangaPageAdapter : RecyclerView.Adapter Date: Wed, 6 Dec 2023 19:21:53 -0600 Subject: [PATCH 03/12] out of bounds on 25 fix --- .../main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt index 67304285ae..66c922b4b3 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaChapterAdapter.kt @@ -120,6 +120,7 @@ class MangaChapterAdapter( fun downloadNChaptersFrom(position: Int, n: Int) { //download next n chapters + if (position < 0 || position >= arr.size) return for (i in 0.. Date: Wed, 6 Dec 2023 19:25:00 -0600 Subject: [PATCH 04/12] toast fix --- app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt b/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt index ea2fa1a0b7..03b4091905 100644 --- a/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt +++ b/app/src/main/java/ani/dantotsu/parsers/AniyomiAdapter.kt @@ -16,6 +16,7 @@ import ani.dantotsu.logger import ani.dantotsu.media.anime.AnimeNameAdapter import ani.dantotsu.media.manga.ImageData import ani.dantotsu.media.manga.MangaCache +import ani.dantotsu.snackString import com.google.firebase.crashlytics.FirebaseCrashlytics import eu.kanade.tachiyomi.animesource.AnimeCatalogueSource import eu.kanade.tachiyomi.animesource.model.AnimesPage @@ -327,8 +328,7 @@ class DynamicMangaParser(extension: MangaExtension.Installed) : MangaParser() { } catch (e: Exception) { logger("loadImages Exception: $e") - Toast.makeText(currContext(), "Failed to load images: $e", Toast.LENGTH_SHORT) - .show() + snackString("Failed to load images: $e") emptyList() } } From 38a27c45a1f57549eb745d66ab474b73bbd71392 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:27:34 -0600 Subject: [PATCH 05/12] empty check on mediaList --- .../java/ani/dantotsu/media/MediaAdaptor.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt b/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt index 50cd88dc8b..fd04eb58cd 100644 --- a/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt +++ b/app/src/main/java/ani/dantotsu/media/MediaAdaptor.kt @@ -300,17 +300,16 @@ class MediaAdaptor( return type } - fun randomOptionClick() { //used for user list - val media = mediaList?.random() - if (media != null) { - mediaList?.let { - clicked( - it.indexOf(media), - null - ) - } + fun randomOptionClick() { + val media = if (!mediaList.isNullOrEmpty()) { + mediaList.random() + } else { + null + } + media?.let { + val index = mediaList?.indexOf(it) ?: -1 + clicked(index, null) } - } inner class MediaViewHolder(val binding: ItemMediaCompactBinding) : From ac9d3a2363804e3162a80458c84ed46ffeadaf50 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:32:14 -0600 Subject: [PATCH 06/12] fix for Unable to destroy activity MediaDetailsActivity --- .../media/anime/AnimeWatchFragment.kt | 26 ++++++++++--------- .../dantotsu/media/manga/MangaReadFragment.kt | 26 ++++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt index dbe483b302..df3522200a 100644 --- a/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/anime/AnimeWatchFragment.kt @@ -298,19 +298,21 @@ class AnimeWatchFragment : Fragment() { fun openSettings(pkg: AnimeExtension.Installed) { val changeUIVisibility: (Boolean) -> Unit = { show -> - val activity = requireActivity() as MediaDetailsActivity - val visibility = if (show) View.VISIBLE else View.GONE - activity.findViewById(R.id.mediaAppBar).visibility = visibility - activity.findViewById(R.id.mediaViewPager).visibility = visibility - activity.findViewById(R.id.mediaCover).visibility = visibility - activity.findViewById(R.id.mediaClose).visibility = visibility - try { - activity.findViewById(R.id.mediaTab).visibility = visibility - } catch (e: ClassCastException) { - activity.findViewById(R.id.mediaTab).visibility = visibility + val activity = activity + if (activity is MediaDetailsActivity && isAdded) { + val visibility = if (show) View.VISIBLE else View.GONE + activity.findViewById(R.id.mediaAppBar).visibility = visibility + activity.findViewById(R.id.mediaViewPager).visibility = visibility + activity.findViewById(R.id.mediaCover).visibility = visibility + activity.findViewById(R.id.mediaClose).visibility = visibility + try { + activity.findViewById(R.id.mediaTab).visibility = visibility + } catch (e: ClassCastException) { + activity.findViewById(R.id.mediaTab).visibility = visibility + } + activity.findViewById(R.id.fragmentExtensionsContainer).visibility = + if (show) View.GONE else View.VISIBLE } - activity.findViewById(R.id.fragmentExtensionsContainer).visibility = - if (show) View.GONE else View.VISIBLE } val allSettings = pkg.sources.filterIsInstance() if (allSettings.isNotEmpty()) { diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index 2239bf5ed0..ac4a255fe5 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -338,19 +338,21 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { fun openSettings(pkg: MangaExtension.Installed) { val changeUIVisibility: (Boolean) -> Unit = { show -> - val activity = requireActivity() as MediaDetailsActivity - val visibility = if (show) View.VISIBLE else View.GONE - activity.findViewById(R.id.mediaAppBar).visibility = visibility - activity.findViewById(R.id.mediaViewPager).visibility = visibility - activity.findViewById(R.id.mediaCover).visibility = visibility - activity.findViewById(R.id.mediaClose).visibility = visibility - try { - activity.findViewById(R.id.mediaTab).visibility = visibility - } catch (e: ClassCastException) { - activity.findViewById(R.id.mediaTab).visibility = visibility + val activity = activity + if (activity is MediaDetailsActivity && isAdded) { + val visibility = if (show) View.VISIBLE else View.GONE + activity.findViewById(R.id.mediaAppBar).visibility = visibility + activity.findViewById(R.id.mediaViewPager).visibility = visibility + activity.findViewById(R.id.mediaCover).visibility = visibility + activity.findViewById(R.id.mediaClose).visibility = visibility + try { + activity.findViewById(R.id.mediaTab).visibility = visibility + } catch (e: ClassCastException) { + activity.findViewById(R.id.mediaTab).visibility = visibility + } + activity.findViewById(R.id.fragmentExtensionsContainer).visibility = + if (show) View.GONE else View.VISIBLE } - activity.findViewById(R.id.fragmentExtensionsContainer).visibility = - if (show) View.GONE else View.VISIBLE } val allSettings = pkg.sources.filterIsInstance() if (allSettings.isNotEmpty()) { From ac6b22f6596b73f653a7bf97bc1d344d7c62b954 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:34:22 -0600 Subject: [PATCH 07/12] progressChapterIndex IndexOutOfBoundsException fix --- app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt index ac4a255fe5..25a87c9bc1 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/MangaReadFragment.kt @@ -203,6 +203,7 @@ open class MangaReadFragment : Fragment(), ScanlatorSelectionListener { val chapters = media.manga?.chapters?.values?.toList() //filter by selected language val progressChapterIndex = chapters?.indexOfFirst { MangaNameAdapter.findChapterNumber(it.number)?.toInt() == selected }?:0 + if (progressChapterIndex < 0 || n < 1) return val chaptersToDownload = chapters?.subList( progressChapterIndex + 1, progressChapterIndex + n + 1 From f463275a735cff54e75a95b7dfaca7e5467b3aa3 Mon Sep 17 00:00:00 2001 From: Finnley Somdahl <87634197+rebelonion@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:22:45 -0600 Subject: [PATCH 08/12] Custom AlertDialog fix --- .../manga/mangareader/MangaReaderActivity.kt | 43 +++++++++---------- app/src/main/res/values/style.xml | 4 +- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt index d463002be4..30fefb2652 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt @@ -81,7 +81,8 @@ class MangaReaderActivity : AppCompatActivity() { private var isContVisible = false private var showProgressDialog = true - private var progressDialog: AlertDialog.Builder? = null + + //private var progressDialog: AlertDialog.Builder? = null private var maxChapterPage = 0L private var currentChapterPage = 0L @@ -253,23 +254,6 @@ class MangaReaderActivity : AppCompatActivity() { showProgressDialog = if (settings.askIndividual) loadData("${media.id}_progressDialog") != true else false - progressDialog = - if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true) { - val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null) - val checkbox = dialogView.findViewById(R.id.dialog_checkbox) - checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName) - checkbox.setOnCheckedChangeListener { _, isChecked -> - if (isChecked) progressDialog = null - saveData("${media.id}_progressDialog", isChecked) - showProgressDialog = isChecked - } - AlertDialog.Builder(this, R.style.MyPopup) - .setTitle(getString(R.string.title_update_progress)) - .setView(dialogView) - .apply { - setOnCancelListener { hideBars() } - } - } else null //Chapter Change fun change(index: Int) { @@ -811,9 +795,20 @@ class MangaReaderActivity : AppCompatActivity() { private fun progress(runnable: Runnable) { if (maxChapterPage - currentChapterPage <= 1 && Anilist.userid != null) { - if (showProgressDialog && progressDialog != null) { - progressDialog?.setCancelable(false) - ?.setPositiveButton(getString(R.string.yes)) { dialog, _ -> + if (showProgressDialog) { + val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null) + val checkbox = dialogView.findViewById(R.id.dialog_checkbox) + checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName) + checkbox.setOnCheckedChangeListener { _, isChecked -> + saveData("${media.id}_progressDialog", isChecked) + showProgressDialog = !isChecked + } + + AlertDialog.Builder(this, R.style.MyPopup) + .setTitle(getString(R.string.title_update_progress)) + .setView(dialogView) + .setCancelable(false) + .setPositiveButton(getString(R.string.yes)) { dialog, _ -> saveData("${media.id}_save_progress", true) updateProgress( media, @@ -823,12 +818,14 @@ class MangaReaderActivity : AppCompatActivity() { dialog.dismiss() runnable.run() } - ?.setNegativeButton(getString(R.string.no)) { dialog, _ -> + .setNegativeButton(getString(R.string.no)) { dialog, _ -> saveData("${media.id}_save_progress", false) dialog.dismiss() runnable.run() } - progressDialog?.show() + .setOnCancelListener { hideBars() } + .create() + .show() } else { if (loadData("${media.id}_save_progress") != false && if (media.isAdult) settings.updateForH else true) updateProgress( diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml index 9bb3424830..72d7648e70 100644 --- a/app/src/main/res/values/style.xml +++ b/app/src/main/res/values/style.xml @@ -46,8 +46,8 @@ 16dp @drawable/round_corner - - ?attr/colorOnBackground + + @color/bg_opp