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

Improve color selection dialog

parent 573a6e42
No related branches found
No related tags found
No related merge requests found
......@@ -289,7 +289,7 @@ class Editor(
private fun showColorChooser(
activity: FragmentActivity, @StringRes title: Int, @ColorInt preselect: Int, f: (Int?) -> Unit
) {
var selectedColor: Int? = null
var selectedColor: Int? = preselect
ColorChooserDialog.Builder(chatline.context, title)
.customColors(intArrayOf(
formatHandler.mircColors[0],
......@@ -318,6 +318,10 @@ class Editor(
.dynamicButtonColor(false)
.allowUserColorInputAlpha(false)
.callback(object : ColorChooserDialog.ColorCallback {
override fun onColorReset(dialog: ColorChooserDialog) {
selectedColor = null
}
override fun onColorSelection(dialog: ColorChooserDialog, color: Int) {
selectedColor = color
}
......
......@@ -341,6 +341,7 @@ public class ColorChooserDialog extends DialogFragment
subIndex(-1); // Do this to avoid ArrayIndexOutOfBoundsException
invalidate();
} else {
builder.callback.onColorReset(ColorChooserDialog.this);
dialog.cancel();
}
}
......@@ -574,6 +575,7 @@ public class ColorChooserDialog extends DialogFragment
}
public interface ColorCallback {
void onColorReset(@NonNull ColorChooserDialog dialog);
void onColorSelection(@NonNull ColorChooserDialog dialog, @ColorInt int selectedColor);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment