Color Picker: use oval preview

This brings the color picker preview inline with the LED. If we're going
to keep the color picker thing around, lets at least make it uniform

Change-Id: Icc7d9d57c6ca0ceb20dd2ebbc5678f08988f9ddb
diff --git a/src/com/bliss/support/colorpicker/ColorPickerPreference.java b/src/com/bliss/support/colorpicker/ColorPickerPreference.java
index ea61502..aaef939 100644
--- a/src/com/bliss/support/colorpicker/ColorPickerPreference.java
+++ b/src/com/bliss/support/colorpicker/ColorPickerPreference.java
@@ -23,6 +23,8 @@
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.Color;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.shapes.OvalShape;
 import android.os.Bundle;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -203,8 +205,10 @@
         }
         widgetFrameView.addView(iView);
         widgetFrameView.setMinimumWidth(0);
-        iView.setBackgroundDrawable(new AlphaPatternDrawable((int) (5 * mDensity)));
-        iView.setImageBitmap(getPreviewBitmap());
+        final int size = (int) getContext().getResources().getDimension(R.dimen.oval_notification_size);
+        final int imageColor = ((mValue & 0xF0F0F0) == 0xF0F0F0) ?
+                (mValue - 0x101010) : mValue;
+        iView.setImageDrawable(createOvalShape(size, 0xFF000000 + imageColor));
         iView.setTag("preview");
         iView.setOnClickListener(new View.OnClickListener() {
             @Override
@@ -224,26 +228,6 @@
         }
     }
 
-    private Bitmap getPreviewBitmap() {
-        int d = (int) (mDensity * 31); // 30dip
-        int color = mValue;
-        Bitmap bm = Bitmap.createBitmap(d, d, Config.ARGB_8888);
-        int w = bm.getWidth();
-        int h = bm.getHeight();
-        int c = color;
-        for (int i = 0; i < w; i++) {
-            for (int j = i; j < h; j++) {
-                c = (i <= 1 || j <= 1 || i >= w - 2 || j >= h - 2) ? Color.GRAY : color;
-                bm.setPixel(i, j, c);
-                if (i != j) {
-                    bm.setPixel(j, i, c);
-                }
-            }
-        }
-
-        return bm;
-    }
-
     @Override
     public void onColorChanged(int color) {
         if (isPersistent()) {
@@ -421,4 +405,12 @@
             }
         };
     }
+
+    private static ShapeDrawable createOvalShape(int size, int color) {
+        ShapeDrawable shape = new ShapeDrawable(new OvalShape());
+        shape.setIntrinsicHeight(size);
+        shape.setIntrinsicWidth(size);
+        shape.getPaint().setColor(color);
+        return shape;
+    }
 }