Respect chapter list filtering when reading (closes #2810)

This commit is contained in:
arkon 2020-04-01 22:37:28 -04:00
parent 89df50da4e
commit a3b660a2c9
5 changed files with 128 additions and 87 deletions

View File

@ -135,6 +135,8 @@ object PreferenceKeys {
const val skipRead = "skip_read" const val skipRead = "skip_read"
const val skipFiltered = "skip_filtered"
const val downloadBadge = "display_download_badge" const val downloadBadge = "display_download_badge"
const val alwaysShowChapterTransition = "always_show_chapter_transition" const val alwaysShowChapterTransition = "always_show_chapter_transition"

View File

@ -208,6 +208,8 @@ class PreferencesHelper(val context: Context) {
fun skipRead() = prefs.getBoolean(Keys.skipRead, false) fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, false)
fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE) fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE)
fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet()) fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet())

View File

@ -91,8 +91,27 @@ class ReaderPresenter(
?: error("Requested chapter of id $chapterId not found in chapter list") ?: error("Requested chapter of id $chapterId not found in chapter list")
val chaptersForReader = val chaptersForReader =
if (preferences.skipRead()) { if (preferences.skipRead() || preferences.skipFiltered()) {
val list = dbChapters.filter { !it.read }.toMutableList() val list = dbChapters
.filter {
if (preferences.skipRead() && it.read) {
return@filter false
} else if (preferences.skipFiltered()) {
if (
(manga.readFilter == Manga.SHOW_READ && !it.read) ||
(manga.readFilter == Manga.SHOW_UNREAD && it.read) ||
(manga.downloadedFilter == Manga.SHOW_DOWNLOADED &&
!downloadManager.isChapterDownloaded(it, manga)) ||
(manga.bookmarkedFilter == Manga.SHOW_BOOKMARKED && !it.bookmark)
) {
return@filter false
}
}
true
}
.toMutableList()
val find = list.find { it.id == chapterId } val find = list.find { it.id == chapterId }
if (find == null) { if (find == null) {
list.add(selectedChapter) list.add(selectedChapter)

View File

@ -16,6 +16,9 @@ class SettingsReaderController : SettingsController() {
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) { override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
titleRes = R.string.pref_category_reader titleRes = R.string.pref_category_reader
preferenceCategory {
titleRes = R.string.pref_category_general
intListPreference { intListPreference {
key = Keys.defaultViewer key = Keys.defaultViewer
titleRes = R.string.pref_viewer_type titleRes = R.string.pref_viewer_type
@ -69,11 +72,6 @@ class SettingsReaderController : SettingsController() {
defaultValue = "500" defaultValue = "500"
summary = "%s" summary = "%s"
} }
switchPreference {
key = Keys.skipRead
titleRes = R.string.pref_skip_read_chapters
defaultValue = false
}
switchPreference { switchPreference {
key = Keys.fullscreen key = Keys.fullscreen
titleRes = R.string.pref_fullscreen titleRes = R.string.pref_fullscreen
@ -103,11 +101,27 @@ class SettingsReaderController : SettingsController() {
defaultValue = false defaultValue = false
} }
} }
}
preferenceCategory {
titleRes = R.string.pref_category_reading
switchPreference {
key = Keys.skipRead
titleRes = R.string.pref_skip_read_chapters
defaultValue = false
}
switchPreference {
key = Keys.skipFiltered
titleRes = R.string.pref_skip_filtered_chapters
defaultValue = false
}
switchPreference { switchPreference {
key = Keys.alwaysShowChapterTransition key = Keys.alwaysShowChapterTransition
titleRes = R.string.pref_always_show_chapter_transition titleRes = R.string.pref_always_show_chapter_transition
defaultValue = true defaultValue = true
} }
}
preferenceCategory { preferenceCategory {
titleRes = R.string.pager_viewer titleRes = R.string.pager_viewer
@ -123,6 +137,7 @@ class SettingsReaderController : SettingsController() {
defaultValue = false defaultValue = false
} }
} }
preferenceCategory { preferenceCategory {
titleRes = R.string.webtoon_viewer titleRes = R.string.webtoon_viewer
@ -137,6 +152,7 @@ class SettingsReaderController : SettingsController() {
defaultValue = false defaultValue = false
} }
} }
preferenceCategory { preferenceCategory {
titleRes = R.string.pref_reader_navigation titleRes = R.string.pref_reader_navigation

View File

@ -234,6 +234,7 @@
<string name="filter_mode_darken">Burn / Darken</string> <string name="filter_mode_darken">Burn / Darken</string>
<string name="pref_keep_screen_on">Keep screen on</string> <string name="pref_keep_screen_on">Keep screen on</string>
<string name="pref_skip_read_chapters">Skip chapters marked read</string> <string name="pref_skip_read_chapters">Skip chapters marked read</string>
<string name="pref_skip_filtered_chapters">Skip filtered chapters</string>
<string name="pref_reader_navigation">Navigation</string> <string name="pref_reader_navigation">Navigation</string>
<string name="pref_read_with_volume_keys">Volume keys</string> <string name="pref_read_with_volume_keys">Volume keys</string>
<string name="pref_read_with_volume_keys_inverted">Invert volume keys</string> <string name="pref_read_with_volume_keys_inverted">Invert volume keys</string>
@ -275,6 +276,7 @@
<string name="color_filter_b_value">B</string> <string name="color_filter_b_value">B</string>
<string name="color_filter_a_value">A</string> <string name="color_filter_a_value">A</string>
<string name="pref_always_show_chapter_transition">Always show chapter transition</string> <string name="pref_always_show_chapter_transition">Always show chapter transition</string>
<string name="pref_category_reading">Reading</string>
<!-- Downloads section --> <!-- Downloads section -->
<string name="pref_download_directory">Download location</string> <string name="pref_download_directory">Download location</string>