fix(settings): single choice prefs not being dismissed when clicking outside dialog (#1311)

Some preferences that do not have an "Ok" or "cancel" button forced us to click on the choice again so that the card disappeared

Now the following preferences are dismissable:
- UI Mode (Theme)
- Tab Size
- Empty elements behavior
This commit is contained in:
Rafael de Moura Dev
2023-09-14 15:09:00 -03:00
committed by GitHub
parent 0f81698c97
commit 0050a5dde0
3 changed files with 5 additions and 5 deletions
@@ -165,6 +165,7 @@ private class TabSize(
override val summary: Int? = string.msg_tab_size,
override val icon: Int? = drawable.ic_font_ligatures,
) : SingleChoicePreference() {
override val dialogCancellable = true
@IgnoredOnParcel private val choices = arrayOf("2", "4", "6", "8")
@@ -196,6 +197,7 @@ private class ColorSchemePreference(
override val summary: Int? = R.string.idepref_editor_colorScheme_summary,
override val icon: Int? = R.drawable.ic_color_scheme
) : SingleChoicePreference() {
override val dialogCancellable = true
@IgnoredOnParcel private val schemes = IDEColorSchemeProvider.list()
@@ -212,11 +214,6 @@ private class ColorSchemePreference(
colorScheme = schemes[position].key
}
}
override fun onConfigureDialog(preference: Preference, dialog: MaterialAlertDialogBuilder) {
super.onConfigureDialog(preference, dialog)
dialog.setCancelable(true)
}
}
@Parcelize
@@ -91,6 +91,8 @@ class UiMode(
override val summary: Int? = R.string.idepref_general_uiMode_summary,
override val icon: Int? = R.drawable.ic_ui_mode
) : SingleChoicePreference() {
override val dialogCancellable = true
override fun getChoices(context: Context): Array<String> {
return arrayOf(
context.getString(R.string.uiMode_light),
@@ -225,6 +225,7 @@ private class EmptyElementsBehavior(
override val title: Int = string.idepref_emptyElements_title,
override val summary: Int? = string.idepref_emptyElements_summary
) : SingleChoicePreference() {
override val dialogCancellable = true
override fun getSelectedItem(): Int {
return EmptyElements.valueOf(emptyElementsBehavior).ordinal