mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Reduce redundancy in some preference declarations
The remaining ones could also be converted to FlowPreferences for this, but it's not really necessary.
This commit is contained in:
@@ -67,8 +67,10 @@ open class ExtensionPresenter(
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name }))
|
||||
|
||||
val installedSorted = installed.filter { !it.hasUpdate && (showNsfwSources || !it.isNsfw) }
|
||||
.sortedWith(compareBy<Extension.Installed> { !it.isObsolete }
|
||||
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name })
|
||||
.sortedWith(
|
||||
compareBy<Extension.Installed> { !it.isObsolete }
|
||||
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name }
|
||||
)
|
||||
|
||||
val untrustedSorted = untrusted.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER, { it.name }))
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class LibraryAdapter(
|
||||
|
||||
private var boundViews = arrayListOf<View>()
|
||||
|
||||
private val isPerCategory by lazy { preferences.categorisedDisplaySettings().get() }
|
||||
private val isPerCategory by lazy { preferences.categorizedDisplaySettings().get() }
|
||||
private var currentDisplayMode = preferences.libraryDisplayMode().get()
|
||||
|
||||
init {
|
||||
|
||||
@@ -195,7 +195,7 @@ class LibraryController(
|
||||
is LibrarySettingsSheet.Filter.FilterGroup -> onFilterChanged()
|
||||
is LibrarySettingsSheet.Sort.SortGroup -> onSortChanged()
|
||||
is LibrarySettingsSheet.Display.DisplayGroup -> {
|
||||
val delay = if (preferences.categorisedDisplaySettings().get()) 125L else 0L
|
||||
val delay = if (preferences.categorizedDisplaySettings().get()) 125L else 0L
|
||||
|
||||
Observable.timer(delay, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
|
||||
@@ -369,7 +369,7 @@ class LibraryPresenter(
|
||||
*/
|
||||
private fun getLibraryMangasObservable(): Observable<LibraryMap> {
|
||||
val defaultLibraryDisplayMode = preferences.libraryDisplayMode()
|
||||
val shouldSetFromCategory = preferences.categorisedDisplaySettings()
|
||||
val shouldSetFromCategory = preferences.categorizedDisplaySettings()
|
||||
return db.getLibraryMangas().asRxObservable()
|
||||
.map { list ->
|
||||
list.map { libraryManga ->
|
||||
|
||||
@@ -245,7 +245,7 @@ class LibrarySettingsSheet(
|
||||
SortDirectionSetting.DESCENDING
|
||||
}
|
||||
|
||||
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
if (preferences.categorizedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
currentCategory?.sortDirection = flag.flag
|
||||
|
||||
db.insertCategory(currentCategory!!).executeAsBlocking()
|
||||
@@ -267,7 +267,7 @@ class LibrarySettingsSheet(
|
||||
else -> throw NotImplementedError("Unknown display mode")
|
||||
}
|
||||
|
||||
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
if (preferences.categorizedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
currentCategory?.sortMode = flag.flag
|
||||
|
||||
db.insertCategory(currentCategory!!).executeAsBlocking()
|
||||
@@ -304,7 +304,7 @@ class LibrarySettingsSheet(
|
||||
|
||||
// Gets user preference of currently selected display mode at current category
|
||||
private fun getDisplayModePreference(): DisplayModeSetting {
|
||||
return if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
return if (preferences.categorizedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
DisplayModeSetting.fromFlag(currentCategory?.displayMode)
|
||||
} else {
|
||||
preferences.libraryDisplayMode().get()
|
||||
@@ -353,7 +353,7 @@ class LibrarySettingsSheet(
|
||||
else -> throw NotImplementedError("Unknown display mode")
|
||||
}
|
||||
|
||||
if (preferences.categorisedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
if (preferences.categorizedDisplaySettings().get() && currentCategory != null && currentCategory?.id != 0) {
|
||||
currentCategory?.displayMode = flag.flag
|
||||
|
||||
db.insertCategory(currentCategory!!).executeAsBlocking()
|
||||
|
||||
@@ -15,7 +15,7 @@ enum class SortDirectionSetting(val flag: Int) {
|
||||
}
|
||||
|
||||
fun get(preferences: PreferencesHelper, category: Category?): SortDirectionSetting {
|
||||
return if (preferences.categorisedDisplaySettings().get() && category != null && category.id != 0) {
|
||||
return if (preferences.categorizedDisplaySettings().get() && category != null && category.id != 0) {
|
||||
fromFlag(category.sortDirection)
|
||||
} else {
|
||||
preferences.librarySortingAscending().get()
|
||||
|
||||
@@ -22,7 +22,7 @@ enum class SortModeSetting(val flag: Int) {
|
||||
}
|
||||
|
||||
fun get(preferences: PreferencesHelper, category: Category?): SortModeSetting {
|
||||
return if (preferences.categorisedDisplaySettings().get() && category != null && category.id != 0) {
|
||||
return if (preferences.categorizedDisplaySettings().get() && category != null && category.id != 0) {
|
||||
fromFlag(category.sortMode)
|
||||
} else {
|
||||
preferences.librarySortingMode().get()
|
||||
|
||||
@@ -18,7 +18,7 @@ import eu.kanade.tachiyomi.ui.setting.SettingsBackupController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||
import eu.kanade.tachiyomi.util.preference.add
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.iconRes
|
||||
import eu.kanade.tachiyomi.util.preference.iconTint
|
||||
import eu.kanade.tachiyomi.util.preference.onClick
|
||||
@@ -36,7 +36,6 @@ import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
||||
class MoreController :
|
||||
SettingsController(),
|
||||
@@ -58,7 +57,7 @@ class MoreController :
|
||||
add(MoreHeaderPreference(context))
|
||||
|
||||
switchPreference {
|
||||
key = Keys.downloadedOnly
|
||||
bindTo(preferences.downloadedOnly())
|
||||
titleRes = R.string.label_downloaded_only
|
||||
summaryRes = R.string.downloaded_only_summary
|
||||
iconRes = R.drawable.ic_cloud_off_24dp
|
||||
@@ -66,12 +65,11 @@ class MoreController :
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.incognitoMode
|
||||
bindTo(preferences.incognitoMode())
|
||||
summaryRes = R.string.pref_incognito_mode_summary
|
||||
titleRes = R.string.pref_incognito_mode
|
||||
iconRes = R.drawable.ic_glasses_24dp
|
||||
iconTint = tintColor
|
||||
defaultValue = false
|
||||
|
||||
preferences.incognitoMode().asFlow()
|
||||
.onEach { isChecked = it }
|
||||
|
||||
@@ -76,7 +76,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
|
||||
private val threshold: Int =
|
||||
Injekt.get<PreferencesHelper>()
|
||||
.readerHideTreshold()
|
||||
.readerHideThreshold()
|
||||
.get()
|
||||
.threshold
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.ui.setting.database.ClearDatabaseController
|
||||
import eu.kanade.tachiyomi.util.CrashLogUtil
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -35,7 +36,6 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.isPackageInstalled
|
||||
import eu.kanade.tachiyomi.util.system.powerManager
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
@@ -206,7 +206,7 @@ class SettingsAdvancedController : SettingsController() {
|
||||
titleRes = R.string.label_extensions
|
||||
|
||||
listPreference {
|
||||
key = Keys.extensionInstaller
|
||||
bindTo(preferences.extensionInstaller())
|
||||
titleRes = R.string.ext_installer_pref
|
||||
summary = "%s"
|
||||
entriesRes = arrayOf(
|
||||
@@ -215,11 +215,6 @@ class SettingsAdvancedController : SettingsController() {
|
||||
R.string.ext_installer_shizuku,
|
||||
)
|
||||
entryValues = PreferenceValues.ExtensionInstaller.values().map { it.name }.toTypedArray()
|
||||
defaultValue = if (DeviceUtil.isMiui) {
|
||||
PreferenceValues.ExtensionInstaller.LEGACY
|
||||
} else {
|
||||
PreferenceValues.ExtensionInstaller.PACKAGEINSTALLER
|
||||
}.name
|
||||
|
||||
onChange {
|
||||
if (it == PreferenceValues.ExtensionInstaller.SHIZUKU.name &&
|
||||
@@ -245,12 +240,11 @@ class SettingsAdvancedController : SettingsController() {
|
||||
titleRes = R.string.pref_category_display
|
||||
|
||||
listPreference {
|
||||
key = Keys.tabletUiMode
|
||||
bindTo(preferences.tabletUiMode())
|
||||
titleRes = R.string.pref_tablet_ui_mode
|
||||
summary = "%s"
|
||||
entriesRes = arrayOf(R.string.automatic_background, R.string.lock_always, R.string.landscape, R.string.lock_never)
|
||||
entryValues = PreferenceValues.TabletUiMode.values().map { it.name }.toTypedArray()
|
||||
defaultValue = PreferenceValues.TabletUiMode.AUTOMATIC.name
|
||||
|
||||
onChange {
|
||||
activity?.toast(R.string.requires_app_restart)
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.core.app.ActivityCompat
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.initThenAdd
|
||||
@@ -33,7 +34,7 @@ class SettingsAppearanceController : SettingsController() {
|
||||
titleRes = R.string.pref_category_theme
|
||||
|
||||
listPreference {
|
||||
key = Keys.themeMode
|
||||
bindTo(preferences.themeMode())
|
||||
titleRes = R.string.pref_theme_mode
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
@@ -47,7 +48,6 @@ class SettingsAppearanceController : SettingsController() {
|
||||
Values.ThemeMode.light.name,
|
||||
Values.ThemeMode.dark.name
|
||||
)
|
||||
defaultValue = Values.ThemeMode.system.name
|
||||
} else {
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_light,
|
||||
@@ -57,13 +57,12 @@ class SettingsAppearanceController : SettingsController() {
|
||||
Values.ThemeMode.light.name,
|
||||
Values.ThemeMode.dark.name
|
||||
)
|
||||
defaultValue = Values.ThemeMode.light.name
|
||||
}
|
||||
|
||||
summary = "%s"
|
||||
}
|
||||
themesPreference = initThenAdd(ThemesPreference(context)) {
|
||||
key = Keys.appTheme
|
||||
bindTo(preferences.appTheme())
|
||||
titleRes = R.string.pref_app_theme
|
||||
|
||||
val appThemes = Values.AppTheme.values().filter {
|
||||
@@ -75,7 +74,6 @@ class SettingsAppearanceController : SettingsController() {
|
||||
it.titleResId != null && monetFilter
|
||||
}
|
||||
entries = appThemes
|
||||
defaultValue = appThemes[0].name
|
||||
|
||||
onChange {
|
||||
activity?.let { ActivityCompat.recreate(it) }
|
||||
@@ -83,9 +81,8 @@ class SettingsAppearanceController : SettingsController() {
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.themeDarkAmoled
|
||||
bindTo(preferences.themeDarkAmoled())
|
||||
titleRes = R.string.pref_dark_theme_pure_black
|
||||
defaultValue = false
|
||||
|
||||
visibleIf(preferences.themeMode()) { it != Values.ThemeMode.light }
|
||||
|
||||
@@ -101,7 +98,7 @@ class SettingsAppearanceController : SettingsController() {
|
||||
|
||||
if (context.isTablet()) {
|
||||
intListPreference {
|
||||
key = Keys.sideNavIconAlignment
|
||||
bindTo(preferences.sideNavIconAlignment())
|
||||
titleRes = R.string.pref_side_nav_icon_alignment
|
||||
entriesRes = arrayOf(
|
||||
R.string.alignment_top,
|
||||
@@ -109,14 +106,12 @@ class SettingsAppearanceController : SettingsController() {
|
||||
R.string.alignment_bottom,
|
||||
)
|
||||
entryValues = arrayOf("0", "1", "2")
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
}
|
||||
} else {
|
||||
switchPreference {
|
||||
key = Keys.hideBottomBarOnScroll
|
||||
bindTo(preferences.hideBottomBarOnScroll())
|
||||
titleRes = R.string.pref_hide_bottom_bar_on_scroll
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +120,7 @@ class SettingsAppearanceController : SettingsController() {
|
||||
titleRes = R.string.pref_category_timestamps
|
||||
|
||||
intListPreference {
|
||||
key = Keys.relativeTime
|
||||
bindTo(preferences.relativeTime())
|
||||
titleRes = R.string.pref_relative_format
|
||||
val values = arrayOf("0", "2", "7")
|
||||
entryValues = values
|
||||
@@ -136,7 +131,6 @@ class SettingsAppearanceController : SettingsController() {
|
||||
else -> context.getString(R.string.pref_relative_time_long)
|
||||
}
|
||||
}.toTypedArray()
|
||||
defaultValue = "7"
|
||||
summary = "%s"
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import eu.kanade.tachiyomi.data.backup.full.models.BackupFull
|
||||
import eu.kanade.tachiyomi.data.backup.legacy.LegacyBackupRestoreValidator
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.infoPreference
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -39,7 +39,6 @@ import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
|
||||
class SettingsBackupController : SettingsController() {
|
||||
|
||||
@@ -103,7 +102,7 @@ class SettingsBackupController : SettingsController() {
|
||||
titleRes = R.string.pref_backup_service_category
|
||||
|
||||
intListPreference {
|
||||
key = Keys.backupInterval
|
||||
bindTo(preferences.backupInterval())
|
||||
titleRes = R.string.pref_backup_interval
|
||||
entriesRes = arrayOf(
|
||||
R.string.update_never,
|
||||
@@ -114,7 +113,6 @@ class SettingsBackupController : SettingsController() {
|
||||
R.string.update_weekly
|
||||
)
|
||||
entryValues = arrayOf("0", "6", "12", "24", "48", "168")
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
onChange { newValue ->
|
||||
@@ -124,7 +122,7 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
}
|
||||
preference {
|
||||
key = Keys.backupDirectory
|
||||
bindTo(preferences.backupsDirectory())
|
||||
titleRes = R.string.pref_backup_directory
|
||||
|
||||
onClick {
|
||||
@@ -146,11 +144,10 @@ class SettingsBackupController : SettingsController() {
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.numberOfBackups
|
||||
bindTo(preferences.numberOfBackups())
|
||||
titleRes = R.string.pref_backup_slots
|
||||
entries = arrayOf("1", "2", "3", "4", "5")
|
||||
entryValues = entries
|
||||
defaultValue = "1"
|
||||
summary = "%s"
|
||||
|
||||
visibleIf(preferences.backupInterval()) { it > 0 }
|
||||
|
||||
@@ -4,6 +4,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.infoPreference
|
||||
import eu.kanade.tachiyomi.util.preference.onChange
|
||||
@@ -24,9 +25,8 @@ class SettingsBrowseController : SettingsController() {
|
||||
titleRes = R.string.label_extensions
|
||||
|
||||
switchPreference {
|
||||
key = Keys.automaticExtUpdates
|
||||
bindTo(preferences.automaticExtUpdates())
|
||||
titleRes = R.string.pref_enable_automatic_extension_updates
|
||||
defaultValue = true
|
||||
|
||||
onChange { newValue ->
|
||||
val checked = newValue as Boolean
|
||||
@@ -50,10 +50,9 @@ class SettingsBrowseController : SettingsController() {
|
||||
titleRes = R.string.pref_category_nsfw_content
|
||||
|
||||
switchPreference {
|
||||
key = Keys.showNsfwSource
|
||||
bindTo(preferences.showNsfwSource())
|
||||
titleRes = R.string.pref_show_nsfw_source
|
||||
summaryRes = R.string.requires_app_restart
|
||||
defaultValue = true
|
||||
|
||||
if (context.isAuthenticationSupported() && activity != null) {
|
||||
requireAuthentication(
|
||||
|
||||
@@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -48,7 +49,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
val categories = listOf(Category.createDefault(context)) + dbCategories
|
||||
|
||||
preference {
|
||||
key = Keys.downloadsDirectory
|
||||
bindTo(preferences.downloadsDirectory())
|
||||
titleRes = R.string.pref_download_directory
|
||||
onClick {
|
||||
val ctrl = DownloadDirectoriesDialog()
|
||||
@@ -97,7 +98,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
defaultValue = false
|
||||
}
|
||||
multiSelectListPreference {
|
||||
key = Keys.removeExcludeCategories
|
||||
bindTo(preferences.removeExcludeCategories())
|
||||
titleRes = R.string.pref_remove_exclude_categories
|
||||
entries = categories.map { it.name }.toTypedArray()
|
||||
entryValues = categories.map { it.id.toString() }.toTypedArray()
|
||||
@@ -121,12 +122,11 @@ class SettingsDownloadController : SettingsController() {
|
||||
titleRes = R.string.pref_category_auto_download
|
||||
|
||||
switchPreference {
|
||||
key = Keys.downloadNew
|
||||
bindTo(preferences.downloadNew())
|
||||
titleRes = R.string.pref_download_new
|
||||
defaultValue = false
|
||||
}
|
||||
preference {
|
||||
key = Keys.downloadNewCategories
|
||||
bindTo(preferences.downloadNewCategories())
|
||||
titleRes = R.string.categories
|
||||
onClick {
|
||||
DownloadCategoriesDialog().showDialog(router)
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Build
|
||||
import android.provider.Settings
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -33,9 +34,8 @@ class SettingsGeneralController : SettingsController() {
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.showUpdatesNavBadge
|
||||
bindTo(preferences.showUpdatesNavBadge())
|
||||
titleRes = R.string.pref_library_update_show_tab_badge
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.confirmExit
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import eu.kanade.tachiyomi.R
|
||||
@@ -22,6 +21,7 @@ import eu.kanade.tachiyomi.databinding.PrefLibraryColumnsBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryController
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -127,9 +127,8 @@ class SettingsLibraryController : SettingsController() {
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.categorizedDisplay
|
||||
bindTo(preferences.categorizedDisplaySettings())
|
||||
titleRes = R.string.categorized_display_settings
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
titleRes = R.string.pref_category_library_update
|
||||
|
||||
intListPreference {
|
||||
key = Keys.libraryUpdateInterval
|
||||
bindTo(preferences.libraryUpdateInterval())
|
||||
titleRes = R.string.pref_library_update_interval
|
||||
entriesRes = arrayOf(
|
||||
R.string.update_never,
|
||||
@@ -148,7 +147,6 @@ class SettingsLibraryController : SettingsController() {
|
||||
R.string.update_weekly
|
||||
)
|
||||
entryValues = arrayOf("0", "12", "24", "48", "72", "168")
|
||||
defaultValue = "24"
|
||||
summary = "%s"
|
||||
|
||||
onChange { newValue ->
|
||||
@@ -158,13 +156,12 @@ class SettingsLibraryController : SettingsController() {
|
||||
}
|
||||
}
|
||||
multiSelectListPreference {
|
||||
key = Keys.libraryUpdateDeviceRestriction
|
||||
bindTo(preferences.libraryUpdateDeviceRestriction())
|
||||
titleRes = R.string.pref_library_update_restriction
|
||||
entriesRes = arrayOf(R.string.connected_to_wifi, R.string.charging)
|
||||
entryValues = arrayOf(DEVICE_ONLY_ON_WIFI, DEVICE_CHARGING)
|
||||
defaultValue = preferences.libraryUpdateDeviceRestriction().defaultValue
|
||||
|
||||
visibleIfGlobalUpdateEnabled()
|
||||
visibleIf(preferences.libraryUpdateInterval()) { it > 0 }
|
||||
|
||||
onChange {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
@@ -196,11 +193,10 @@ class SettingsLibraryController : SettingsController() {
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
multiSelectListPreference {
|
||||
key = Keys.libraryUpdateMangaRestriction
|
||||
bindTo(preferences.libraryUpdateMangaRestriction())
|
||||
titleRes = R.string.pref_library_update_manga_restriction
|
||||
entriesRes = arrayOf(R.string.pref_update_only_completely_read, R.string.pref_update_only_non_completed)
|
||||
entryValues = arrayOf(MANGA_FULLY_READ, MANGA_ONGOING)
|
||||
defaultValue = preferences.libraryUpdateMangaRestriction().defaultValue
|
||||
|
||||
fun updateSummary() {
|
||||
val restrictions = preferences.libraryUpdateMangaRestriction().get()
|
||||
@@ -226,7 +222,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
.launchIn(viewScope)
|
||||
}
|
||||
preference {
|
||||
key = Keys.libraryUpdateCategories
|
||||
bindTo(preferences.libraryUpdateCategories())
|
||||
titleRes = R.string.categories
|
||||
|
||||
onClick {
|
||||
@@ -290,10 +286,6 @@ class SettingsLibraryController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun Preference.visibleIfGlobalUpdateEnabled() {
|
||||
visibleIf(preferences.libraryUpdateInterval()) { it > 0 }
|
||||
}
|
||||
|
||||
class LibraryColumnsDialog : DialogController() {
|
||||
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
|
||||
@@ -7,6 +7,7 @@ import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
@@ -39,11 +40,10 @@ class SettingsReaderController : SettingsController() {
|
||||
summary = "%s"
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.doubleTapAnimationSpeed
|
||||
bindTo(preferences.doubleTapAnimSpeed())
|
||||
titleRes = R.string.pref_double_tap_anim_speed
|
||||
entries = arrayOf(context.getString(R.string.double_tap_anim_speed_0), context.getString(R.string.double_tap_anim_speed_normal), context.getString(R.string.double_tap_anim_speed_fast))
|
||||
entryValues = arrayOf("1", "500", "250") // using a value of 0 breaks the image viewer, so min is 1
|
||||
defaultValue = "500"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
@@ -53,23 +53,20 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.showNavigationOverlayOnStart
|
||||
bindTo(preferences.showNavigationOverlayOnStart())
|
||||
titleRes = R.string.pref_show_navigation_mode
|
||||
summaryRes = R.string.pref_show_navigation_mode_summary
|
||||
defaultValue = false
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
switchPreference {
|
||||
key = Keys.trueColor
|
||||
bindTo(preferences.trueColor())
|
||||
titleRes = R.string.pref_true_color
|
||||
summaryRes = R.string.pref_true_color_summary
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.enableTransitions
|
||||
bindTo(preferences.pageTransitions())
|
||||
titleRes = R.string.pref_page_transitions
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
@@ -91,38 +88,33 @@ class SettingsReaderController : SettingsController() {
|
||||
summary = "%s"
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.readerTheme
|
||||
bindTo(preferences.readerTheme())
|
||||
titleRes = R.string.pref_reader_theme
|
||||
entriesRes = arrayOf(R.string.black_background, R.string.gray_background, R.string.white_background, R.string.automatic_background)
|
||||
entryValues = arrayOf("1", "2", "0", "3")
|
||||
defaultValue = "1"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.fullscreen
|
||||
bindTo(preferences.fullscreen())
|
||||
titleRes = R.string.pref_fullscreen
|
||||
defaultValue = true
|
||||
}
|
||||
|
||||
if (activity?.hasDisplayCutout() == true) {
|
||||
switchPreference {
|
||||
key = Keys.cutoutShort
|
||||
bindTo(preferences.cutoutShort())
|
||||
titleRes = R.string.pref_cutout_short
|
||||
defaultValue = true
|
||||
|
||||
visibleIf(preferences.fullscreen()) { it }
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.keepScreenOn
|
||||
bindTo(preferences.keepScreenOn())
|
||||
titleRes = R.string.pref_keep_screen_on
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.showPageNumber
|
||||
bindTo(preferences.showPageNumber())
|
||||
titleRes = R.string.pref_show_page_number
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,9 +132,8 @@ class SettingsReaderController : SettingsController() {
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.alwaysShowChapterTransition
|
||||
bindTo(preferences.alwaysShowChapterTransition())
|
||||
titleRes = R.string.pref_always_show_chapter_transition
|
||||
defaultValue = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,18 +141,17 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pager_viewer
|
||||
|
||||
intListPreference {
|
||||
key = Keys.navigationModePager
|
||||
bindTo(preferences.navigationModePager())
|
||||
titleRes = R.string.pref_viewer_nav
|
||||
entries = context.resources.getStringArray(R.array.pager_nav).also { values ->
|
||||
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
||||
}
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
visibleIf(preferences.readWithTapping()) { it }
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.pagerNavInverted
|
||||
bindTo(preferences.pagerNavInverted())
|
||||
titleRes = R.string.pref_read_with_tapping_inverted
|
||||
entriesRes = arrayOf(
|
||||
R.string.tapping_inverted_none,
|
||||
@@ -175,13 +165,12 @@ class SettingsReaderController : SettingsController() {
|
||||
TappingInvertMode.VERTICAL.name,
|
||||
TappingInvertMode.BOTH.name
|
||||
)
|
||||
defaultValue = TappingInvertMode.NONE.name
|
||||
summary = "%s"
|
||||
|
||||
visibleIf(preferences.readWithTapping()) { it }
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.imageScaleType
|
||||
bindTo(preferences.imageScaleType())
|
||||
titleRes = R.string.pref_image_scale_type
|
||||
entriesRes = arrayOf(
|
||||
R.string.scale_type_fit_screen,
|
||||
@@ -192,11 +181,10 @@ class SettingsReaderController : SettingsController() {
|
||||
R.string.scale_type_smart_fit
|
||||
)
|
||||
entryValues = arrayOf("1", "2", "3", "4", "5", "6")
|
||||
defaultValue = "1"
|
||||
summary = "%s"
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.zoomStart
|
||||
bindTo(preferences.zoomStart())
|
||||
titleRes = R.string.pref_zoom_start
|
||||
entriesRes = arrayOf(
|
||||
R.string.zoom_start_automatic,
|
||||
@@ -205,24 +193,20 @@ class SettingsReaderController : SettingsController() {
|
||||
R.string.zoom_start_center
|
||||
)
|
||||
entryValues = arrayOf("1", "2", "3", "4")
|
||||
defaultValue = "1"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.cropBorders
|
||||
bindTo(preferences.cropBorders())
|
||||
titleRes = R.string.pref_crop_borders
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.dualPageSplitPaged
|
||||
bindTo(preferences.dualPageSplitPaged())
|
||||
titleRes = R.string.pref_dual_page_split
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.dualPageInvertPaged
|
||||
bindTo(preferences.dualPageInvertPaged())
|
||||
titleRes = R.string.pref_dual_page_invert
|
||||
summaryRes = R.string.pref_dual_page_invert_summary
|
||||
defaultValue = false
|
||||
visibleIf(preferences.dualPageSplitPaged()) { it }
|
||||
}
|
||||
}
|
||||
@@ -231,18 +215,16 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.webtoon_viewer
|
||||
|
||||
intListPreference {
|
||||
key = Keys.navigationModeWebtoon
|
||||
bindTo(preferences.navigationModeWebtoon())
|
||||
titleRes = R.string.pref_viewer_nav
|
||||
entries = context.resources.getStringArray(R.array.webtoon_nav).also { values ->
|
||||
entryValues = values.indices.map { index -> "$index" }.toTypedArray()
|
||||
}
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
|
||||
visibleIf(preferences.readWithTapping()) { it }
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.webtoonNavInverted
|
||||
bindTo(preferences.webtoonNavInverted())
|
||||
titleRes = R.string.pref_read_with_tapping_inverted
|
||||
entriesRes = arrayOf(
|
||||
R.string.tapping_inverted_none,
|
||||
@@ -256,13 +238,12 @@ class SettingsReaderController : SettingsController() {
|
||||
TappingInvertMode.VERTICAL.name,
|
||||
TappingInvertMode.BOTH.name
|
||||
)
|
||||
defaultValue = TappingInvertMode.NONE.name
|
||||
summary = "%s"
|
||||
|
||||
visibleIf(preferences.readWithTapping()) { it }
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.webtoonSidePadding
|
||||
bindTo(preferences.webtoonSidePadding())
|
||||
titleRes = R.string.pref_webtoon_side_padding
|
||||
entriesRes = arrayOf(
|
||||
R.string.webtoon_side_padding_0,
|
||||
@@ -272,11 +253,10 @@ class SettingsReaderController : SettingsController() {
|
||||
R.string.webtoon_side_padding_25
|
||||
)
|
||||
entryValues = arrayOf("0", "10", "15", "20", "25")
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.readerHideThreshold
|
||||
bindTo(preferences.readerHideThreshold())
|
||||
titleRes = R.string.pref_hide_threshold
|
||||
entriesRes = arrayOf(
|
||||
R.string.pref_highest,
|
||||
@@ -287,24 +267,20 @@ class SettingsReaderController : SettingsController() {
|
||||
entryValues = PreferenceValues.ReaderHideThreshold.values()
|
||||
.map { it.name }
|
||||
.toTypedArray()
|
||||
defaultValue = "${PreferenceValues.ReaderHideThreshold.LOW}"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.cropBordersWebtoon
|
||||
bindTo(preferences.cropBordersWebtoon())
|
||||
titleRes = R.string.pref_crop_borders
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.dualPageSplitWebtoon
|
||||
bindTo(preferences.dualPageSplitWebtoon())
|
||||
titleRes = R.string.pref_dual_page_split
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.dualPageInvertWebtoon
|
||||
bindTo(preferences.dualPageInvertWebtoon())
|
||||
titleRes = R.string.pref_dual_page_invert
|
||||
summaryRes = R.string.pref_dual_page_invert_summary
|
||||
defaultValue = false
|
||||
visibleIf(preferences.dualPageSplitWebtoon()) { it }
|
||||
}
|
||||
}
|
||||
@@ -313,19 +289,16 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pref_reader_navigation
|
||||
|
||||
switchPreference {
|
||||
key = Keys.readWithTapping
|
||||
bindTo(preferences.readWithTapping())
|
||||
titleRes = R.string.pref_read_with_tapping
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.readWithVolumeKeys
|
||||
bindTo(preferences.readWithVolumeKeys())
|
||||
titleRes = R.string.pref_read_with_volume_keys
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.readWithVolumeKeysInverted
|
||||
bindTo(preferences.readWithVolumeKeysInverted())
|
||||
titleRes = R.string.pref_read_with_volume_keys_inverted
|
||||
defaultValue = false
|
||||
visibleIf(preferences.readWithVolumeKeys()) { it }
|
||||
}
|
||||
}
|
||||
@@ -334,9 +307,8 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pref_reader_actions
|
||||
|
||||
switchPreference {
|
||||
key = Keys.readWithLongTap
|
||||
bindTo(preferences.readWithLongTap())
|
||||
titleRes = R.string.pref_read_with_long_tap
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.folderPerManga
|
||||
|
||||
@@ -5,6 +5,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.preference.bindTo
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
import eu.kanade.tachiyomi.util.preference.requireAuthentication
|
||||
@@ -24,9 +25,8 @@ class SettingsSecurityController : SettingsController() {
|
||||
|
||||
if (context.isAuthenticationSupported()) {
|
||||
switchPreference {
|
||||
key = Keys.useAuthenticator
|
||||
bindTo(preferences.useAuthenticator())
|
||||
titleRes = R.string.lock_with_biometrics
|
||||
defaultValue = false
|
||||
|
||||
requireAuthentication(
|
||||
activity as? FragmentActivity,
|
||||
@@ -36,7 +36,7 @@ class SettingsSecurityController : SettingsController() {
|
||||
}
|
||||
|
||||
intListPreference {
|
||||
key = Keys.lockAppAfter
|
||||
bindTo(preferences.lockAppAfter())
|
||||
titleRes = R.string.lock_when_idle
|
||||
val values = arrayOf("0", "1", "2", "5", "10", "-1")
|
||||
entries = values.mapNotNull {
|
||||
@@ -47,7 +47,6 @@ class SettingsSecurityController : SettingsController() {
|
||||
}
|
||||
}.toTypedArray()
|
||||
entryValues = values
|
||||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
if (value == newValue) return@OnPreferenceChangeListener false
|
||||
@@ -82,10 +81,9 @@ class SettingsSecurityController : SettingsController() {
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.secureScreen
|
||||
bindTo(preferences.secureScreen())
|
||||
titleRes = R.string.secure_screen
|
||||
summaryRes = R.string.secure_screen_summary
|
||||
defaultValue = false
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
|
||||
Reference in New Issue
Block a user