Comick: add tag exclude to extension settings (#8504)
* feat(all/comick): Add tag exclude to extension settings * dont add empty tags
This commit is contained in:
parent
c9fc08676f
commit
b709f76b96
@ -1,5 +1,7 @@
|
||||
ignored_groups_title=Ignored Groups
|
||||
ignored_groups_summary=Chapters from these groups won't be shown.\nOne group name per line (case-insensitive)
|
||||
ignored_tags_title=Ignored Tags
|
||||
ignored_tags_summary=Manga with these tags won't show up when browsing.\nOne tag per line (case-insensitive)
|
||||
show_alternative_titles_title=Show Alternative Titles
|
||||
show_alternative_titles_on=Adds alternative titles to the description
|
||||
show_alternative_titles_off=Does not show alternative titles to the description
|
||||
|
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'Comick'
|
||||
extClass = '.ComickFactory'
|
||||
extVersionCode = 55
|
||||
extVersionCode = 56
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,12 @@ abstract class Comick(
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
|
||||
EditTextPreference(screen.context).apply {
|
||||
key = IGNORED_TAGS_PREF
|
||||
title = intl["ignored_tags_title"]
|
||||
summary = intl["ignored_tags_summary"]
|
||||
}.also(screen::addPreference)
|
||||
|
||||
SwitchPreferenceCompat(screen.context).apply {
|
||||
key = SHOW_ALTERNATIVE_TITLES_PREF
|
||||
title = intl["show_alternative_titles_title"]
|
||||
@ -184,6 +190,14 @@ abstract class Comick(
|
||||
.orEmpty()
|
||||
.toSet()
|
||||
|
||||
private val SharedPreferences.ignoredTags: String
|
||||
get() = getString(IGNORED_TAGS_PREF, "")
|
||||
?.split("\n")
|
||||
?.map(String::trim)
|
||||
?.filter(String::isNotEmpty)
|
||||
.orEmpty()
|
||||
.joinToString(",")
|
||||
|
||||
private val SharedPreferences.showAlternativeTitles: Boolean
|
||||
get() = getBoolean(SHOW_ALTERNATIVE_TITLES_PREF, SHOW_ALTERNATIVE_TITLES_DEFAULT)
|
||||
|
||||
@ -243,8 +257,13 @@ abstract class Comick(
|
||||
|
||||
/** Popular Manga **/
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
val url = "$apiUrl/v1.0/search?sort=follow&limit=$LIMIT&page=$page&tachiyomi=true"
|
||||
return GET(url, headers)
|
||||
return searchMangaRequest(
|
||||
page = page,
|
||||
query = "",
|
||||
filters = FilterList(
|
||||
SortFilter("follow"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun popularMangaParse(response: Response): MangasPage {
|
||||
@ -257,8 +276,13 @@ abstract class Comick(
|
||||
|
||||
/** Latest Manga **/
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
val url = "$apiUrl/v1.0/search?sort=uploaded&limit=$LIMIT&page=$page&tachiyomi=true"
|
||||
return GET(url, headers)
|
||||
return searchMangaRequest(
|
||||
page = page,
|
||||
query = "",
|
||||
filters = FilterList(
|
||||
SortFilter("uploaded"),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun latestUpdatesParse(response: Response) = popularMangaParse(response)
|
||||
@ -316,7 +340,7 @@ abstract class Comick(
|
||||
}
|
||||
|
||||
private fun addTagQueryParameters(builder: Builder, tags: String, parameterName: String) {
|
||||
tags.split(",").forEach {
|
||||
tags.split(",").filter(String::isNotEmpty).forEach {
|
||||
builder.addQueryParameter(
|
||||
parameterName,
|
||||
it.trim().lowercase().replace(SPACE_AND_SLASH_REGEX, "-")
|
||||
@ -412,6 +436,7 @@ abstract class Comick(
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
addTagQueryParameters(this, preferences.ignoredTags, "excluded-tags")
|
||||
addQueryParameter("tachiyomi", "true")
|
||||
addQueryParameter("limit", "$LIMIT")
|
||||
addQueryParameter("page", "$page")
|
||||
@ -587,6 +612,7 @@ abstract class Comick(
|
||||
const val SLUG_SEARCH_PREFIX = "id:"
|
||||
private val SPACE_AND_SLASH_REGEX = Regex("[ /]")
|
||||
private const val IGNORED_GROUPS_PREF = "IgnoredGroups"
|
||||
private const val IGNORED_TAGS_PREF = "IgnoredTags"
|
||||
private const val SHOW_ALTERNATIVE_TITLES_PREF = "ShowAlternativeTitles"
|
||||
const val SHOW_ALTERNATIVE_TITLES_DEFAULT = false
|
||||
private const val INCLUDE_MU_TAGS_PREF = "IncludeMangaUpdatesTags"
|
||||
|
@ -9,7 +9,7 @@ fun getFilters(): FilterList {
|
||||
GenreFilter("Genre", getGenresList),
|
||||
DemographicFilter("Demographic", getDemographicList),
|
||||
TypeFilter("Type", getTypeList),
|
||||
SortFilter("Sort", getSortsList),
|
||||
SortFilter(),
|
||||
StatusFilter("Status", getStatusList),
|
||||
ContentRatingFilter("Content Rating", getContentRatingList),
|
||||
CompletedFilter("Completely Scanlated?"),
|
||||
@ -50,8 +50,8 @@ internal class FromYearFilter(name: String) : TextFilter(name)
|
||||
|
||||
internal class ToYearFilter(name: String) : TextFilter(name)
|
||||
|
||||
internal class SortFilter(name: String, sortList: List<Pair<String, String>>, state: Int = 0) :
|
||||
SelectFilter(name, sortList, state)
|
||||
internal class SortFilter(defaultValue: String? = null, state: Int = 0) :
|
||||
SelectFilter("Sort", getSortsList, state, defaultValue)
|
||||
|
||||
internal class StatusFilter(name: String, statusList: List<Pair<String, String>>, state: Int = 0) :
|
||||
SelectFilter(name, statusList, state)
|
||||
@ -66,8 +66,8 @@ internal open class TextFilter(name: String) : Filter.Text(name)
|
||||
|
||||
internal open class CheckBoxFilter(name: String, val value: String = "") : Filter.CheckBox(name)
|
||||
|
||||
internal open class SelectFilter(name: String, private val vals: List<Pair<String, String>>, state: Int = 0) :
|
||||
Filter.Select<String>(name, vals.map { it.first }.toTypedArray(), state) {
|
||||
internal open class SelectFilter(name: String, private val vals: List<Pair<String, String>>, state: Int = 0, defaultValue: String? = null) :
|
||||
Filter.Select<String>(name, vals.map { it.first }.toTypedArray(), vals.indexOfFirst { it.second == defaultValue }.takeIf { it != -1 } ?: state) {
|
||||
fun getValue() = vals[state].second
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user