fix: correctly using language flag in source name to avoid it appears in folder name (#313)
* fix: correctly using language flag in source name to avoid it appears in folder name * using flag language in PreMigration list
This commit is contained in:
parent
9def7e7380
commit
ce727d6d42
5 changed files with 41 additions and 23 deletions
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.source
|
|||
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import tachiyomi.domain.source.model.StubSource
|
||||
import tachiyomi.presentation.core.icons.FlagEmoji
|
||||
import tachiyomi.source.local.isLocal
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
|
@ -9,10 +10,11 @@ import uy.kohesive.injekt.api.get
|
|||
fun Source.getNameForMangaInfo(
|
||||
// SY -->
|
||||
mergeSources: List<Source>?,
|
||||
enabledLanguages: List<String> = Injekt.get<SourcePreferences>().enabledLanguages().get()
|
||||
.filterNot { it in listOf("all", "other") },
|
||||
// SY <--
|
||||
): String {
|
||||
val preferences = Injekt.get<SourcePreferences>()
|
||||
val enabledLanguages = preferences.enabledLanguages().get()
|
||||
.filterNot { it in listOf("all", "other") }
|
||||
val hasOneActiveLanguages = enabledLanguages.size == 1
|
||||
val isInEnabledLanguages = lang in enabledLanguages
|
||||
return when {
|
||||
|
|
@ -23,11 +25,20 @@ fun Source.getNameForMangaInfo(
|
|||
hasOneActiveLanguages,
|
||||
)
|
||||
// SY <--
|
||||
// KMK -->
|
||||
this is StubSource -> toString()
|
||||
// KMK <--
|
||||
// For edge cases where user disables a source they got manga of in their library.
|
||||
hasOneActiveLanguages && !isInEnabledLanguages -> toString()
|
||||
hasOneActiveLanguages && !isInEnabledLanguages ->
|
||||
// KMK -->
|
||||
"$name (${FlagEmoji.getEmojiLangFlag(lang)})"
|
||||
// KMK <--
|
||||
// Hide the language tag when only one language is used.
|
||||
hasOneActiveLanguages && isInEnabledLanguages -> name
|
||||
else -> toString()
|
||||
else ->
|
||||
// KMK -->
|
||||
"$name (${FlagEmoji.getEmojiLangFlag(lang)})"
|
||||
// KMK <--
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,14 +50,28 @@ private fun getMergedSourcesString(
|
|||
): String {
|
||||
return if (onlyName) {
|
||||
mergeSources.joinToString { source ->
|
||||
if (source.lang !in enabledLangs) {
|
||||
source.toString()
|
||||
} else {
|
||||
source.name
|
||||
when {
|
||||
// KMK -->
|
||||
source is StubSource -> source.toString()
|
||||
// KMK <--
|
||||
source.lang !in enabledLangs ->
|
||||
// KMK -->
|
||||
"${source.name} (${FlagEmoji.getEmojiLangFlag(source.lang)})"
|
||||
// KMK <--
|
||||
else ->
|
||||
source.name
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mergeSources.joinToString()
|
||||
mergeSources.joinToString { source ->
|
||||
// KMK -->
|
||||
if (source is StubSource) {
|
||||
source.toString()
|
||||
} else {
|
||||
"${source.name} (${FlagEmoji.getEmojiLangFlag(source.lang)})"
|
||||
}
|
||||
// KMK <--
|
||||
}
|
||||
}
|
||||
}
|
||||
// SY <--
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import android.view.View
|
|||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.databinding.MigrationSourceItemBinding
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.getNameForMangaInfo
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import exh.util.capitalize
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
|
|
@ -18,9 +18,11 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) :
|
|||
}
|
||||
|
||||
fun bind(source: HttpSource, sourceEnabled: Boolean) {
|
||||
val isMultiLanguage = adapter.sourcePreferences.enabledLanguages().get().size > 1
|
||||
// Set capitalized title.
|
||||
val sourceName = if (isMultiLanguage) source.toString() else source.name.capitalize()
|
||||
val sourceName =
|
||||
// KMK -->
|
||||
source.getNameForMangaInfo(null)
|
||||
// KMK <--
|
||||
binding.title.text = sourceName
|
||||
// Update circle letter image.
|
||||
itemView.post {
|
||||
|
|
|
|||
|
|
@ -995,8 +995,6 @@ class MangaScreenModel(
|
|||
val isLocal = manga.isLocal()
|
||||
// SY -->
|
||||
val isExhManga = manga.isEhBasedManga()
|
||||
val enabledLanguages = sourcePreferences.enabledLanguages().get()
|
||||
.filterNot { it in listOf("all", "other") }
|
||||
// SY <--
|
||||
return map { chapter ->
|
||||
val activeDownload = if (isLocal) {
|
||||
|
|
@ -1034,7 +1032,7 @@ class MangaScreenModel(
|
|||
downloadProgress = activeDownload?.progress ?: 0,
|
||||
selected = chapter.id in selectedChapterIds,
|
||||
// SY -->
|
||||
sourceName = source?.getNameForMangaInfo(null, enabledLanguages = enabledLanguages),
|
||||
sourceName = source?.getNameForMangaInfo(null),
|
||||
showScanlator = !isExhManga,
|
||||
// SY <--
|
||||
)
|
||||
|
|
|
|||
|
|
@ -46,10 +46,6 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":presentation-core"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
compilerOptions.freeCompilerArgs.addAll(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import okhttp3.Request
|
|||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
import tachiyomi.core.common.util.lang.awaitSingle
|
||||
import tachiyomi.presentation.core.icons.FlagEmoji
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.net.URI
|
||||
|
|
@ -140,9 +139,7 @@ abstract class HttpSource : CatalogueSource {
|
|||
/**
|
||||
* Visible name of the source.
|
||||
*/
|
||||
override fun toString() = "$name (${
|
||||
FlagEmoji.getEmojiLangFlag(lang)
|
||||
})"
|
||||
override fun toString() = "$name (${lang.uppercase()})"
|
||||
|
||||
/**
|
||||
* Get a page with a list of manga.
|
||||
|
|
|
|||
Loading…
Reference in a new issue