Skip to content
Snippets Groups Projects
Commit d0394f6a authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Correctly handle dismissing a dialog without a preselected color

parent 3c20bb8e
No related branches found
No related tags found
No related merge requests found
...@@ -221,8 +221,8 @@ class Editor( ...@@ -221,8 +221,8 @@ class Editor(
showColorChooser( showColorChooser(
activity, activity,
R.string.label_foreground, R.string.label_foreground,
formatHandler.foregroundColor(chatline.selection) formatHandler.foregroundColor(chatline.selection),
?: formatHandler.defaultForegroundColor formatHandler.defaultForegroundColor
) { color -> ) { color ->
formatHandler.toggleForeground(chatline.selection, color, formatHandler.toggleForeground(chatline.selection, color,
formatHandler.mircColorMap[color]) formatHandler.mircColorMap[color])
...@@ -235,8 +235,8 @@ class Editor( ...@@ -235,8 +235,8 @@ class Editor(
showColorChooser( showColorChooser(
activity, activity,
R.string.label_background, R.string.label_background,
formatHandler.backgroundColor(chatline.selection) formatHandler.backgroundColor(chatline.selection),
?: formatHandler.defaultBackgroundColor formatHandler.defaultBackgroundColor
) { color -> ) { color ->
formatHandler.toggleBackground(chatline.selection, color, formatHandler.toggleBackground(chatline.selection, color,
formatHandler.mircColorMap[color]) formatHandler.mircColorMap[color])
...@@ -287,7 +287,11 @@ class Editor( ...@@ -287,7 +287,11 @@ class Editor(
} }
private fun showColorChooser( private fun showColorChooser(
activity: FragmentActivity, @StringRes title: Int, @ColorInt preselect: Int, f: (Int?) -> Unit activity: FragmentActivity,
@StringRes title: Int,
@ColorInt preselect: Int?,
@ColorInt default: Int,
f: (Int?) -> Unit
) { ) {
var selectedColor: Int? = preselect var selectedColor: Int? = preselect
ColorChooserDialog.Builder(chatline.context, title) ColorChooserDialog.Builder(chatline.context, title)
...@@ -314,7 +318,7 @@ class Editor( ...@@ -314,7 +318,7 @@ class Editor(
.backButton(R.string.label_back) .backButton(R.string.label_back)
.customButton(R.string.label_colors_custom) .customButton(R.string.label_colors_custom)
.presetsButton(R.string.label_colors_mirc) .presetsButton(R.string.label_colors_mirc)
.preselect(preselect) .preselect(preselect ?: default)
.dynamicButtonColor(false) .dynamicButtonColor(false)
.allowUserColorInputAlpha(false) .allowUserColorInputAlpha(false)
.callback(object : ColorChooserDialog.ColorCallback { .callback(object : ColorChooserDialog.ColorCallback {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment