mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 16:21:49 +01:00
More preference grouping
This commit is contained in:
parent
bf8268adc4
commit
3a62acc54d
@ -27,98 +27,6 @@ class SettingsGeneralController : SettingsController() {
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) = with(screen) {
|
||||
titleRes = R.string.pref_category_general
|
||||
|
||||
listPreference {
|
||||
key = Keys.lang
|
||||
titleRes = R.string.pref_language
|
||||
entryValues = arrayOf("", "ar", "bg", "bn", "ca", "cs", "de", "el", "en-US", "en-GB",
|
||||
"es", "fr", "hi", "hu", "in", "it", "ja", "ko", "lv", "ms", "nb-rNO", "nl", "pl", "pt",
|
||||
"pt-BR", "ro", "ru", "sc", "sr", "sv", "th", "tl", "tr", "uk", "vi", "zh-rCN")
|
||||
entries = entryValues.map { value ->
|
||||
val locale = LocaleHelper.getLocaleFromString(value.toString())
|
||||
locale?.getDisplayName(locale)?.capitalize()
|
||||
?: context.getString(R.string.system_default)
|
||||
}.toTypedArray()
|
||||
defaultValue = ""
|
||||
summary = "%s"
|
||||
|
||||
onChange { newValue ->
|
||||
val activity = activity ?: return@onChange false
|
||||
val app = activity.application
|
||||
LocaleHelper.changeLocale(newValue.toString())
|
||||
LocaleHelper.updateConfiguration(app, app.resources.configuration)
|
||||
activity.recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.dateFormat
|
||||
titleRes = R.string.pref_date_format
|
||||
entryValues = arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd")
|
||||
entries = entryValues.map { value ->
|
||||
if (value == "") {
|
||||
context.getString(R.string.system_default)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
}.toTypedArray()
|
||||
defaultValue = ""
|
||||
summary = "%s"
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeMode
|
||||
titleRes = R.string.pref_theme_mode
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_system,
|
||||
R.string.theme_light,
|
||||
R.string.theme_dark)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_MODE_SYSTEM,
|
||||
Values.THEME_MODE_LIGHT,
|
||||
Values.THEME_MODE_DARK)
|
||||
defaultValue = Values.THEME_MODE_SYSTEM
|
||||
} else {
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_light,
|
||||
R.string.theme_dark)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_MODE_LIGHT,
|
||||
Values.THEME_MODE_DARK)
|
||||
defaultValue = Values.THEME_MODE_LIGHT
|
||||
}
|
||||
|
||||
summary = "%s"
|
||||
|
||||
onChange {
|
||||
activity?.recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeDark
|
||||
titleRes = R.string.pref_theme_dark
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_dark_default,
|
||||
R.string.theme_dark_blue,
|
||||
R.string.theme_dark_amoled)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_DARK_DEFAULT,
|
||||
Values.THEME_DARK_BLUE,
|
||||
Values.THEME_DARK_AMOLED)
|
||||
defaultValue = Values.THEME_DARK_DEFAULT
|
||||
summary = "%s"
|
||||
|
||||
preferences.themeMode().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it != Values.THEME_MODE_LIGHT }
|
||||
|
||||
onChange {
|
||||
if (preferences.themeMode().getOrDefault() != Values.THEME_MODE_LIGHT) {
|
||||
activity?.recreate()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
intListPreference {
|
||||
key = Keys.startScreen
|
||||
titleRes = R.string.pref_start_screen
|
||||
@ -140,6 +48,103 @@ class SettingsGeneralController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_display
|
||||
|
||||
listPreference {
|
||||
key = Keys.lang
|
||||
titleRes = R.string.pref_language
|
||||
entryValues = arrayOf("", "ar", "bg", "bn", "ca", "cs", "de", "el", "en-US", "en-GB",
|
||||
"es", "fr", "hi", "hu", "in", "it", "ja", "ko", "lv", "ms", "nb-rNO", "nl", "pl", "pt",
|
||||
"pt-BR", "ro", "ru", "sc", "sr", "sv", "th", "tl", "tr", "uk", "vi", "zh-rCN")
|
||||
entries = entryValues.map { value ->
|
||||
val locale = LocaleHelper.getLocaleFromString(value.toString())
|
||||
locale?.getDisplayName(locale)?.capitalize()
|
||||
?: context.getString(R.string.system_default)
|
||||
}.toTypedArray()
|
||||
defaultValue = ""
|
||||
summary = "%s"
|
||||
|
||||
onChange { newValue ->
|
||||
val activity = activity ?: return@onChange false
|
||||
val app = activity.application
|
||||
LocaleHelper.changeLocale(newValue.toString())
|
||||
LocaleHelper.updateConfiguration(app, app.resources.configuration)
|
||||
activity.recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.dateFormat
|
||||
titleRes = R.string.pref_date_format
|
||||
entryValues = arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd")
|
||||
entries = entryValues.map { value ->
|
||||
if (value == "") {
|
||||
context.getString(R.string.system_default)
|
||||
} else {
|
||||
value
|
||||
}
|
||||
}.toTypedArray()
|
||||
defaultValue = ""
|
||||
summary = "%s"
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeMode
|
||||
titleRes = R.string.pref_theme_mode
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_system,
|
||||
R.string.theme_light,
|
||||
R.string.theme_dark)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_MODE_SYSTEM,
|
||||
Values.THEME_MODE_LIGHT,
|
||||
Values.THEME_MODE_DARK)
|
||||
defaultValue = Values.THEME_MODE_SYSTEM
|
||||
} else {
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_light,
|
||||
R.string.theme_dark)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_MODE_LIGHT,
|
||||
Values.THEME_MODE_DARK)
|
||||
defaultValue = Values.THEME_MODE_LIGHT
|
||||
}
|
||||
|
||||
summary = "%s"
|
||||
|
||||
onChange {
|
||||
activity?.recreate()
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeDark
|
||||
titleRes = R.string.pref_theme_dark
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_dark_default,
|
||||
R.string.theme_dark_blue,
|
||||
R.string.theme_dark_amoled)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_DARK_DEFAULT,
|
||||
Values.THEME_DARK_BLUE,
|
||||
Values.THEME_DARK_AMOLED)
|
||||
defaultValue = Values.THEME_DARK_DEFAULT
|
||||
summary = "%s"
|
||||
|
||||
preferences.themeMode().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it != Values.THEME_MODE_LIGHT }
|
||||
|
||||
onChange {
|
||||
if (preferences.themeMode().getOrDefault() != Values.THEME_MODE_LIGHT) {
|
||||
activity?.recreate()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_security
|
||||
|
||||
|
@ -41,7 +41,7 @@ class SettingsLibraryController : SettingsController() {
|
||||
titleRes = R.string.pref_category_library
|
||||
|
||||
preferenceCategory {
|
||||
titleRes = R.string.pref_category_library_display
|
||||
titleRes = R.string.pref_category_display
|
||||
|
||||
preference {
|
||||
titleRes = R.string.pref_library_columns
|
||||
|
@ -147,7 +147,7 @@
|
||||
<string name="secure_screen_summary">Hide app contents when switching apps and block screenshots</string>
|
||||
|
||||
<!-- Library section -->
|
||||
<string name="pref_category_library_display">Display</string>
|
||||
<string name="pref_category_display">Display</string>
|
||||
<string name="pref_library_columns">Library manga per row</string>
|
||||
<string name="portrait">Portrait</string>
|
||||
<string name="landscape">Landscape</string>
|
||||
|
Loading…
Reference in New Issue
Block a user