diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterController.kt index 8a5b3abf8..c33984b1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionFilterController.kt @@ -2,28 +2,27 @@ package eu.kanade.tachiyomi.ui.browse.extension import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.data.preference.minusAssign +import eu.kanade.tachiyomi.data.preference.plusAssign import eu.kanade.tachiyomi.extension.ExtensionManager import eu.kanade.tachiyomi.ui.setting.SettingsController import eu.kanade.tachiyomi.util.preference.onChange import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.LocaleHelper -import uy.kohesive.injekt.Injekt -import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy class ExtensionFilterController : SettingsController() { + private val extensionManager: ExtensionManager by injectLazy() + override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.label_extensions val activeLangs = preferences.enabledLanguages().get() - val availableLangs = - Injekt.get().availableExtensions.groupBy { - it.lang - }.keys - .minus("all") - .sortedWith(compareBy({ it !in activeLangs }, { LocaleHelper.getSourceDisplayName(it, context) })) + val availableLangs = extensionManager.availableExtensions.groupBy { it.lang }.keys + .sortedWith(compareBy({ it !in activeLangs }, { LocaleHelper.getSourceDisplayName(it, context) })) availableLangs.forEach { switchPreference { @@ -33,16 +32,11 @@ class ExtensionFilterController : SettingsController() { isChecked = it in activeLangs onChange { newValue -> - val checked = newValue as Boolean - val currentActiveLangs = preferences.enabledLanguages().get() - - preferences.enabledLanguages().set( - if (checked) { - currentActiveLangs + it - } else { - currentActiveLangs - it - } - ) + if (newValue as Boolean) { + preferences.enabledLanguages() += it + } else { + preferences.enabledLanguages() -= it + } true } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt index b9ac17b73..4c174ea6b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionPresenter.kt @@ -69,7 +69,7 @@ open class ExtensionPresenter( .filter { avail -> installed.none { it.pkgName == avail.pkgName } && untrusted.none { it.pkgName == avail.pkgName } && - (avail.lang in activeLangs || avail.lang == "all") && + avail.lang in activeLangs && (showNsfwSources || !avail.isNsfw) } .sortedBy { it.name }