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 6b19f4b09b..859c81f8db 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 @@ -129,7 +129,8 @@ class SettingsLibraryController : SettingsController() { titleRes = R.string.library_update_restriction entriesRes = arrayOf(R.string.wifi, R.string.charging) entryValues = listOf("wifi", "ac") - summaryRes = R.string.library_update_restriction_summary + preSummaryRes = R.string.restrictions_ + noSelectionRes = R.string.none preferences.libraryUpdateInterval().asObservable() .subscribeUntilDestroy { isVisible = it > 0 } @@ -158,7 +159,6 @@ class SettingsLibraryController : SettingsController() { ) entryRange = 0..1 defaultValue = 0 - summaryRes = R.string.select_order_to_update } triStateListPreference(activity) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MatPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MatPreference.kt index 66dcd7cae1..bd3cf315e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MatPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MatPreference.kt @@ -21,6 +21,12 @@ open class MatPreference @JvmOverloads constructor( Preference(context, attrs) { protected val prefs: PreferencesHelper = Injekt.get() + + @StringRes var preSummaryRes: Int? = null + set(value) { + field = value + notifyChanged() + } private var isShowing = false @StringRes var dialogTitleRes: Int? = null @@ -41,7 +47,14 @@ open class MatPreference @JvmOverloads constructor( } 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() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt index db50e747fc..f9b69f9d3d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/MultiListMatPreference.kt @@ -21,6 +21,7 @@ class MultiListMatPreference @JvmOverloads constructor( ListMatPreference(activity, context, attrs) { var allSelectionRes: Int? = null + var noSelectionRes: Int? = null /** All item is always selected and uncheckabele */ var allIsAlwaysSelected = false @@ -56,6 +57,9 @@ class MultiListMatPreference @JvmOverloads constructor( allIsAlwaysSelected -> values = values + context.getString(allRes) } } + if (values.isEmpty()) { + noSelectionRes?.let { values = listOf(context.getString(it)) } + } values.joinToString() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9df092bffb..0f14206b6d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -211,9 +211,9 @@ Library update frequency Library update order - Select the order in which Tachiyomi checks for update Library update restrictions Update only when the conditions are met + Restrictions: %1$s Only update ongoing manga Sort by ignoring articles When sorting alphabetically, sort ignoring