From ff5f13eafedcb48558ced648bcf5506e4a1c2e46 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 15 Jun 2020 22:45:28 -0400 Subject: [PATCH] Remove categories for multi language "single" sources --- .../details/ExtensionDetailsController.kt | 24 ++++++++++++------- app/src/main/res/values/strings.xml | 1 - 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index 79602d04a9..51f53f7c05 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -114,17 +114,14 @@ class ExtensionDetailsController(bundle: Bundle? = null) : preferenceScreen = screen val isMultiSource = extension.sources.size > 1 + val isMultiLangSingleSource = isMultiSource && extension.sources.map { it.name }.distinct().size == 1 with(screen) { extension.sources .groupBy { (it as CatalogueSource).lang } .toSortedMap(compareBy { LocaleHelper.getSourceDisplayName(it, context) }) .forEach { - preferenceCategory { - if (isMultiSource) { - title = LocaleHelper.getSourceDisplayName(it.key, context) - } - + val preferenceBlock = { it.value .sortedWith(compareBy({ !it.isEnabled() }, { it.name })) .forEach { source -> @@ -132,10 +129,9 @@ class ExtensionDetailsController(bundle: Bundle? = null) : val block: (@DSL SwitchPreferenceCompat).() -> Unit = { key = getSourceKey(source.id) - title = if (isMultiSource) { - source.toString() - } else { - context.getString(R.string.enabled) + title = when { + isMultiSource && !isMultiLangSingleSource -> source.toString() + else -> LocaleHelper.getSourceDisplayName(it.key, context) } isPersistent = false isChecked = source.isEnabled() @@ -171,6 +167,16 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } } } + + if (isMultiSource && !isMultiLangSingleSource) { + preferenceCategory { + title = LocaleHelper.getSourceDisplayName(it.key, context) + + preferenceBlock() + } + } else { + preferenceBlock() + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2f35440c45..946037a978 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -224,7 +224,6 @@ This extension is not from the official Tachiyomi extensions list. Version: %1$s Language: %1$s - Enabled Fullscreen