From 2cb7624953202f4552064238fbb253b243cbc5d3 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 25 Jun 2020 18:10:46 -0400 Subject: [PATCH] Make jumping to manga chapters optional --- .../eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../kanade/tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../ui/manga/chapter/MangaInfoChaptersController.kt | 7 +++++-- .../tachiyomi/ui/setting/SettingsLibraryController.kt | 5 +++++ app/src/main/res/values/strings.xml | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 42df98f0cf..c2ba44e16b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -67,6 +67,8 @@ object PreferenceKeys { const val landscapeColumns = "pref_library_columns_landscape_key" + const val jumpToChapters = "jump_to_chapters" + const val updateOnlyNonCompleted = "pref_update_only_non_completed_key" const val autoUpdateTrack = "pref_auto_update_manga_sync_key" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 69ad48ceac..76d049c6a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -131,6 +131,8 @@ class PreferencesHelper(val context: Context) { fun landscapeColumns() = flowPrefs.getInt(Keys.landscapeColumns, 0) + fun jumpToChapters() = prefs.getBoolean(Keys.jumpToChapters, false) + fun updateOnlyNonCompleted() = prefs.getBoolean(Keys.updateOnlyNonCompleted, false) fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt index 5a2d1ab102..8bedcc991f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/MangaInfoChaptersController.kt @@ -72,6 +72,8 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) : private var chaptersHeaderAdapter: MangaChaptersHeaderAdapter? = null private var chaptersAdapter: ChaptersAdapter? = null + private var skippedInfoOnOpen: Boolean = false + /** * Action mode for multiple selection. */ @@ -305,9 +307,10 @@ class MangaInfoChaptersController(private val fromSource: Boolean = false) : // Update view. mangaInfoAdapter?.update(manga, source) - // Skips directly to chapters list by default if navigated to from the library - if (!fromSource) { + // Skips directly to chapters list if navigated to from the library + if (!fromSource && !skippedInfoOnOpen && preferences.jumpToChapters()) { (binding.recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(1, 0) + skippedInfoOnOpen = true } } else { // Initialize manga. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index a637d72a8c..b42ed0b0a0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -72,6 +72,11 @@ class SettingsLibraryController : SettingsController() { } .launchIn(scope) } + switchPreference { + key = Keys.jumpToChapters + titleRes = R.string.pref_jump_to_chapters + defaultValue = false + } } preferenceCategory { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2c86687e20..53a413ce7e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -172,6 +172,7 @@ Portrait Landscape Default + Jump to chapters on open Updates Library update frequency