mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:55:11 +01:00
Fix Starting screen summary not showing correct value when using last used
This commit is contained in:
parent
4fb120944c
commit
2c6156c061
@ -21,6 +21,12 @@ class SettingsGeneralController : SettingsController() {
|
||||
intListPreference(activity) {
|
||||
key = Keys.startingTab
|
||||
titleRes = R.string.starting_screen
|
||||
summaryRes = when (preferences.startingTab().get()) {
|
||||
-1 -> R.string.library
|
||||
-2 -> R.string.recents
|
||||
-3 -> R.string.browse
|
||||
else -> R.string.last_used_library_recents
|
||||
}
|
||||
entriesRes = arrayOf(
|
||||
R.string.last_used_library_recents,
|
||||
R.string.library,
|
||||
@ -29,6 +35,25 @@ class SettingsGeneralController : SettingsController() {
|
||||
)
|
||||
entryValues = (0 downTo -3).toList()
|
||||
defaultValue = 0
|
||||
customSelectedValue = when (val value = preferences.startingTab().get()) {
|
||||
in -3..-1 -> value
|
||||
else -> 0
|
||||
}
|
||||
|
||||
onChange { newValue ->
|
||||
summaryRes = when (newValue) {
|
||||
0, 1 -> R.string.last_used_library_recents
|
||||
-1 -> R.string.library
|
||||
-2 -> R.string.recents
|
||||
-3 -> R.string.browse
|
||||
else -> R.string.last_used_library_recents
|
||||
}
|
||||
customSelectedValue = when (newValue) {
|
||||
in -3..-1 -> newValue as Int
|
||||
else -> 0
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
|
@ -24,6 +24,7 @@ class IntListMatPreference @JvmOverloads constructor(
|
||||
set(value) { entries = value.map { context.getString(it) } }
|
||||
private var defValue: Int = 0
|
||||
var entries: List<String> = emptyList()
|
||||
var customSelectedValue: Int? = null
|
||||
|
||||
override fun onSetInitialValue(defaultValue: Any?) {
|
||||
super.onSetInitialValue(defaultValue)
|
||||
@ -37,9 +38,19 @@ class IntListMatPreference @JvmOverloads constructor(
|
||||
else entries[index]
|
||||
}
|
||||
|
||||
override fun setSummary(summaryResId: Int) {
|
||||
super.setSummary(summaryResId)
|
||||
customSummary = summary.toString()
|
||||
}
|
||||
|
||||
override fun setSummary(summary: CharSequence?) {
|
||||
super.setSummary(summary)
|
||||
customSummary = summary?.toString()
|
||||
}
|
||||
|
||||
override fun dialog(): MaterialDialog {
|
||||
return super.dialog().apply {
|
||||
val default = entryValues.indexOf(prefs.getInt(key, defValue).getOrDefault())
|
||||
val default = entryValues.indexOf(customSelectedValue ?: prefs.getInt(key, defValue).getOrDefault())
|
||||
listItemsSingleChoice(
|
||||
items = entries,
|
||||
waitForPositiveButton = false,
|
||||
|
Loading…
Reference in New Issue
Block a user