Color Picker: don't show picker on click if preference is disabled
Change-Id: Ifd5d35f4a11f8e0422e1671b99ba41a9faf1510b
diff --git a/src/com/dirtyunicorns/support/colorpicker/ColorPickerPreference.java b/src/com/dirtyunicorns/support/colorpicker/ColorPickerPreference.java
index 67815f7..40a1328 100644
--- a/src/com/dirtyunicorns/support/colorpicker/ColorPickerPreference.java
+++ b/src/com/dirtyunicorns/support/colorpicker/ColorPickerPreference.java
@@ -49,6 +49,7 @@
private int mValue = Color.BLACK;
private float mDensity = 0;
private boolean mAlphaSliderEnabled = false;
+ private boolean mEnabled = true;
// if we return -6, button is not enabled
static final String SETTINGS_NS = "http://schemas.android.com/apk/res/com.android.settings";
@@ -205,11 +206,21 @@
iView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- showDialog(null);
+ if (mEnabled) {
+ showDialog(null);
+ }
}
});
}
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if (mEnabled != enabled) {
+ mEnabled = enabled;
+ }
+ }
+
private Bitmap getPreviewBitmap() {
int d = (int) (mDensity * 31); // 30dip
int color = mValue;