From ff999a6dda4468f4fc74e978b0d2ced1bc46f36a Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 11 Jan 2020 10:11:30 -0500 Subject: [PATCH] Show selected preference for "Library update order" --- .../ui/setting/SettingsLibraryController.kt | 35 ++++++++++++------- app/src/main/res/values/strings.xml | 1 - 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index eb63229387..59b170e60a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -114,33 +114,42 @@ class SettingsLibraryController : SettingsController() { selectedCategories.joinToString { it.name } } } - intListPreference{ + intListPreference { key = Keys.libraryUpdatePrioritization titleRes = R.string.pref_library_update_prioritization - // The following arrays are to be lined up with the list rankingScheme in: + + // The following array lines up with the list rankingScheme in: // ../../data/library/LibraryUpdateRanker.kt - entriesRes = arrayOf( - R.string.action_sort_alpha, - R.string.action_sort_last_updated + val priorities = arrayOf( + Pair("0", R.string.action_sort_alpha), + Pair("1", R.string.action_sort_last_updated) ) - entryValues = arrayOf( - "0", - "1" - ) - defaultValue = "0" - summaryRes = R.string.pref_library_update_prioritization_summary + val defaultPriority = priorities[0] + + entriesRes = priorities.map { it.second }.toTypedArray() + entryValues = priorities.map { it.first }.toTypedArray() + defaultValue = defaultPriority.first + + val selectedPriority = priorities.find { it.first.toInt() == preferences.libraryUpdatePrioritization().getOrDefault() } + summaryRes = selectedPriority?.second ?: defaultPriority.second + onChange { newValue -> + summaryRes = priorities.find { + it.first == (newValue as String) + }?.second ?: defaultPriority.second + true + } } intListPreference { key = Keys.defaultCategory titleRes = R.string.default_category - val selectedCategory = categories.find { it.id == preferences.defaultCategory() } entries = arrayOf(context.getString(R.string.default_category_summary)) + categories.map { it.name }.toTypedArray() entryValues = arrayOf("-1") + categories.map { it.id.toString() }.toTypedArray() defaultValue = "-1" - summary = selectedCategory?.name ?: context.getString(R.string.default_category_summary) + val selectedCategory = categories.find { it.id == preferences.defaultCategory() } + summary = selectedCategory?.name ?: context.getString(R.string.default_category_summary) onChange { newValue -> summary = categories.find { it.id == (newValue as String).toInt() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fba4d407fa..fd046af0a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,7 +147,6 @@ Categories to include in global update All Library update order - Select the order in which Tachiyomi checks for update Library update restrictions Update only when the conditions are met Wi-Fi