Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix(settings): single choice prefs not being dismissed when clicking …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Rafael2616 authored Sep 14, 2023
1 parent 0f81698 commit 0050a5d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/src/main/java/com/itsaky/androidide/preferences/editor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0050a5d

Please sign in to comment.