mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 19:41:50 +01:00
Allow hiding "All" section in extensions list (closes #6081)
This commit is contained in:
parent
151193c4c3
commit
42026b49bf
@ -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<ExtensionManager>().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
|
||||
}
|
||||
}
|
||||
|
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user