Show selected preference for "Library update order"

This commit is contained in:
arkon 2020-01-11 10:11:30 -05:00
parent 797553ce16
commit ff999a6dda
2 changed files with 22 additions and 14 deletions

View File

@ -114,33 +114,42 @@ class SettingsLibraryController : SettingsController() {
selectedCategories.joinToString { it.name } selectedCategories.joinToString { it.name }
} }
} }
intListPreference{ intListPreference {
key = Keys.libraryUpdatePrioritization key = Keys.libraryUpdatePrioritization
titleRes = R.string.pref_library_update_prioritization 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 // ../../data/library/LibraryUpdateRanker.kt
entriesRes = arrayOf( val priorities = arrayOf(
R.string.action_sort_alpha, Pair("0", R.string.action_sort_alpha),
R.string.action_sort_last_updated Pair("1", R.string.action_sort_last_updated)
) )
entryValues = arrayOf( val defaultPriority = priorities[0]
"0",
"1" entriesRes = priorities.map { it.second }.toTypedArray()
) entryValues = priorities.map { it.first }.toTypedArray()
defaultValue = "0" defaultValue = defaultPriority.first
summaryRes = R.string.pref_library_update_prioritization_summary
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 { intListPreference {
key = Keys.defaultCategory key = Keys.defaultCategory
titleRes = R.string.default_category titleRes = R.string.default_category
val selectedCategory = categories.find { it.id == preferences.defaultCategory() }
entries = arrayOf(context.getString(R.string.default_category_summary)) + entries = arrayOf(context.getString(R.string.default_category_summary)) +
categories.map { it.name }.toTypedArray() categories.map { it.name }.toTypedArray()
entryValues = arrayOf("-1") + categories.map { it.id.toString() }.toTypedArray() entryValues = arrayOf("-1") + categories.map { it.id.toString() }.toTypedArray()
defaultValue = "-1" 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 -> onChange { newValue ->
summary = categories.find { summary = categories.find {
it.id == (newValue as String).toInt() it.id == (newValue as String).toInt()

View File

@ -147,7 +147,6 @@
<string name="pref_library_update_categories">Categories to include in global update</string> <string name="pref_library_update_categories">Categories to include in global update</string>
<string name="all">All</string> <string name="all">All</string>
<string name="pref_library_update_prioritization">Library update order</string> <string name="pref_library_update_prioritization">Library update order</string>
<string name="pref_library_update_prioritization_summary">Select the order in which Tachiyomi checks for update</string>
<string name="pref_library_update_restriction">Library update restrictions</string> <string name="pref_library_update_restriction">Library update restrictions</string>
<string name="pref_library_update_restriction_summary">Update only when the conditions are met</string> <string name="pref_library_update_restriction_summary">Update only when the conditions are met</string>
<string name="wifi">Wi-Fi</string> <string name="wifi">Wi-Fi</string>