Hide Android 12 auto update features if "notify for ext updates" is disabled

This commit is contained in:
Jays2Kings 2021-09-30 13:08:36 -04:00
parent a489f824b5
commit 93aafb46f4

View file

@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.updater.AutoUpdaterJob
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
@ -44,7 +45,7 @@ class SettingsBrowseController : SettingsController() {
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
intListPreference(activity) {
val intPref = intListPreference(activity) {
key = PreferenceKeys.autoUpdateExtensions
titleRes = R.string.auto_update_extensions
entryRange = 0..2
@ -55,8 +56,8 @@ class SettingsBrowseController : SettingsController() {
)
defaultValue = AutoUpdaterJob.ONLY_ON_UNMETERED
}
infoPreference(R.string.some_extensions_may_not_update)
switchPreference {
val infoPref = infoPreference(R.string.some_extensions_may_not_update)
val switchPref = switchPreference {
key = "notify_ext_updated"
isPersistent = false
titleRes = R.string.notify_extension_updated
@ -73,6 +74,9 @@ class SettingsBrowseController : SettingsController() {
startActivity(intent)
}
}
preferences.automaticExtUpdates().asImmediateFlowIn(viewScope) { value ->
arrayOf(intPref, infoPref, switchPref).forEach { it.isVisible = value }
}
}
}