[Comick] Preferences and Serialization fixes (#18835)
* Fix Tags preference not saving Address entries without tags raising a MissingFieldException * Simplify Boolean conversion Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> --------- Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
This commit is contained in:
parent
4d1d90a07b
commit
79d8a72d7b
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'Comick'
|
||||
pkgNameSuffix = 'all.comickfun'
|
||||
extClass = '.ComickFunFactory'
|
||||
extVersionCode = 37
|
||||
extVersionCode = 38
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,17 @@ abstract class ComickFun(
|
|||
title = "Include Tags"
|
||||
summaryOn = "More specific, but might contain spoilers!"
|
||||
summaryOff = "Only the broader genres"
|
||||
setDefaultValue(true)
|
||||
setDefaultValue(INCLUDE_MU_TAGS_DEFAULT)
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
preferences.edit()
|
||||
.putBoolean(INCLUDE_MU_TAGS_PREF, newValue as Boolean)
|
||||
.commit()
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
private val SharedPreferences.ignoredGroups
|
||||
private val SharedPreferences.ignoredGroups: Set<String>
|
||||
get() = getString(IGNORED_GROUPS_PREF, "")
|
||||
?.lowercase()
|
||||
?.split("\n")
|
||||
|
@ -88,8 +94,8 @@ abstract class ComickFun(
|
|||
.orEmpty()
|
||||
.toSet()
|
||||
|
||||
private val SharedPreferences.includeMuTags
|
||||
get() = getBoolean(INCLUDE_MU_TAGS_PREF, true)
|
||||
private val SharedPreferences.includeMuTags: Boolean
|
||||
get() = getBoolean(INCLUDE_MU_TAGS_PREF, INCLUDE_MU_TAGS_DEFAULT)
|
||||
|
||||
init {
|
||||
preferences.newLineIgnoredGroups()
|
||||
|
@ -384,6 +390,7 @@ abstract class ComickFun(
|
|||
const val SLUG_SEARCH_PREFIX = "id:"
|
||||
private const val IGNORED_GROUPS_PREF = "IgnoredGroups"
|
||||
private const val INCLUDE_MU_TAGS_PREF = "IncludeMangaUpdatesTags"
|
||||
private const val INCLUDE_MU_TAGS_DEFAULT = false
|
||||
private const val MIGRATED_IGNORED_GROUPS = "MigratedIgnoredGroups"
|
||||
private const val limit = 20
|
||||
val dateFormat by lazy {
|
||||
|
|
|
@ -56,7 +56,7 @@ data class Manga(
|
|||
addAll(comic.mdGenres.mapNotNull { it.name })
|
||||
if (includeMuTags) {
|
||||
comic.muGenres.categories.forEach { category ->
|
||||
category.category?.title?.let { add(Name(it)) }
|
||||
category?.category?.title?.let { add(Name(it)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ data class Comic(
|
|||
@SerialName("md_covers") val mdCovers: List<MDcovers> = emptyList(),
|
||||
@SerialName("cover_url") val cover: String? = null,
|
||||
@SerialName("md_comic_md_genres") val mdGenres: List<MdGenres>,
|
||||
@SerialName("mu_comics") val muGenres: MuComicCategories,
|
||||
@SerialName("mu_comics") val muGenres: MuComicCategories = MuComicCategories(emptyList()),
|
||||
) {
|
||||
val origination = when (country) {
|
||||
"jp" -> Name("Manga")
|
||||
|
@ -95,7 +95,7 @@ data class MdGenres(
|
|||
|
||||
@Serializable
|
||||
data class MuComicCategories(
|
||||
@SerialName("mu_comic_categories") val categories: List<MuCategories> = emptyList(),
|
||||
@SerialName("mu_comic_categories") val categories: List<MuCategories?> = emptyList(),
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
|
Loading…
Reference in New Issue