minor updates to summaries in library settings

adding support for preSummaryRes for more deceptive summaries with the value
This commit is contained in:
Jays2Kings 2021-08-06 22:43:37 -04:00
parent 430bc10e4e
commit 51ec6d9bf6
4 changed files with 21 additions and 4 deletions

View File

@ -129,7 +129,8 @@ class SettingsLibraryController : SettingsController() {
titleRes = R.string.library_update_restriction titleRes = R.string.library_update_restriction
entriesRes = arrayOf(R.string.wifi, R.string.charging) entriesRes = arrayOf(R.string.wifi, R.string.charging)
entryValues = listOf("wifi", "ac") entryValues = listOf("wifi", "ac")
summaryRes = R.string.library_update_restriction_summary preSummaryRes = R.string.restrictions_
noSelectionRes = R.string.none
preferences.libraryUpdateInterval().asObservable() preferences.libraryUpdateInterval().asObservable()
.subscribeUntilDestroy { isVisible = it > 0 } .subscribeUntilDestroy { isVisible = it > 0 }
@ -158,7 +159,6 @@ class SettingsLibraryController : SettingsController() {
) )
entryRange = 0..1 entryRange = 0..1
defaultValue = 0 defaultValue = 0
summaryRes = R.string.select_order_to_update
} }
triStateListPreference(activity) { triStateListPreference(activity) {

View File

@ -21,6 +21,12 @@ open class MatPreference @JvmOverloads constructor(
Preference(context, attrs) { Preference(context, attrs) {
protected val prefs: PreferencesHelper = Injekt.get() protected val prefs: PreferencesHelper = Injekt.get()
@StringRes var preSummaryRes: Int? = null
set(value) {
field = value
notifyChanged()
}
private var isShowing = false private var isShowing = false
@StringRes var dialogTitleRes: Int? = null @StringRes var dialogTitleRes: Int? = null
@ -41,7 +47,14 @@ open class MatPreference @JvmOverloads constructor(
} }
override fun getSummary(): CharSequence? { override fun getSummary(): CharSequence? {
customSummaryProvider?.let { return it.provideSummary(this) } customSummaryProvider?.let {
val preSummaryRes = preSummaryRes
return if (preSummaryRes != null) {
context.getString(preSummaryRes, it.provideSummary(this))
} else {
it.provideSummary(this)
}
}
return super.getSummary() return super.getSummary()
} }

View File

@ -21,6 +21,7 @@ class MultiListMatPreference @JvmOverloads constructor(
ListMatPreference(activity, context, attrs) { ListMatPreference(activity, context, attrs) {
var allSelectionRes: Int? = null var allSelectionRes: Int? = null
var noSelectionRes: Int? = null
/** All item is always selected and uncheckabele */ /** All item is always selected and uncheckabele */
var allIsAlwaysSelected = false var allIsAlwaysSelected = false
@ -56,6 +57,9 @@ class MultiListMatPreference @JvmOverloads constructor(
allIsAlwaysSelected -> values = values + context.getString(allRes) allIsAlwaysSelected -> values = values + context.getString(allRes)
} }
} }
if (values.isEmpty()) {
noSelectionRes?.let { values = listOf(context.getString(it)) }
}
values.joinToString() values.joinToString()
} }

View File

@ -211,9 +211,9 @@
<!-- Library settings --> <!-- Library settings -->
<string name="library_update_frequency">Library update frequency</string> <string name="library_update_frequency">Library update frequency</string>
<string name="library_update_order">Library update order</string> <string name="library_update_order">Library update order</string>
<string name="select_order_to_update">Select the order in which Tachiyomi checks for update</string>
<string name="library_update_restriction">Library update restrictions</string> <string name="library_update_restriction">Library update restrictions</string>
<string name="library_update_restriction_summary">Update only when the conditions are met</string> <string name="library_update_restriction_summary">Update only when the conditions are met</string>
<string name="restrictions_">Restrictions: %1$s</string>
<string name="only_update_ongoing">Only update ongoing manga</string> <string name="only_update_ongoing">Only update ongoing manga</string>
<string name="sort_by_ignoring_articles">Sort by ignoring articles</string> <string name="sort_by_ignoring_articles">Sort by ignoring articles</string>
<string name="when_sorting_ignore_articles">When sorting alphabetically, sort ignoring <string name="when_sorting_ignore_articles">When sorting alphabetically, sort ignoring