Refactor dependant preference visibility flows
(cherry picked from commit 945afc71ef7aa753ec09640cbf9859ff98770c5a) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt # app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSecurityController.kt
This commit is contained in:
parent
b19c178eae
commit
2bd9d2844f
@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
|||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD
|
import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
@ -303,8 +302,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
defaultValue = ""
|
defaultValue = ""
|
||||||
summaryRes = R.string.data_saver_server_summary
|
summaryRes = R.string.data_saver_server_summary
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -312,8 +310,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
key = Keys.dataSaverDownloaer
|
key = Keys.dataSaverDownloaer
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -321,8 +318,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
key = Keys.ignoreJpeg
|
key = Keys.ignoreJpeg
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -330,8 +326,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
key = Keys.ignoreGif
|
key = Keys.ignoreGif
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
@ -342,8 +337,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
defaultValue = "80"
|
defaultValue = "80"
|
||||||
summaryRes = R.string.data_saver_image_quality_summary
|
summaryRes = R.string.data_saver_image_quality_summary
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -353,8 +347,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
summaryOn = context.getString(R.string.data_saver_image_format_summary_on)
|
summaryOn = context.getString(R.string.data_saver_image_format_summary_on)
|
||||||
summaryOff = context.getString(R.string.data_saver_image_format_summary_off)
|
summaryOff = context.getString(R.string.data_saver_image_format_summary_off)
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -362,8 +355,7 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
key = Keys.dataSaverColorBW
|
key = Keys.dataSaverColorBW
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
|
||||||
preferences.dataSaver().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.dataSaver()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import androidx.core.app.ActivityCompat
|
|||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||||
import eu.kanade.tachiyomi.util.preference.initThenAdd
|
import eu.kanade.tachiyomi.util.preference.initThenAdd
|
||||||
@ -19,7 +18,6 @@ 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.isTablet
|
import eu.kanade.tachiyomi.util.system.isTablet
|
||||||
import eu.kanade.tachiyomi.widget.preference.ThemesPreference
|
import eu.kanade.tachiyomi.widget.preference.ThemesPreference
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||||
@ -89,8 +87,7 @@ class SettingsAppearanceController : SettingsController() {
|
|||||||
titleRes = R.string.pref_dark_theme_pure_black
|
titleRes = R.string.pref_dark_theme_pure_black
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
|
||||||
preferences.themeMode().asImmediateFlow { isVisible = it != Values.ThemeMode.light }
|
visibleIf(preferences.themeMode()) { it != Values.ThemeMode.light }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
activity?.let { ActivityCompat.recreate(it) }
|
activity?.let { ActivityCompat.recreate(it) }
|
||||||
|
@ -23,7 +23,6 @@ import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
|||||||
import eu.kanade.tachiyomi.data.backup.full.FullBackupRestoreValidator
|
import eu.kanade.tachiyomi.data.backup.full.FullBackupRestoreValidator
|
||||||
import eu.kanade.tachiyomi.data.backup.full.models.BackupFull
|
import eu.kanade.tachiyomi.data.backup.full.models.BackupFull
|
||||||
import eu.kanade.tachiyomi.data.backup.legacy.LegacyBackupRestoreValidator
|
import eu.kanade.tachiyomi.data.backup.legacy.LegacyBackupRestoreValidator
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||||
@ -137,8 +136,7 @@ class SettingsBackupController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.backupInterval().asImmediateFlow { isVisible = it > 0 }
|
visibleIf(preferences.backupInterval()) { it > 0 }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
preferences.backupsDirectory().asFlow()
|
preferences.backupsDirectory().asFlow()
|
||||||
.onEach { path ->
|
.onEach { path ->
|
||||||
@ -155,8 +153,7 @@ class SettingsBackupController : SettingsController() {
|
|||||||
defaultValue = "1"
|
defaultValue = "1"
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.backupInterval().asImmediateFlow { isVisible = it > 0 }
|
visibleIf(preferences.backupInterval()) { it > 0 }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.core.animation.doOnEnd
|
import androidx.core.animation.doOnEnd
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceController
|
import androidx.preference.PreferenceController
|
||||||
import androidx.preference.PreferenceGroup
|
import androidx.preference.PreferenceGroup
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
@ -21,12 +22,14 @@ import com.bluelinelabs.conductor.ControllerChangeType
|
|||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
import eu.kanade.tachiyomi.ui.base.controller.RootController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
@ -133,4 +136,9 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
|
|
||||||
(activity as? AppCompatActivity)?.supportActionBar?.title = getTitle()
|
(activity as? AppCompatActivity)?.supportActionBar?.title = getTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <T> Preference.visibleIf(preference: com.tfcporciuncula.flow.Preference<T>, crossinline block: (T) -> Boolean) {
|
||||||
|
preference.asImmediateFlow { isVisible = block(it) }
|
||||||
|
.launchIn(viewScope)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||||
@ -84,8 +83,7 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
entryValues = entries
|
entryValues = entries
|
||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
|
|
||||||
preferences.saveChaptersAsCBZ().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.saveChaptersAsCBZ()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
@ -153,8 +151,7 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
DownloadCategoriesDialog().showDialog(router)
|
DownloadCategoriesDialog().showDialog(router)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.downloadNew().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.downloadNew()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
fun updateSummary() {
|
fun updateSummary() {
|
||||||
val selectedCategories = preferences.downloadNewCategories().get()
|
val selectedCategories = preferences.downloadNewCategories().get()
|
||||||
|
@ -20,7 +20,6 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.preference.DEVICE_CHARGING
|
import eu.kanade.tachiyomi.data.preference.DEVICE_CHARGING
|
||||||
import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI
|
import eu.kanade.tachiyomi.data.preference.DEVICE_ONLY_ON_WIFI
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.databinding.DialogStubTextinputBinding
|
import eu.kanade.tachiyomi.databinding.DialogStubTextinputBinding
|
||||||
import eu.kanade.tachiyomi.ui.setting.eh.FrontPageCategoriesDialog
|
import eu.kanade.tachiyomi.ui.setting.eh.FrontPageCategoriesDialog
|
||||||
import eu.kanade.tachiyomi.ui.setting.eh.LanguagesDialog
|
import eu.kanade.tachiyomi.ui.setting.eh.LanguagesDialog
|
||||||
@ -133,8 +132,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
|
|
||||||
onChange { preferences.useHentaiAtHome().reconfigure() }
|
onChange { preferences.useHentaiAtHome().reconfigure() }
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -146,8 +144,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
|
|
||||||
onChange { preferences.useJapaneseTitle().reconfigure() }
|
onChange { preferences.useJapaneseTitle().reconfigure() }
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -159,8 +156,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
|
|
||||||
onChange { preferences.exhUseOriginalImages().reconfigure() }
|
onChange { preferences.exhUseOriginalImages().reconfigure() }
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
@ -176,8 +172,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
@ -221,8 +216,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
@ -267,8 +261,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
@ -282,8 +275,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
dialog.showDialog(router)
|
dialog.showDialog(router)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preference {
|
preference {
|
||||||
@ -297,8 +289,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
dialog.showDialog(router)
|
dialog.showDialog(router)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -307,8 +298,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
titleRes = R.string.watched_list_default
|
titleRes = R.string.watched_list_default
|
||||||
summaryRes = R.string.watched_list_state_summary
|
summaryRes = R.string.watched_list_state_summary
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
listPreference {
|
listPreference {
|
||||||
@ -335,8 +325,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
|
|
||||||
onChange { preferences.imageQuality().reconfigure() }
|
onChange { preferences.imageQuality().reconfigure() }
|
||||||
|
|
||||||
preferences.enableExhentai().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.enableExhentai()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -465,9 +454,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
summary = context.getString(R.string.restrictions, restrictionsText)
|
summary = context.getString(R.string.restrictions, restrictionsText)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.exhAutoUpdateFrequency().asFlow()
|
visibleIf(preferences.exhAutoUpdateFrequency()) { it > 0 }
|
||||||
.onEach { isVisible = it > 0 }
|
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
// Post to event looper to allow the preference to be updated.
|
// Post to event looper to allow the preference to be updated.
|
||||||
|
@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.data.preference.MANGA_FULLY_READ
|
|||||||
import eu.kanade.tachiyomi.data.preference.MANGA_ONGOING
|
import eu.kanade.tachiyomi.data.preference.MANGA_ONGOING
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.GroupLibraryMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.GroupLibraryMode
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.databinding.PrefLibraryColumnsBinding
|
import eu.kanade.tachiyomi.databinding.PrefLibraryColumnsBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
@ -190,8 +189,7 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
entryValues = arrayOf(DEVICE_ONLY_ON_WIFI, DEVICE_CHARGING)
|
entryValues = arrayOf(DEVICE_ONLY_ON_WIFI, DEVICE_CHARGING)
|
||||||
defaultValue = preferences.libraryUpdateDeviceRestriction().defaultValue
|
defaultValue = preferences.libraryUpdateDeviceRestriction().defaultValue
|
||||||
|
|
||||||
preferences.libraryUpdateInterval().asImmediateFlow { isVisible = it > 0 }
|
visibleIf(preferences.libraryUpdateInterval()) { it > 0 }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
// Post to event looper to allow the preference to be updated.
|
// Post to event looper to allow the preference to be updated.
|
||||||
@ -229,8 +227,7 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
entryValues = arrayOf(MANGA_FULLY_READ, MANGA_ONGOING)
|
entryValues = arrayOf(MANGA_FULLY_READ, MANGA_ONGOING)
|
||||||
defaultValue = preferences.libraryUpdateMangaRestriction().defaultValue
|
defaultValue = preferences.libraryUpdateMangaRestriction().defaultValue
|
||||||
|
|
||||||
preferences.libraryUpdateInterval().asImmediateFlow { isVisible = it > 0 }
|
visibleIf(preferences.libraryUpdateInterval()) { it > 0 }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
fun updateSummary() {
|
fun updateSummary() {
|
||||||
val restrictions = preferences.libraryUpdateMangaRestriction().get()
|
val restrictions = preferences.libraryUpdateMangaRestriction().get()
|
||||||
|
@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderBottomButton
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderBottomButton
|
||||||
@ -26,7 +25,6 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
|
|||||||
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.hasDisplayCutout
|
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
@ -83,14 +81,14 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.pref_show_vert_seekbar_landscape
|
titleRes = R.string.pref_show_vert_seekbar_landscape
|
||||||
summaryRes = R.string.pref_show_vert_seekbar_landscape_summary
|
summaryRes = R.string.pref_show_vert_seekbar_landscape_summary
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.forceHorizontalSeekbar().asImmediateFlow { isVisible = !it }.launchIn(viewScope)
|
visibleIf(preferences.forceHorizontalSeekbar()) { !it }
|
||||||
}
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.leftVerticalSeekbar
|
key = Keys.leftVerticalSeekbar
|
||||||
titleRes = R.string.pref_left_handed_vertical_seekbar
|
titleRes = R.string.pref_left_handed_vertical_seekbar
|
||||||
summaryRes = R.string.pref_left_handed_vertical_seekbar_summary
|
summaryRes = R.string.pref_left_handed_vertical_seekbar_summary
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.forceHorizontalSeekbar().asImmediateFlow { isVisible = !it }.launchIn(viewScope)
|
visibleIf(preferences.forceHorizontalSeekbar()) { !it }
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@ -139,7 +137,8 @@ class SettingsReaderController : SettingsController() {
|
|||||||
key = Keys.cutoutShort
|
key = Keys.cutoutShort
|
||||||
titleRes = R.string.pref_cutout_short
|
titleRes = R.string.pref_cutout_short
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
preferences.fullscreen().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
|
||||||
|
visibleIf(preferences.fullscreen()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +186,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.readWithTapping()) { it }
|
||||||
}
|
}
|
||||||
listPreference {
|
listPreference {
|
||||||
key = Keys.pagerNavInverted
|
key = Keys.pagerNavInverted
|
||||||
@ -207,7 +206,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
defaultValue = TappingInvertMode.NONE.name
|
defaultValue = TappingInvertMode.NONE.name
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.readWithTapping()) { it }
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
key = Keys.imageScaleType
|
key = Keys.imageScaleType
|
||||||
@ -259,7 +258,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.pref_dual_page_invert
|
titleRes = R.string.pref_dual_page_invert
|
||||||
summaryRes = R.string.pref_dual_page_invert_summary
|
summaryRes = R.string.pref_dual_page_invert_summary
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.dualPageSplitPaged().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.dualPageSplitPaged()) { it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +274,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
defaultValue = "0"
|
defaultValue = "0"
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.readWithTapping()) { it }
|
||||||
}
|
}
|
||||||
listPreference {
|
listPreference {
|
||||||
key = Keys.webtoonNavInverted
|
key = Keys.webtoonNavInverted
|
||||||
@ -295,7 +294,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
defaultValue = TappingInvertMode.NONE.name
|
defaultValue = TappingInvertMode.NONE.name
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.readWithTapping()) { it }
|
||||||
}
|
}
|
||||||
intListPreference {
|
intListPreference {
|
||||||
key = Keys.webtoonSidePadding
|
key = Keys.webtoonSidePadding
|
||||||
@ -341,7 +340,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.pref_dual_page_invert
|
titleRes = R.string.pref_dual_page_invert
|
||||||
summaryRes = R.string.pref_dual_page_invert_summary
|
summaryRes = R.string.pref_dual_page_invert_summary
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.dualPageSplitWebtoon().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
visibleIf(preferences.dualPageSplitWebtoon()) { it }
|
||||||
}
|
}
|
||||||
// SY -->
|
// SY -->
|
||||||
switchPreference {
|
switchPreference {
|
||||||
@ -392,8 +391,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
key = Keys.readWithVolumeKeysInverted
|
key = Keys.readWithVolumeKeysInverted
|
||||||
titleRes = R.string.pref_read_with_volume_keys_inverted
|
titleRes = R.string.pref_read_with_volume_keys_inverted
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
|
visibleIf(preferences.readWithVolumeKeys()) { it }
|
||||||
preferences.readWithVolumeKeys().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +548,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
key = Keys.invertDoublePages
|
key = Keys.invertDoublePages
|
||||||
titleRes = R.string.invert_double_pages
|
titleRes = R.string.invert_double_pages
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
preferences.pageLayout().asImmediateFlow { isVisible = it != PagerConfig.PageLayout.SINGLE_PAGE }
|
visibleIf(preferences.pageLayout()) { it != PagerConfig.PageLayout.SINGLE_PAGE }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
@ -9,7 +9,6 @@ import androidx.preference.PreferenceScreen
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||||
import eu.kanade.tachiyomi.ui.category.biometric.BiometricTimesController
|
import eu.kanade.tachiyomi.ui.category.biometric.BiometricTimesController
|
||||||
@ -26,7 +25,6 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
|||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.isAuthenticationSupported
|
||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.startAuthentication
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
|
|
||||||
@ -90,8 +88,7 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.useAuthenticator()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +112,7 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
val timeRanges = preferences.authenticatorTimeRanges().get().size
|
val timeRanges = preferences.authenticatorTimeRanges().get().size
|
||||||
summary = context.resources.getQuantityString(R.plurals.num_lock_times, timeRanges, timeRanges)
|
summary = context.resources.getQuantityString(R.plurals.num_lock_times, timeRanges, timeRanges)
|
||||||
|
|
||||||
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.useAuthenticator()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
onClick {
|
onClick {
|
||||||
router.pushController(BiometricTimesController().withFadeTransaction())
|
router.pushController(BiometricTimesController().withFadeTransaction())
|
||||||
@ -127,8 +123,7 @@ class SettingsSecurityController : SettingsController() {
|
|||||||
titleRes = R.string.biometric_lock_days
|
titleRes = R.string.biometric_lock_days
|
||||||
summaryRes = R.string.biometric_lock_days_summary
|
summaryRes = R.string.biometric_lock_days_summary
|
||||||
|
|
||||||
preferences.useAuthenticator().asImmediateFlow { isVisible = it }
|
visibleIf(preferences.useAuthenticator()) { it }
|
||||||
.launchIn(viewScope)
|
|
||||||
|
|
||||||
onClick {
|
onClick {
|
||||||
SetLockedDaysDialog().showDialog(router)
|
SetLockedDaysDialog().showDialog(router)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user