mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add Reader Setting to Skip Dupe Chapters
Add reader setting to filter dupe chapters with same scanlator priority. Slightly changed to check if any of the current chapter's scanlators are in another chapter (since scan groups like to collab) Co-Authored-By: MCAxiaz <mcaxiaz@gmail.com>
This commit is contained in:
parent
a64753b4ac
commit
d75a2318a9
5 changed files with 27 additions and 3 deletions
|
@ -330,6 +330,8 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
fun skipFiltered() = prefs.getBoolean(Keys.skipFiltered, true)
|
||||||
|
|
||||||
|
fun skipDupe() = flowPrefs.getBoolean("skip_dupe", false)
|
||||||
|
|
||||||
fun useBiometrics() = flowPrefs.getBoolean(Keys.useBiometrics, false)
|
fun useBiometrics() = flowPrefs.getBoolean(Keys.useBiometrics, false)
|
||||||
|
|
||||||
fun lockAfter() = flowPrefs.getInt(Keys.lockAfter, 0)
|
fun lockAfter() = flowPrefs.getInt(Keys.lockAfter, 0)
|
||||||
|
|
|
@ -140,6 +140,10 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.skip_filtered_chapters
|
titleRes = R.string.skip_filtered_chapters
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
}
|
}
|
||||||
|
switchPreference {
|
||||||
|
bindTo(preferences.skipDupe())
|
||||||
|
titleRes = R.string.skip_dupe_chapters
|
||||||
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.alwaysShowChapterTransition
|
key = Keys.alwaysShowChapterTransition
|
||||||
titleRes = R.string.always_show_chapter_transition
|
titleRes = R.string.always_show_chapter_transition
|
||||||
|
|
|
@ -41,8 +41,8 @@ class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downl
|
||||||
/** filter chapters for the reader */
|
/** filter chapters for the reader */
|
||||||
fun <T : Chapter> filterChaptersForReader(chapters: List<T>, manga: Manga, selectedChapter: T? = null): List<T> {
|
fun <T : Chapter> filterChaptersForReader(chapters: List<T>, manga: Manga, selectedChapter: T? = null): List<T> {
|
||||||
var filteredChapters = filterChaptersByScanlators(chapters, manga)
|
var filteredChapters = filterChaptersByScanlators(chapters, manga)
|
||||||
// if neither preference is enabled don't even filter
|
// if filter prefs aren't enabled don't even filter
|
||||||
if (!preferences.skipRead() && !preferences.skipFiltered()) {
|
if (!preferences.skipRead() && !preferences.skipFiltered() && !preferences.skipDupe().get()) {
|
||||||
return filteredChapters
|
return filteredChapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,23 @@ class ChapterFilter(val preferences: PreferencesHelper = Injekt.get(), val downl
|
||||||
if (preferences.skipFiltered()) {
|
if (preferences.skipFiltered()) {
|
||||||
filteredChapters = filterChapters(filteredChapters, manga)
|
filteredChapters = filterChapters(filteredChapters, manga)
|
||||||
}
|
}
|
||||||
|
if (preferences.skipDupe().get()) {
|
||||||
|
filteredChapters = filteredChapters.groupBy { it.chapter_number }
|
||||||
|
.map { (_, chapters) ->
|
||||||
|
chapters.find { it.id == selectedChapter?.id }
|
||||||
|
?: chapters.find { it.scanlator == selectedChapter?.scanlator }
|
||||||
|
?: chapters.find {
|
||||||
|
val mainScans = it.scanlator?.split(ChapterUtil.scanlatorSeparator)
|
||||||
|
?: return@find false
|
||||||
|
val currScans =
|
||||||
|
selectedChapter?.scanlator?.split(ChapterUtil.scanlatorSeparator)
|
||||||
|
?: return@find false
|
||||||
|
mainScans.any { scanlator -> currScans.contains(scanlator) }
|
||||||
|
}
|
||||||
|
?: chapters.first()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add the selected chapter to the list in case it was filtered out
|
// add the selected chapter to the list in case it was filtered out
|
||||||
if (selectedChapter?.id != null) {
|
if (selectedChapter?.id != null) {
|
||||||
val find = filteredChapters.find { it.id == selectedChapter.id }
|
val find = filteredChapters.find { it.id == selectedChapter.id }
|
||||||
|
|
|
@ -143,7 +143,7 @@ class ChapterUtil {
|
||||||
return chapters.size > 20
|
return chapters.size > 20
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val scanlatorSeparator = " & "
|
const val scanlatorSeparator = " & "
|
||||||
|
|
||||||
fun getScanlators(scanlators: String?): List<String> {
|
fun getScanlators(scanlators: String?): List<String> {
|
||||||
if (scanlators.isNullOrBlank()) return emptyList()
|
if (scanlators.isNullOrBlank()) return emptyList()
|
||||||
|
|
|
@ -426,6 +426,7 @@
|
||||||
<string name="keep_screen_on">Keep screen on</string>
|
<string name="keep_screen_on">Keep screen on</string>
|
||||||
<string name="skip_read_chapters">Skip chapters marked read</string>
|
<string name="skip_read_chapters">Skip chapters marked read</string>
|
||||||
<string name="skip_filtered_chapters">Skip filtered chapters</string>
|
<string name="skip_filtered_chapters">Skip filtered chapters</string>
|
||||||
|
<string name="skip_dupe_chapters">Skip duplicate chapters</string>
|
||||||
<string name="navigation">Navigation</string>
|
<string name="navigation">Navigation</string>
|
||||||
<string name="volume_keys">Volume keys</string>
|
<string name="volume_keys">Volume keys</string>
|
||||||
<string name="invert_volume_keys">Invert volume keys</string>
|
<string name="invert_volume_keys">Invert volume keys</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue