diff --git a/src/all/comickfun/assets/i18n/messages_en.properties b/src/all/comickfun/assets/i18n/messages_en.properties index 55487eaacd..ae8156297d 100644 --- a/src/all/comickfun/assets/i18n/messages_en.properties +++ b/src/all/comickfun/assets/i18n/messages_en.properties @@ -3,6 +3,9 @@ ignored_groups_summary=Chapters from these groups won't be shown.\nOne group nam include_tags_title=Include Tags include_tags_on=More specific, but might contain spoilers! include_tags_off=Only the broader genres +group_tags_title=Group Tags (fork must support grouping) +group_tags_on=Will prefix tags with their type +group_tags_off=List all tags together update_cover_title=Update Covers update_cover_on=Keep cover updated update_cover_off=Prefer first cover diff --git a/src/all/comickfun/assets/i18n/messages_pt_br.properties b/src/all/comickfun/assets/i18n/messages_pt_br.properties index 745ed5b153..31ac4d314b 100644 --- a/src/all/comickfun/assets/i18n/messages_pt_br.properties +++ b/src/all/comickfun/assets/i18n/messages_pt_br.properties @@ -3,6 +3,9 @@ ignored_groups_summary=Capítulos desses grupos não aparecerão.\nUm grupo por include_tags_title=Incluir Tags include_tags_on=Mais detalhadas, mas podem conter spoilers include_tags_off=Apenas os gêneros básicos +group_tags_title=Agrupar Tags (necessário fork compatível) +group_tags_on=Prefixar tags com o respectivo tipo +group_tags_off=Listar todas as tags juntas update_cover_title=Atualizar Capas update_cover_on=Manter capas atualizadas update_cover_off=Usar apenas a primeira capa diff --git a/src/all/comickfun/build.gradle b/src/all/comickfun/build.gradle index 1593f541ea..9c3455bd0c 100644 --- a/src/all/comickfun/build.gradle +++ b/src/all/comickfun/build.gradle @@ -2,7 +2,7 @@ ext { kmkVersionCode = 1 extName = 'Comick' extClass = '.ComickFactory' - extVersionCode = 48 + extVersionCode = 49 isNsfw = true } diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt index 54e34438b0..9e856de0d4 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Comick.kt @@ -97,6 +97,20 @@ abstract class Comick( } }.also(screen::addPreference) + SwitchPreferenceCompat(screen.context).apply { + key = GROUP_TAGS_PREF + title = intl["group_tags_title"] + summaryOn = intl["group_tags_on"] + summaryOff = intl["group_tags_off"] + setDefaultValue(GROUP_TAGS_DEFAULT) + + setOnPreferenceChangeListener { _, newValue -> + preferences.edit() + .putBoolean(GROUP_TAGS_PREF, newValue as Boolean) + .commit() + } + }.also(screen::addPreference) + SwitchPreferenceCompat(screen.context).apply { key = FIRST_COVER_PREF title = intl["update_cover_title"] @@ -149,6 +163,9 @@ abstract class Comick( private val SharedPreferences.includeMuTags: Boolean get() = getBoolean(INCLUDE_MU_TAGS_PREF, INCLUDE_MU_TAGS_DEFAULT) + private val SharedPreferences.groupTags: Boolean + get() = getBoolean(GROUP_TAGS_PREF, GROUP_TAGS_DEFAULT) + private val SharedPreferences.updateCover: Boolean get() = getBoolean(FIRST_COVER_PREF, FIRST_COVER_DEFAULT) @@ -393,11 +410,13 @@ abstract class Comick( includeMuTags = preferences.includeMuTags, scorePosition = preferences.scorePosition, covers = covers, + groupTags = preferences.groupTags, ) } return mangaData.toSManga( includeMuTags = preferences.includeMuTags, scorePosition = preferences.scorePosition, + groupTags = preferences.groupTags, ) } @@ -537,6 +556,8 @@ abstract class Comick( private const val IGNORED_GROUPS_PREF = "IgnoredGroups" private const val INCLUDE_MU_TAGS_PREF = "IncludeMangaUpdatesTags" const val INCLUDE_MU_TAGS_DEFAULT = false + private const val GROUP_TAGS_PREF = "GroupTags" + const val GROUP_TAGS_DEFAULT = false private const val MIGRATED_IGNORED_GROUPS = "MigratedIgnoredGroups" private const val FIRST_COVER_PREF = "DefaultCover" private const val FIRST_COVER_DEFAULT = true diff --git a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt index b80de715cf..bb0e60e757 100644 --- a/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt +++ b/src/all/comickfun/src/eu/kanade/tachiyomi/extension/all/comickfun/Dto.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.extension.all.comickfun +import eu.kanade.tachiyomi.extension.all.comickfun.Comick.Companion.GROUP_TAGS_DEFAULT import eu.kanade.tachiyomi.extension.all.comickfun.Comick.Companion.INCLUDE_MU_TAGS_DEFAULT import eu.kanade.tachiyomi.extension.all.comickfun.Comick.Companion.SCORE_POSITION_DEFAULT import eu.kanade.tachiyomi.source.model.SChapter @@ -29,13 +30,14 @@ class Manga( val comic: Comic, private val artists: List = emptyList(), private val authors: List = emptyList(), - private val genres: List = emptyList(), + private val genres: List = emptyList(), private val demographic: String? = null, ) { fun toSManga( includeMuTags: Boolean = INCLUDE_MU_TAGS_DEFAULT, scorePosition: String = SCORE_POSITION_DEFAULT, covers: List? = null, + groupTags: Boolean = GROUP_TAGS_DEFAULT, ) = SManga.create().apply { // appennding # at end as part of migration from slug to hid @@ -75,19 +77,23 @@ class Manga( artist = artists.joinToString { it.name.trim() } author = authors.joinToString { it.name.trim() } genre = buildList { - comic.origination?.let(::add) - demographic?.let { add(Name(it)) } - addAll(genres) - addAll(comic.mdGenres.mapNotNull { it.name }) + comic.origination?.let { add(Genre("Origination", it.name)) } + demographic?.let { add(Genre("Demographic", it)) } + addAll( + comic.mdGenres.mapNotNull { it.genre }.sortedBy { it.group } + .sortedBy { it.name }, + ) + addAll(genres.sortedBy { it.group }.sortedBy { it.name }) if (includeMuTags) { - comic.muGenres.categories.forEach { category -> - category?.category?.title?.let { add(Name(it)) } - } + addAll( + comic.muGenres.categories.mapNotNull { it?.category?.title }.sorted() + .map { Genre("Category", it) }, + ) } } .distinctBy { it.name } - .filter { it.name.isNotBlank() } - .joinToString { it.name.trim() } + .filterNot { it.name.isNullOrBlank() || it.group.isNullOrBlank() } + .joinToString { if (groupTags) "${it.group}:${it.name?.trim()}" else "${it.name?.trim()}" } } } @@ -128,7 +134,13 @@ class Comic( @Serializable class MdGenres( - @SerialName("md_genres") val name: Name? = null, + @SerialName("md_genres") val genre: Genre? = null, +) + +@Serializable +class Genre( + val group: String? = null, + val name: String? = null, ) @Serializable