[Comick] Make the group filtering case-insensitive (#18196)
Make the group filtering case-insensitive * Remove redundant RegEx escaping * Reformat code
This commit is contained in:
parent
f8373acc61
commit
ba7391e17a
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Comick'
|
extName = 'Comick'
|
||||||
pkgNameSuffix = 'all.comickfun'
|
pkgNameSuffix = 'all.comickfun'
|
||||||
extClass = '.ComickFunFactory'
|
extClass = '.ComickFunFactory'
|
||||||
extVersionCode = 35
|
extVersionCode = 36
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,8 @@ abstract class ComickFun(
|
|||||||
EditTextPreference(screen.context).apply {
|
EditTextPreference(screen.context).apply {
|
||||||
key = IGNORED_GROUPS_PREF
|
key = IGNORED_GROUPS_PREF
|
||||||
title = "Ignored Groups"
|
title = "Ignored Groups"
|
||||||
summary = "Chapters from these groups won't be shown. Comma-separated list of group names"
|
summary =
|
||||||
|
"Chapters from these groups won't be shown.\nComma-separated list of group names (case-insensitive)"
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
preferences.edit()
|
preferences.edit()
|
||||||
@ -70,6 +71,7 @@ abstract class ComickFun(
|
|||||||
|
|
||||||
private val SharedPreferences.ignoredGroups
|
private val SharedPreferences.ignoredGroups
|
||||||
get() = getString(IGNORED_GROUPS_PREF, "")
|
get() = getString(IGNORED_GROUPS_PREF, "")
|
||||||
|
?.lowercase()
|
||||||
?.split(",")
|
?.split(",")
|
||||||
?.map(String::trim)
|
?.map(String::trim)
|
||||||
?.filter(String::isNotEmpty)
|
?.filter(String::isNotEmpty)
|
||||||
@ -110,7 +112,11 @@ abstract class ComickFun(
|
|||||||
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
||||||
|
|
||||||
/** Manga Search **/
|
/** Manga Search **/
|
||||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
override fun fetchSearchManga(
|
||||||
|
page: Int,
|
||||||
|
query: String,
|
||||||
|
filters: FilterList,
|
||||||
|
): Observable<MangasPage> {
|
||||||
return if (query.startsWith(SLUG_SEARCH_PREFIX)) {
|
return if (query.startsWith(SLUG_SEARCH_PREFIX)) {
|
||||||
// url deep link
|
// url deep link
|
||||||
val slugOrHid = query.substringAfter(SLUG_SEARCH_PREFIX)
|
val slugOrHid = query.substringAfter(SLUG_SEARCH_PREFIX)
|
||||||
@ -166,6 +172,7 @@ abstract class ComickFun(
|
|||||||
addQueryParameter("completed", "true")
|
addQueryParameter("completed", "true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is GenreFilter -> {
|
is GenreFilter -> {
|
||||||
it.state.filter { it.isIncluded() }.forEach {
|
it.state.filter { it.isIncluded() }.forEach {
|
||||||
addQueryParameter("genres", it.value)
|
addQueryParameter("genres", it.value)
|
||||||
@ -175,44 +182,53 @@ abstract class ComickFun(
|
|||||||
addQueryParameter("excludes", it.value)
|
addQueryParameter("excludes", it.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is DemographicFilter -> {
|
is DemographicFilter -> {
|
||||||
it.state.filter { it.isIncluded() }.forEach {
|
it.state.filter { it.isIncluded() }.forEach {
|
||||||
addQueryParameter("demographic", it.value)
|
addQueryParameter("demographic", it.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is TypeFilter -> {
|
is TypeFilter -> {
|
||||||
it.state.filter { it.state }.forEach {
|
it.state.filter { it.state }.forEach {
|
||||||
addQueryParameter("country", it.value)
|
addQueryParameter("country", it.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is SortFilter -> {
|
is SortFilter -> {
|
||||||
addQueryParameter("sort", it.getValue())
|
addQueryParameter("sort", it.getValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
is StatusFilter -> {
|
is StatusFilter -> {
|
||||||
if (it.state > 0) {
|
if (it.state > 0) {
|
||||||
addQueryParameter("status", it.getValue())
|
addQueryParameter("status", it.getValue())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is CreatedAtFilter -> {
|
is CreatedAtFilter -> {
|
||||||
if (it.state > 0) {
|
if (it.state > 0) {
|
||||||
addQueryParameter("time", it.getValue())
|
addQueryParameter("time", it.getValue())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is MinimumFilter -> {
|
is MinimumFilter -> {
|
||||||
if (it.state.isNotEmpty()) {
|
if (it.state.isNotEmpty()) {
|
||||||
addQueryParameter("minimum", it.state)
|
addQueryParameter("minimum", it.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is FromYearFilter -> {
|
is FromYearFilter -> {
|
||||||
if (it.state.isNotEmpty()) {
|
if (it.state.isNotEmpty()) {
|
||||||
addQueryParameter("from", it.state)
|
addQueryParameter("from", it.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is ToYearFilter -> {
|
is ToYearFilter -> {
|
||||||
if (it.state.isNotEmpty()) {
|
if (it.state.isNotEmpty()) {
|
||||||
addQueryParameter("to", it.state)
|
addQueryParameter("to", it.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is TagFilter -> {
|
is TagFilter -> {
|
||||||
if (it.state.isNotEmpty()) {
|
if (it.state.isNotEmpty()) {
|
||||||
it.state.split(",").forEach {
|
it.state.split(",").forEach {
|
||||||
@ -220,6 +236,7 @@ abstract class ComickFun(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +314,9 @@ abstract class ComickFun(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return chapterListResponse.chapters
|
return chapterListResponse.chapters
|
||||||
.filter { it.groups.intersect(preferences.ignoredGroups).isEmpty() }
|
.filter {
|
||||||
|
it.groups.map { g -> g.lowercase() }.intersect(preferences.ignoredGroups).isEmpty()
|
||||||
|
}
|
||||||
.map { it.toSChapter(mangaUrl) }
|
.map { it.toSChapter(mangaUrl) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,8 +356,8 @@ abstract class ComickFun(
|
|||||||
timeZone = TimeZone.getTimeZone("UTC")
|
timeZone = TimeZone.getTimeZone("UTC")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val markdownLinksRegex = "\\[([^]]+)\\]\\(([^)]+)\\)".toRegex()
|
val markdownLinksRegex = "\\[([^]]+)]\\(([^)]+)\\)".toRegex()
|
||||||
val markdownItalicBoldRegex = "\\*+\\s*([^\\*]*)\\s*\\*+".toRegex()
|
val markdownItalicBoldRegex = "\\*+\\s*([^*]*)\\s*\\*+".toRegex()
|
||||||
val markdownItalicRegex = "_+\\s*([^_]*)\\s*_+".toRegex()
|
val markdownItalicRegex = "_+\\s*([^_]*)\\s*_+".toRegex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user