DMZJ: default to single genre filter (#14552)

This commit is contained in:
stevenyomi 2022-12-15 19:47:09 +08:00 committed by GitHub
parent 26beb51f44
commit 0c132a3a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'DMZJ'
pkgNameSuffix = 'zh.dmzj'
extClass = '.Dmzj'
extVersionCode = 34
extVersionCode = 35
}
apply from: "$rootDir/common.gradle"

View File

@ -116,7 +116,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
val request = GET(ApiSearch.textSearchUrl(query), headers)
Observable.fromCallable {
// this API fails randomly, and might return empty list
repeat(8) {
repeat(5) {
val result = ApiSearch.parsePage(client.newCall(request).execute())
if (result.mangas.isNotEmpty()) return@fromCallable result
}
@ -221,7 +221,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
override fun imageUrlParse(response: Response) =
throw UnsupportedOperationException("This method should not be called!")
override fun getFilterList() = getFilterListInternal()
override fun getFilterList() = getFilterListInternal(preferences.isMultiGenreFilter)
override fun setupPreferenceScreen(screen: PreferenceScreen) {
getPreferencesInternal(screen.context, preferences).forEach(screen::addPreference)

View File

@ -3,11 +3,11 @@ package eu.kanade.tachiyomi.extension.zh.dmzj
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
fun getFilterListInternal() = FilterList(
fun getFilterListInternal(isMultiGenre: Boolean) = FilterList(
RankingGroup(),
Filter.Separator(),
Filter.Header("分类筛选(查看排行榜、搜索文本时无效)"),
GenreGroup(),
if (isMultiGenre) GenreGroup() else GenreSelectFilter(),
StatusFilter(),
ReaderFilter(),
RegionFilter(),
@ -77,6 +77,8 @@ fun parseFilters(filters: FilterList): String {
private interface TagFilter : UriPartFilter
private class GenreSelectFilter : TagFilter, SelectFilter("题材", genres)
private class GenreGroup : TagFilter, Filter.Group<GenreFilter>(
"题材(作品需包含勾选的所有项目)",
genres.drop(1).map { GenreFilter(it.first, it.second) }

View File

@ -28,6 +28,13 @@ fun getPreferencesInternal(context: Context, preferences: SharedPreferences) = a
setDefaultValue(false)
},
SwitchPreferenceCompat(context).apply {
key = MULTI_GENRE_FILTER_PREF
title = "分类筛选时允许勾选多个题材"
summary = "可以更精细地筛选出同时符合多个题材的作品。"
setDefaultValue(false)
},
MultiSelectListPreference(context).setupIdList(
LICENSED_LIST_PREF,
"特殊漫画 ID 列表 (1)",
@ -45,6 +52,8 @@ val SharedPreferences.imageQuality get() = getString(IMAGE_QUALITY_PREF, AUTO_RE
val SharedPreferences.showChapterComments get() = getBoolean(CHAPTER_COMMENTS_PREF, false)
val SharedPreferences.isMultiGenreFilter get() = getBoolean(MULTI_GENRE_FILTER_PREF, false)
val SharedPreferences.licensedList: Set<String> get() = getStringSet(LICENSED_LIST_PREF, emptySet())!!
val SharedPreferences.hiddenList: Set<String> get() = getStringSet(HIDDEN_LIST_PREF, emptySet())!!
@ -82,6 +91,7 @@ const val ORIGINAL_RES = "ORIG_RES_ONLY"
const val LOW_RES = "LOW_RES_ONLY"
private const val CHAPTER_COMMENTS_PREF = "chapterComments"
private const val MULTI_GENRE_FILTER_PREF = "multiGenreFilter"
private const val LICENSED_LIST_PREF = "licensedList"
private const val HIDDEN_LIST_PREF = "hiddenList"