mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:09:19 +01:00
Allow hiding "All" section in extensions list (closes #6081)
This commit is contained in:
parent
151193c4c3
commit
42026b49bf
@ -2,27 +2,26 @@ package eu.kanade.tachiyomi.ui.browse.extension
|
|||||||
|
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
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.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.util.preference.onChange
|
import eu.kanade.tachiyomi.util.preference.onChange
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.injectLazy
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
|
|
||||||
class ExtensionFilterController : SettingsController() {
|
class ExtensionFilterController : SettingsController() {
|
||||||
|
|
||||||
|
private val extensionManager: ExtensionManager by injectLazy()
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
|
||||||
titleRes = R.string.label_extensions
|
titleRes = R.string.label_extensions
|
||||||
|
|
||||||
val activeLangs = preferences.enabledLanguages().get()
|
val activeLangs = preferences.enabledLanguages().get()
|
||||||
|
|
||||||
val availableLangs =
|
val availableLangs = extensionManager.availableExtensions.groupBy { it.lang }.keys
|
||||||
Injekt.get<ExtensionManager>().availableExtensions.groupBy {
|
|
||||||
it.lang
|
|
||||||
}.keys
|
|
||||||
.minus("all")
|
|
||||||
.sortedWith(compareBy({ it !in activeLangs }, { LocaleHelper.getSourceDisplayName(it, context) }))
|
.sortedWith(compareBy({ it !in activeLangs }, { LocaleHelper.getSourceDisplayName(it, context) }))
|
||||||
|
|
||||||
availableLangs.forEach {
|
availableLangs.forEach {
|
||||||
@ -33,16 +32,11 @@ class ExtensionFilterController : SettingsController() {
|
|||||||
isChecked = it in activeLangs
|
isChecked = it in activeLangs
|
||||||
|
|
||||||
onChange { newValue ->
|
onChange { newValue ->
|
||||||
val checked = newValue as Boolean
|
if (newValue as Boolean) {
|
||||||
val currentActiveLangs = preferences.enabledLanguages().get()
|
preferences.enabledLanguages() += it
|
||||||
|
|
||||||
preferences.enabledLanguages().set(
|
|
||||||
if (checked) {
|
|
||||||
currentActiveLangs + it
|
|
||||||
} else {
|
} else {
|
||||||
currentActiveLangs - it
|
preferences.enabledLanguages() -= it
|
||||||
}
|
}
|
||||||
)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ open class ExtensionPresenter(
|
|||||||
.filter { avail ->
|
.filter { avail ->
|
||||||
installed.none { it.pkgName == avail.pkgName } &&
|
installed.none { it.pkgName == avail.pkgName } &&
|
||||||
untrusted.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)
|
(showNsfwSources || !avail.isNsfw)
|
||||||
}
|
}
|
||||||
.sortedBy { it.name }
|
.sortedBy { it.name }
|
||||||
|
Loading…
Reference in New Issue
Block a user