Add Last used default tab in details

This commit is contained in:
Koitharu
2024-01-24 11:53:53 +02:00
parent b95174727a
commit 018c84b6af
7 changed files with 19 additions and 8 deletions

View File

@@ -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"

View File

@@ -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,

View File

@@ -84,6 +84,7 @@ class ChaptersPagesSheet : BaseAdaptiveSheet<SheetChaptersPagesBinding>(), Actio
private fun onPageChanged(position: Int) {
viewBinding?.toolbar?.invalidateMenu()
settings.lastDetailsTab = position
}
companion object {

View File

@@ -79,8 +79,10 @@
<item>@string/frequency_once_per_month</item>
</string-array>
<string-array name="details_tabs" translatable="false">
<item>@string/last_used</item>
<item>@string/chapters</item>
<item>@string/pages</item>
<item>@string/bookmarks</item>
</string-array>
<string-array name="download_formats" translatable="false">
<item>@string/automatic</item>

View File

@@ -66,7 +66,9 @@
<item>30</item>
</string-array>
<string-array name="details_tabs_values" translatable="false">
<item>-1</item>
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

View File

@@ -651,4 +651,5 @@
<string name="hours_minutes_short">%1$d h %2$d m</string>
<string name="fix">Fix</string>
<string name="missing_storage_permission">There is no permission to access manga on external storage</string>
<string name="last_used">Last used</string>
</resources>

View File

@@ -48,11 +48,6 @@
<PreferenceCategory android:title="@string/details">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="new_details_screen"
android:title="Use new details screen (experimental)" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="pages_tab"
@@ -60,7 +55,7 @@
android:title="@string/show_pages_thumbs" />
<ListPreference
android:defaultValue="0"
android:defaultValue="-1"
android:dependency="pages_tab"
android:entries="@array/details_tabs"
android:entryValues="@array/details_tabs_values"