mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
add option to skip chapters marked read (#1791)
This commit is contained in:
parent
a62a7d5330
commit
77296348a0
@ -107,6 +107,8 @@ object PreferenceKeys {
|
||||
|
||||
const val defaultCategory = "default_category"
|
||||
|
||||
const val skipRead = "skip_read"
|
||||
|
||||
const val downloadBadge = "display_download_badge"
|
||||
|
||||
@Deprecated("Use the preferences of the source")
|
||||
|
@ -167,6 +167,8 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun defaultCategory() = prefs.getInt(Keys.defaultCategory, -1)
|
||||
|
||||
fun skipRead() = prefs.getBoolean(Keys.skipRead, false)
|
||||
|
||||
fun migrateFlags() = rxPrefs.getInteger("migrate_flags", Int.MAX_VALUE)
|
||||
|
||||
fun trustedSignatures() = rxPrefs.getStringSet("trusted_signatures", emptySet())
|
||||
|
@ -32,7 +32,7 @@ import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
@ -84,12 +84,25 @@ class ReaderPresenter(
|
||||
private val chapterList by lazy {
|
||||
val manga = manga!!
|
||||
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||
|
||||
val selectedChapter = dbChapters.find { it.id == chapterId }
|
||||
?: error("Requested chapter of id $chapterId not found in chapter list")
|
||||
|
||||
val chaptersForReader =
|
||||
if (preferences.skipRead()) {
|
||||
var list = dbChapters.filter { it -> !it.read }.toMutableList()
|
||||
val find = list.find { it.id == chapterId }
|
||||
if (find == null) {
|
||||
list.add(selectedChapter)
|
||||
}
|
||||
list
|
||||
} else {
|
||||
dbChapters
|
||||
}
|
||||
|
||||
when (manga.sorting) {
|
||||
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(dbChapters)
|
||||
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(dbChapters, selectedChapter)
|
||||
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
|
||||
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
|
||||
else -> error("Unknown sorting method")
|
||||
}.map(::ReaderChapter)
|
||||
}
|
||||
|
@ -63,6 +63,11 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = "500"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.skipRead
|
||||
titleRes = R.string.pref_skip_read_chapters
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.fullscreen
|
||||
titleRes = R.string.pref_fullscreen
|
||||
|
@ -178,6 +178,7 @@
|
||||
<string name="pref_custom_brightness">Use custom brightness</string>
|
||||
<string name="pref_custom_color_filter">Use custom color filter</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_reader_navigation">Navigation</string>
|
||||
<string name="pref_read_with_volume_keys">Volume keys</string>
|
||||
<string name="pref_read_with_volume_keys_inverted">Invert volume keys</string>
|
||||
|
Loading…
Reference in New Issue
Block a user