Colorpicker: preserve entered color

pull/212/head
M66B 2 years ago
parent 6aa8dc98ac
commit 3aab01aee3

@ -343,6 +343,17 @@ public class ColorPickerView extends View {
return Utils.adjustAlpha(this.alpha, color); return Utils.adjustAlpha(this.alpha, color);
} }
public int getEnteredColor() {
if (this.colorEdit != null)
try {
return Color.parseColor(this.colorEdit.getText().toString());
} catch (Throwable ex) {
return Color.TRANSPARENT;
}
else
return getSelectedColor();
}
public Integer[] getAllColors() { public Integer[] getAllColors() {
return initialColors; return initialColors;
} }

@ -289,7 +289,7 @@ public class ColorPickerDialogBuilder {
} }
private void positiveButtonOnClick(DialogInterface dialog, ColorPickerClickListener onClickListener) { private void positiveButtonOnClick(DialogInterface dialog, ColorPickerClickListener onClickListener) {
int selectedColor = colorPickerView.getSelectedColor(); int selectedColor = colorPickerView.getEnteredColor();
Integer[] allColors = colorPickerView.getAllColors(); Integer[] allColors = colorPickerView.getAllColors();
onClickListener.onClick(dialog, selectedColor, allColors); onClickListener.onClick(dialog, selectedColor, allColors);
} }

Loading…
Cancel
Save