From 018c84b6afd8bac27e35a962223efd721ebb525a Mon Sep 17 00:00:00 2001 From: Koitharu Date: Wed, 24 Jan 2024 11:53:53 +0200 Subject: [PATCH] Add Last used default tab in details --- .../org/koitharu/kotatsu/core/prefs/AppSettings.kt | 12 +++++++++++- .../koitharu/kotatsu/details/ui/DetailsActivity.kt | 2 +- .../kotatsu/details/ui/pager/ChaptersPagesSheet.kt | 1 + app/src/main/res/values/arrays.xml | 2 ++ app/src/main/res/values/constants.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_appearance.xml | 7 +------ 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt index 6b0da911c..466e38788 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/AppSettings.kt @@ -230,11 +230,20 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { val defaultDetailsTab: Int get() = if (isPagesTabEnabled) { - prefs.getString(KEY_DETAILS_TAB, null)?.toIntOrNull()?.coerceIn(0, 1) ?: 0 + val raw = prefs.getString(KEY_DETAILS_TAB, null)?.toIntOrNull() ?: 0 + if (raw == -1) { + lastDetailsTab + } else { + raw + }.coerceIn(0, 2) } else { 0 } + var lastDetailsTab: Int + get() = prefs.getInt(KEY_DETAILS_LAST_TAB, 0) + set(value) = prefs.edit { putInt(KEY_DETAILS_LAST_TAB, value) } + val isContentPrefetchEnabled: Boolean get() { if (isBackgroundNetworkRestricted()) { @@ -636,6 +645,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) { const val KEY_IGNORE_DOZE = "ignore_dose" const val KEY_PAGES_TAB = "pages_tab" const val KEY_DETAILS_TAB = "details_tab" + const val KEY_DETAILS_LAST_TAB = "details_last_tab" const val KEY_READING_TIME = "reading_time" const val KEY_PAGES_SAVE_DIR = "pages_dir" const val KEY_PAGES_SAVE_ASK = "pages_dir_ask" diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index be6e02ac2..b38b6e893 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -438,7 +438,7 @@ class DetailsActivity : private fun getActivityIntent(context: Context): Intent { val prefs = PreferenceManager.getDefaultSharedPreferences(context) - val useNewActivity = prefs.getBoolean(KEY_NEW_ACTIVITY, false) + val useNewActivity = prefs.getBoolean(KEY_NEW_ACTIVITY, true) return Intent( context, if (useNewActivity) DetailsActivity2::class.java else DetailsActivity::class.java, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/ChaptersPagesSheet.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/ChaptersPagesSheet.kt index 5727167ab..5ad5b7b30 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/ChaptersPagesSheet.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/pager/ChaptersPagesSheet.kt @@ -84,6 +84,7 @@ class ChaptersPagesSheet : BaseAdaptiveSheet(), Actio private fun onPageChanged(position: Int) { viewBinding?.toolbar?.invalidateMenu() + settings.lastDetailsTab = position } companion object { diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6bea0c5d2..bcdaf2ac9 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -79,8 +79,10 @@ @string/frequency_once_per_month + @string/last_used @string/chapters @string/pages + @string/bookmarks @string/automatic diff --git a/app/src/main/res/values/constants.xml b/app/src/main/res/values/constants.xml index 3788a32f4..91c9ec015 100644 --- a/app/src/main/res/values/constants.xml +++ b/app/src/main/res/values/constants.xml @@ -66,7 +66,9 @@ 30 + -1 0 1 + 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 366e0b06c..c59921a46 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -651,4 +651,5 @@ %1$d h %2$d m Fix There is no permission to access manga on external storage + Last used diff --git a/app/src/main/res/xml/pref_appearance.xml b/app/src/main/res/xml/pref_appearance.xml index e5b247b45..8e12a9ac2 100644 --- a/app/src/main/res/xml/pref_appearance.xml +++ b/app/src/main/res/xml/pref_appearance.xml @@ -48,11 +48,6 @@ - -