support: ColorPicker: Hide buttons when the preference is disabled
Change-Id: I855b54e230c0db0968c54bd6b8782dcd3c98ac64
Signed-off-by: Anushek Prasal <anushekprasal@gmail.com>
diff --git a/src/com/bliss/support/colorpicker/ColorPickerPreference.java b/src/com/bliss/support/colorpicker/ColorPickerPreference.java
index a2b97b5..44ba936 100644
--- a/src/com/bliss/support/colorpicker/ColorPickerPreference.java
+++ b/src/com/bliss/support/colorpicker/ColorPickerPreference.java
@@ -110,7 +110,7 @@
if (attrs != null) {
mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", Color.BLACK);
- mShowReset = attrs.getAttributeBooleanValue(SETTINGS_NS, "showReset", false);
+ mShowReset = attrs.getAttributeBooleanValue(SETTINGS_NS, "showReset", true);
mShowPreview = attrs.getAttributeBooleanValue(SETTINGS_NS, "showPreview", true);
mDividerAbove = attrs.getAttributeBooleanValue(SETTINGS_NS, "dividerAbove", false);
mDividerBelow = attrs.getAttributeBooleanValue(SETTINGS_NS, "dividerBelow", false);
@@ -155,7 +155,6 @@
if (!mShowReset || mView == null || mWidgetFrameView == null)
return;
- ImageView defView = new ImageView(getContext());
// remove already created default button
int count = mWidgetFrameView.getChildCount();
if (count > 0) {
@@ -168,6 +167,10 @@
mWidgetFrameView.removeView(spacer);
}
}
+
+ if (!isEnabled()) return;
+
+ ImageView defView = new ImageView(getContext());
mWidgetFrameView.addView(defView);
defView.setImageDrawable(getContext().getDrawable(R.drawable.ic_settings_backup_restore));
defView.setTag("default");
@@ -189,7 +192,6 @@
if (!mShowPreview || mView == null || mWidgetFrameView == null)
return;
- ImageView iView = new ImageView(getContext());
// remove already create preview image
int count = mWidgetFrameView.getChildCount();
if (count > 0) {
@@ -198,6 +200,10 @@
mWidgetFrameView.removeView(preview);
}
}
+
+ if (!isEnabled()) return;
+
+ ImageView iView = new ImageView(getContext());
mWidgetFrameView.addView(iView);
final int size = (int) getContext().getResources().getDimension(R.dimen.oval_notification_size);
final int imageColor = ((mCurrentValue & 0xF0F0F0) == 0xF0F0F0) ?
@@ -207,6 +213,13 @@
}
@Override
+ public void setEnabled (boolean enabled) {
+ super.setEnabled(enabled);
+ setPreviewColor();
+ setDefaultButton();
+ }
+
+ @Override
public void onColorChanged(int color) {
mCurrentValue = color;
setPreviewColor();