mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 12:37:47 +01:00
Respect chapter list filtering when reading (closes #2810)
This commit is contained in:
parent
89df50da4e
commit
a3b660a2c9
5 changed files with 128 additions and 87 deletions
|
@ -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"
|
||||||
|
|
|
@ -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())
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -16,97 +16,111 @@ 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
|
||||||
|
|
||||||
intListPreference {
|
preferenceCategory {
|
||||||
key = Keys.defaultViewer
|
titleRes = R.string.pref_category_general
|
||||||
titleRes = R.string.pref_viewer_type
|
|
||||||
entriesRes = arrayOf(R.string.left_to_right_viewer, R.string.right_to_left_viewer,
|
intListPreference {
|
||||||
R.string.vertical_viewer, R.string.webtoon_viewer)
|
key = Keys.defaultViewer
|
||||||
entryValues = arrayOf("1", "2", "3", "4")
|
titleRes = R.string.pref_viewer_type
|
||||||
defaultValue = "1"
|
entriesRes = arrayOf(R.string.left_to_right_viewer, R.string.right_to_left_viewer,
|
||||||
summary = "%s"
|
R.string.vertical_viewer, R.string.webtoon_viewer)
|
||||||
}
|
entryValues = arrayOf("1", "2", "3", "4")
|
||||||
intListPreference {
|
defaultValue = "1"
|
||||||
key = Keys.imageScaleType
|
summary = "%s"
|
||||||
titleRes = R.string.pref_image_scale_type
|
}
|
||||||
entriesRes = arrayOf(R.string.scale_type_fit_screen, R.string.scale_type_stretch,
|
intListPreference {
|
||||||
R.string.scale_type_fit_width, R.string.scale_type_fit_height,
|
key = Keys.imageScaleType
|
||||||
R.string.scale_type_original_size, R.string.scale_type_smart_fit)
|
titleRes = R.string.pref_image_scale_type
|
||||||
entryValues = arrayOf("1", "2", "3", "4", "5", "6")
|
entriesRes = arrayOf(R.string.scale_type_fit_screen, R.string.scale_type_stretch,
|
||||||
defaultValue = "1"
|
R.string.scale_type_fit_width, R.string.scale_type_fit_height,
|
||||||
summary = "%s"
|
R.string.scale_type_original_size, R.string.scale_type_smart_fit)
|
||||||
}
|
entryValues = arrayOf("1", "2", "3", "4", "5", "6")
|
||||||
intListPreference {
|
defaultValue = "1"
|
||||||
key = Keys.zoomStart
|
summary = "%s"
|
||||||
titleRes = R.string.pref_zoom_start
|
}
|
||||||
entriesRes = arrayOf(R.string.zoom_start_automatic, R.string.zoom_start_left,
|
intListPreference {
|
||||||
R.string.zoom_start_right, R.string.zoom_start_center)
|
key = Keys.zoomStart
|
||||||
entryValues = arrayOf("1", "2", "3", "4")
|
titleRes = R.string.pref_zoom_start
|
||||||
defaultValue = "1"
|
entriesRes = arrayOf(R.string.zoom_start_automatic, R.string.zoom_start_left,
|
||||||
summary = "%s"
|
R.string.zoom_start_right, R.string.zoom_start_center)
|
||||||
}
|
entryValues = arrayOf("1", "2", "3", "4")
|
||||||
intListPreference {
|
defaultValue = "1"
|
||||||
key = Keys.rotation
|
summary = "%s"
|
||||||
titleRes = R.string.pref_rotation_type
|
}
|
||||||
entriesRes = arrayOf(R.string.rotation_free, R.string.rotation_lock,
|
intListPreference {
|
||||||
R.string.rotation_force_portrait, R.string.rotation_force_landscape)
|
key = Keys.rotation
|
||||||
entryValues = arrayOf("1", "2", "3", "4")
|
titleRes = R.string.pref_rotation_type
|
||||||
defaultValue = "1"
|
entriesRes = arrayOf(R.string.rotation_free, R.string.rotation_lock,
|
||||||
summary = "%s"
|
R.string.rotation_force_portrait, R.string.rotation_force_landscape)
|
||||||
}
|
entryValues = arrayOf("1", "2", "3", "4")
|
||||||
intListPreference {
|
defaultValue = "1"
|
||||||
key = Keys.readerTheme
|
summary = "%s"
|
||||||
titleRes = R.string.pref_reader_theme
|
}
|
||||||
entriesRes = arrayOf(R.string.white_background, R.string.black_background)
|
intListPreference {
|
||||||
entryValues = arrayOf("0", "1")
|
key = Keys.readerTheme
|
||||||
defaultValue = "0"
|
titleRes = R.string.pref_reader_theme
|
||||||
summary = "%s"
|
entriesRes = arrayOf(R.string.white_background, R.string.black_background)
|
||||||
}
|
entryValues = arrayOf("0", "1")
|
||||||
intListPreference {
|
defaultValue = "0"
|
||||||
key = Keys.doubleTapAnimationSpeed
|
summary = "%s"
|
||||||
titleRes = R.string.pref_double_tap_anim_speed
|
}
|
||||||
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_fast), context.getString(R.string.double_tap_anim_speed_normal))
|
intListPreference {
|
||||||
entryValues = arrayOf("1", "250", "500") // using a value of 0 breaks the image viewer, so min is 1
|
key = Keys.doubleTapAnimationSpeed
|
||||||
defaultValue = "500"
|
titleRes = R.string.pref_double_tap_anim_speed
|
||||||
summary = "%s"
|
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_fast), context.getString(R.string.double_tap_anim_speed_normal))
|
||||||
}
|
entryValues = arrayOf("1", "250", "500") // using a value of 0 breaks the image viewer, so min is 1
|
||||||
switchPreference {
|
defaultValue = "500"
|
||||||
key = Keys.skipRead
|
summary = "%s"
|
||||||
titleRes = R.string.pref_skip_read_chapters
|
}
|
||||||
defaultValue = false
|
|
||||||
}
|
|
||||||
switchPreference {
|
|
||||||
key = Keys.fullscreen
|
|
||||||
titleRes = R.string.pref_fullscreen
|
|
||||||
defaultValue = true
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.cutoutShort
|
key = Keys.fullscreen
|
||||||
titleRes = R.string.pref_cutout_short
|
titleRes = R.string.pref_fullscreen
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
}
|
}
|
||||||
}
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.keepScreenOn
|
key = Keys.cutoutShort
|
||||||
titleRes = R.string.pref_keep_screen_on
|
titleRes = R.string.pref_cutout_short
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
}
|
}
|
||||||
switchPreference {
|
}
|
||||||
key = Keys.showPageNumber
|
|
||||||
titleRes = R.string.pref_show_page_number
|
|
||||||
defaultValue = true
|
|
||||||
}
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.trueColor
|
key = Keys.keepScreenOn
|
||||||
titleRes = R.string.pref_true_color
|
titleRes = R.string.pref_keep_screen_on
|
||||||
defaultValue = false
|
defaultValue = true
|
||||||
|
}
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.showPageNumber
|
||||||
|
titleRes = R.string.pref_show_page_number
|
||||||
|
defaultValue = true
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.trueColor
|
||||||
|
titleRes = R.string.pref_true_color
|
||||||
|
defaultValue = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switchPreference {
|
|
||||||
key = Keys.alwaysShowChapterTransition
|
preferenceCategory {
|
||||||
titleRes = R.string.pref_always_show_chapter_transition
|
titleRes = R.string.pref_category_reading
|
||||||
defaultValue = true
|
|
||||||
|
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 {
|
||||||
|
key = Keys.alwaysShowChapterTransition
|
||||||
|
titleRes = R.string.pref_always_show_chapter_transition
|
||||||
|
defaultValue = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue