Add on/off content for checkbox
This commit is contained in:
@@ -203,6 +203,7 @@ class UserPreferences(context: Context) : SharedPreferenceStore(
|
||||
})
|
||||
}
|
||||
|
||||
// Change audio delay type from long to int
|
||||
migration(toVersion = 4) {
|
||||
putInt("libvlc_audio_delay", it.getLong("libvlc_audio_delay", 0).toInt())
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import org.jellyfin.androidtv.preferences.ui.dsl.EnumDisplayOptions
|
||||
|
||||
enum class GridDirection {
|
||||
/**
|
||||
* Horizontal
|
||||
* Horizontal.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.grid_direction_horizontal)
|
||||
HORIZONTAL,
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
* Vertical.
|
||||
*/
|
||||
@EnumDisplayOptions(R.string.grid_direction_vertical)
|
||||
VERTICAL
|
||||
|
||||
@@ -12,20 +12,20 @@ fun OptionsScreen.crashReportingCategory(
|
||||
|
||||
checkbox {
|
||||
setTitle(R.string.pref_enable_acra)
|
||||
// setContent(R.string.pref_acra_enabled, R.string.pref_acra_disabled)
|
||||
setContent(R.string.pref_acra_enabled, R.string.pref_acra_disabled)
|
||||
bind(userPreferences, UserPreferences.acraEnabled)
|
||||
}
|
||||
|
||||
checkbox {
|
||||
setTitle(R.string.pref_acra_alwaysaccept)
|
||||
// setContent(R.string.pref_acra_alwaysaccept_enabled, R.string.pref_acra_alwaysaccept_disabled)
|
||||
setContent(R.string.pref_acra_alwaysaccept_enabled, R.string.pref_acra_alwaysaccept_disabled)
|
||||
bind(userPreferences, UserPreferences.acraNoPrompt)
|
||||
depends { userPreferences[UserPreferences.acraEnabled] }
|
||||
}
|
||||
|
||||
checkbox {
|
||||
setTitle(R.string.pref_acra_syslog)
|
||||
// setContent(R.string.pref_acra_syslog_enabled, R.string.pref_acra_syslog_disabled)
|
||||
setContent(R.string.pref_acra_syslog_enabled, R.string.pref_acra_syslog_disabled)
|
||||
bind(userPreferences, UserPreferences.acraIncludeSystemLogs)
|
||||
depends { userPreferences[UserPreferences.acraEnabled] }
|
||||
}
|
||||
|
||||
@@ -15,17 +15,24 @@ class OptionsItemCheckbox(
|
||||
SWITCH
|
||||
}
|
||||
|
||||
var content: String? = null
|
||||
var contentOn: String? = null
|
||||
var contentOff: String? = null
|
||||
var type: Type = Type.CHECKBOX
|
||||
|
||||
fun setTitle(@StringRes resId: Int) {
|
||||
title = context.getString(resId)
|
||||
}
|
||||
|
||||
fun setContent(@StringRes resId: Int) {
|
||||
content = context.getString(resId)
|
||||
fun setContent(@StringRes resIdOn: Int, @StringRes resIdOff: Int) {
|
||||
contentOn = context.getString(resIdOn)
|
||||
contentOff = context.getString(resIdOff)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content that will always show. The checked state does not matter,
|
||||
*/
|
||||
fun setContent(@StringRes resId: Int) = setContent(resId, resId)
|
||||
|
||||
override fun build(category: PreferenceCategory, container: OptionsUpdateFunContainer) {
|
||||
val pref = when (type) {
|
||||
Type.CHECKBOX -> CheckBoxPreference(context)
|
||||
@@ -37,7 +44,8 @@ class OptionsItemCheckbox(
|
||||
it.isEnabled = dependencyCheckFun() && enabled
|
||||
it.isVisible = visible
|
||||
it.title = title
|
||||
it.summary = content
|
||||
it.summaryOn = contentOn
|
||||
it.summaryOff = contentOff
|
||||
it.isChecked = binder.get()
|
||||
it.setOnPreferenceChangeListener { _, newValue ->
|
||||
binder.set(newValue as Boolean)
|
||||
|
||||
@@ -23,7 +23,7 @@ class OptionsScreen(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create androidx PreferenceScreen instance
|
||||
* Create androidx PreferenceScreen instance.
|
||||
*/
|
||||
fun build(preferenceManager: PreferenceManager): PreferenceScreen {
|
||||
val container = OptionsUpdateFunContainer()
|
||||
|
||||
Reference in New Issue
Block a user