diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index b2a3bde3dfed..ae3e2f60f10b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -217,7 +217,10 @@ class PreferencesHelper(val context: Context) { fun browseAsList() = flowPrefs.getBoolean(Keys.catalogueAsList, false) - fun enabledLanguages() = flowPrefs.getStringSet(Keys.enabledLanguages, setOf("all", "en", Locale.getDefault().language)) + fun enabledLanguages() = flowPrefs.getStringSet( + Keys.enabledLanguages, + setOfNotNull("all", "en", Locale.getDefault().language.takeIf { !it.startsWith("en") }), + ) fun sourceSorting() = flowPrefs.getInt(Keys.sourcesSort, 0) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 6b78e2fc6c3b..0c08c4164465 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -88,16 +88,17 @@ interface Source { return fetchPageList(chapter).awaitSingle() } - fun includeLangInName(isMultiLingual: Boolean, extensionManager: ExtensionManager? = null): Boolean { + fun includeLangInName(enabledLanguages: Set, extensionManager: ExtensionManager? = null): Boolean { val httpSource = this as? HttpSource ?: return true val extManager = extensionManager ?: Injekt.get() val allExt = httpSource.getExtension(extManager)?.lang == "all" val onlyAll = httpSource.extOnlyHasAllLanguage(extManager) + val isMultiLingual = enabledLanguages.filterNot { it == "all" }.size > 1 return (isMultiLingual && allExt) || (lang == "all" && !onlyAll) } - fun nameBasedOnEnabledLanguages(isMultiLingual: Boolean, extensionManager: ExtensionManager? = null): String { - return if (includeLangInName(isMultiLingual, extensionManager)) toString() else name + fun nameBasedOnEnabledLanguages(enabledLanguages: Set, extensionManager: ExtensionManager? = null): String { + return if (includeLangInName(enabledLanguages, extensionManager)) toString() else name } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index 847b14ba2d43..d7086536e836 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -433,10 +433,9 @@ class MangaHeaderHolder( ) with(binding.mangaSource) { val enabledLanguages = presenter.preferences.enabledLanguages().get() - .filterNot { it == "all" } text = buildSpannedString { - append(presenter.source.nameBasedOnEnabledLanguages(enabledLanguages.size > 1)) + append(presenter.source.nameBasedOnEnabledLanguages(enabledLanguages)) if (presenter.source is SourceManager.StubSource && presenter.source.name != presenter.source.id.toString() ) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceAdapter.kt index 1945621d5315..19fefc96f3ff 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceAdapter.kt @@ -19,8 +19,7 @@ class MigrationSourceAdapter( ) { val extensionManager: ExtensionManager = Injekt.get() - val isMultiLingual = - Injekt.get().enabledLanguages().get().filterNot { it == "all" }.size > 1 + val enabledLanguages = Injekt.get().enabledLanguages().get() override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceHolder.kt index c47d28c6dbaf..e48bdbc27099 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationSourceHolder.kt @@ -16,7 +16,7 @@ class MigrationSourceHolder(view: View, val adapter: MigrationSourceAdapter) : } fun bind(source: HttpSource, sourceEnabled: Boolean) { - binding.title.text = source.nameBasedOnEnabledLanguages(adapter.isMultiLingual, adapter.extensionManager) + binding.title.text = source.nameBasedOnEnabledLanguages(adapter.enabledLanguages, adapter.extensionManager) // Update circle letter image. itemView.post { val icon = source.icon() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsController.kt index 57c4ffcf7e7d..2cd84e28c597 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsController.kt @@ -377,7 +377,7 @@ class StatsDetailsController : when (it) { is Category -> it.name is Source -> it.nameBasedOnEnabledLanguages( - presenter.isMultiLingual, + presenter.enabledLanguages, presenter.extensionManager, ) else -> it.toString() @@ -519,7 +519,7 @@ class StatsDetailsController : when (val firstValue = selectedValues.first()) { is Category -> firstValue.name is Source -> firstValue.nameBasedOnEnabledLanguages( - presenter.isMultiLingual, + presenter.enabledLanguages, presenter.extensionManager, ) else -> firstValue.toString() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsPresenter.kt index 56001ff24744..e721dd534532 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/stats/details/StatsDetailsPresenter.kt @@ -52,7 +52,7 @@ class StatsDetailsPresenter( private var mangasDistinct = libraryMangas.distinct() val sources = getEnabledSources() val extensionManager by injectLazy() - val isMultiLingual = prefs.enabledLanguages().get().filterNot { it == "all" }.size > 1 + val enabledLanguages = prefs.enabledLanguages().get() var selectedStat: Stats? = null var selectedSeriesType = mutableSetOf() @@ -287,7 +287,7 @@ class StatsDetailsPresenter( meanScore = mangaList.getMeanScoreRounded(), chaptersRead = mangaList.sumOf { it.read }, totalChapters = mangaList.sumOf { it.totalChapters }, - label = source.nameBasedOnEnabledLanguages(isMultiLingual, extensionManager), + label = source.nameBasedOnEnabledLanguages(enabledLanguages, extensionManager), icon = source.icon(), readDuration = mangaList.getReadDuration(), id = sourceId, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceAdapter.kt index 6810fb8de6c4..098fa60d6ae0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceAdapter.kt @@ -20,8 +20,7 @@ class SourceAdapter(val controller: BrowseController) : val sourceListener: SourceListener = controller - val isMultiLingual = - Injekt.get().enabledLanguages().get().filterNot { it == "all" }.size > 1 + val enabledLanguages = Injekt.get().enabledLanguages().get() val extensionManager = controller.presenter.extensionManager diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceHolder.kt index acf149365f7a..8571e675a946 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/SourceHolder.kt @@ -32,7 +32,7 @@ class SourceHolder(view: View, val adapter: SourceAdapter) : val underPinnedSection = item.header?.code?.equals(SourcePresenter.PINNED_KEY) ?: false val underLastUsedSection = item.header?.code?.equals(SourcePresenter.LAST_USED_KEY) ?: false val isPinned = item.isPinned ?: underPinnedSection - val showLanguage = source.includeLangInName(adapter.isMultiLingual, adapter.extensionManager) + val showLanguage = source.includeLangInName(adapter.enabledLanguages, adapter.extensionManager) val sourceName = if (showLanguage && (underPinnedSection || underLastUsedSection)) source.toString() else source.name binding.title.text = sourceName