Bug 1405973 - Add white to basic colour picker. r?jwu
MozReview-Commit-ID: 4Cfxrj8SYGQ
--- a/mobile/android/base/java/org/mozilla/gecko/widget/BasicColorPicker.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/BasicColorPicker.java
@@ -35,17 +35,18 @@ public class BasicColorPicker extends Li
Color.rgb(255, 134, 5),
Color.rgb(255, 203, 19),
Color.rgb(95, 173, 71),
Color.rgb(84, 201, 168),
Color.rgb(33, 161, 222),
Color.rgb(16, 36, 87),
Color.rgb(91, 32, 103),
Color.rgb(212, 221, 228),
- Color.BLACK);
+ Color.BLACK,
+ Color.WHITE);
private static Drawable mCheckDrawable;
int mSelected;
final ColorPickerListAdapter mAdapter;
public BasicColorPicker(Context context) {
this(context, null);
}
@@ -83,17 +84,17 @@ public class BasicColorPicker extends Li
} else {
mSelected = DEFAULT_COLORS.indexOf(color);
}
setSelection(mSelected);
mAdapter.notifyDataSetChanged();
}
- Drawable getCheckDrawable() {
+ private Drawable getCheckDrawable() {
if (mCheckDrawable == null) {
Resources res = getContext().getResources();
TypedValue typedValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.listPreferredItemHeight, typedValue, true);
DisplayMetrics metrics = new android.util.DisplayMetrics();
((WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
int height = (int) typedValue.getDimension(metrics);
@@ -125,16 +126,21 @@ public class BasicColorPicker extends Li
Drawable d = v.getBackground();
d.setColorFilter(getItem(position), PorterDuff.Mode.MULTIPLY);
v.setBackgroundDrawable(d);
Drawable check = null;
CheckedTextView checked = ((CheckedTextView) v);
if (mSelected == position) {
check = getCheckDrawable();
+ if (getItem(position) == Color.WHITE) {
+ check.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
+ } else {
+ check.clearColorFilter();
+ }
}
TextViewCompat.setCompoundDrawablesRelative(checked, check, null, null, null);
checked.setText("");
return v;
}
}