From fa5d2276c0c6777c1fc1d61d916a37c7d8c00c06 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 10 Jul 2020 22:37:36 -0400 Subject: [PATCH] Group theme settings into category --- .../ui/setting/SettingsGeneralController.kt | 156 ++++++++++++------ app/src/main/res/values/strings.xml | 2 + 2 files changed, 107 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index dca4d0ab33..8790c5af8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -58,58 +58,8 @@ class SettingsGeneralController : SettingsController() { } preferenceCategory { - titleRes = R.string.pref_category_display + titleRes = R.string.pref_category_theme - listPreference { - key = Keys.lang - titleRes = R.string.pref_language - - val langs = mutableListOf>() - langs += Pair("", "${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})") - // Due to compatibility issues: - // - Hebrew: `he` is copied into `iw` at build time - langs += arrayOf( - "ar", "be", "bg", "bn", "ca", "cs", "cv", "de", "el", "es", "es-419", "en-US", "en-GB", "fa", "fi", "fil", "fr", "he", - "hi", "hr", "hu", "in", "it", "ja", "ka-rGE", "kn", "ko", "lv", "mr", "ms", "nb-rNO", "nl", "pl", "pt", - "pt-BR", "ro", "ru", "sc", "sk", "sr", "sv", "th", "tl", "tr", "uk", "ur-rPK", "vi", "zh-rCN", "zh-rTW" - ) - .map { - Pair(it, LocaleHelper.getDisplayName(it)) - } - .sortedBy { it.second } - - entryValues = langs.map { it.first }.toTypedArray() - entries = langs.map { it.second }.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") - - val now = Date().time - entries = entryValues.map { value -> - val formattedDate = preferences.dateFormat(value.toString()).format(now) - if (value == "") { - "${context.getString(R.string.system_default)} ($formattedDate)" - } else { - "$value ($formattedDate)" - } - }.toTypedArray() - - defaultValue = "" - summary = "%s" - } listPreference { key = Keys.themeMode titleRes = R.string.pref_theme_mode @@ -196,5 +146,109 @@ class SettingsGeneralController : SettingsController() { } } } + + preferenceCategory { + titleRes = R.string.pref_category_locale + + listPreference { + key = Keys.lang + titleRes = R.string.pref_language + + val langs = mutableListOf>() + langs += Pair( + "", + "${context.getString(R.string.system_default)} (${LocaleHelper.getDisplayName("")})" + ) + // Due to compatibility issues: + // - Hebrew: `he` is copied into `iw` at build time + langs += arrayOf( + "ar", + "be", + "bg", + "bn", + "ca", + "cs", + "cv", + "de", + "el", + "es", + "es-419", + "en-US", + "en-GB", + "fa", + "fi", + "fil", + "fr", + "he", + "hi", + "hr", + "hu", + "in", + "it", + "ja", + "ka-rGE", + "kn", + "ko", + "lv", + "mr", + "ms", + "nb-rNO", + "nl", + "pl", + "pt", + "pt-BR", + "ro", + "ru", + "sc", + "sk", + "sr", + "sv", + "th", + "tl", + "tr", + "uk", + "ur-rPK", + "vi", + "zh-rCN", + "zh-rTW" + ) + .map { + Pair(it, LocaleHelper.getDisplayName(it)) + } + .sortedBy { it.second } + + entryValues = langs.map { it.first }.toTypedArray() + entries = langs.map { it.second }.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") + + val now = Date().time + entries = entryValues.map { value -> + val formattedDate = preferences.dateFormat(value.toString()).format(now) + if (value == "") { + "${context.getString(R.string.system_default)} ($formattedDate)" + } else { + "$value ($formattedDate)" + } + }.toTypedArray() + + defaultValue = "" + summary = "%s" + } + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1234e75231..9ce29e04c3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -137,6 +137,8 @@ About + Theme + Locale Dark mode Follow system Off