diff --git a/res/drawable/ic_action_set.xml b/res/drawable/ic_action_set.xml
new file mode 100644
index 0000000..533bd31
--- /dev/null
+++ b/res/drawable/ic_action_set.xml
@@ -0,0 +1,33 @@
+<!--  Copyright (C) 2014-2016 The Dirty Unicorns Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="32.000000dp"
+    android:height="32.000000dp"
+    android:viewportWidth="96.000000"
+    android:viewportHeight="96.000000"
+    android:tint="?android:attr/colorAccent">
+
+    <group
+        android:translateY="96.000000"
+        android:scaleX="0.100000"
+        android:scaleY="-0.100000">
+        <path
+            android:fillColor="#FFFFFFFF"
+            android:strokeWidth="1"
+            android:pathData="M567 562 l-187 -187 -98 98 -98 97 -42 -43 -42 -43 139 -138 138 -138 232 227 c127
+125 231 230 230 234 0 3 -20 23 -43 43 l-42 37 -187 -187z" />
+    </group>
+</vector>
diff --git a/res/layout-land/preference_color_picker.xml b/res/layout-land/preference_color_picker.xml
index 5168a44..7ec2ea5 100644
--- a/res/layout-land/preference_color_picker.xml
+++ b/res/layout-land/preference_color_picker.xml
@@ -19,48 +19,105 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:layout_marginStart="36dp"
-    android:layout_marginEnd="36dp"
-    android:padding="20dp"
+    android:paddingLeft="5dp"
+    android:paddingRight="5dp"
     android:orientation="horizontal">
 
     <com.bliss.support.colorpicker.ColorPickerView
         android:id="@+id/color_picker_view"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
         android:tag="landscape" />
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:layout_marginTop="6dp"
         android:layout_marginBottom="6dp"
-        android:layout_marginTop="3dp"
         android:gravity="center"
         android:orientation="vertical">
 
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginTop="6dp"
             android:layout_marginBottom="6dp"
-            android:layout_marginTop="3dp"
             android:gravity="center"
             android:orientation="horizontal">
 
             <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:layout_marginEnd="10dp"
                 android:text="@string/hex"
-                android:textSize="20sp" />
+                android:textSize="20sp"
+                android:layout_marginRight="10dp" />
 
             <EditText
                 android:id="@+id/hex"
+                android:hint="@string/hex_hint"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content" />
+
+            <ImageButton
+                android:id="@+id/enter"
+                android:src="@drawable/ic_action_set"
+                android:background="@android:color/transparent"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:inputType="text"
-                android:maxLines="1"
-                android:maxLength="7"
-                android:hint="@string/hex_hint" />
+                android:layout_marginLeft="10dp"
+                android:gravity="center" />
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="wrap_content"
+            android:layout_height="30dp"
+            android:orientation="horizontal"
+            android:layout_marginLeft="7dp"
+            android:layout_marginRight="7dp"
+            android:layout_marginTop="2dp">
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/white_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="6dp"
+                android:layout_weight="0.5" />
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/black_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="6dp"
+                android:layout_weight="0.5" />
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/cyan_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="6dp"
+                android:layout_weight="0.5" />
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/red_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="6dp"
+                android:layout_weight="0.5" />
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/green_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="6dp"
+                android:layout_weight="0.5" />
+
+            <com.bliss.support.colorpicker.ColorPickerPanelView
+                android:id="@+id/yellow_panel"
+                android:layout_width="0px"
+                android:layout_height="wrap_content"
+                android:layout_weight="0.5" />
 
         </LinearLayout>
 
@@ -69,8 +126,8 @@
             android:layout_height="wrap_content"
             android:text="@string/press_color_to_apply"
             android:gravity="center"
-            android:layout_marginTop="10dp"
-            android:layout_marginBottom="10dp"
+            android:layout_marginTop="20dp"
+            android:layout_marginBottom="5dp"
             android:textAppearance="?android:attr/textAppearanceSmall" />
 
         <LinearLayout
@@ -99,6 +156,7 @@
                 android:layout_width="0px"
                 android:layout_height="wrap_content"
                 android:layout_weight="0.5" />
+
         </LinearLayout>
 
     </LinearLayout>
diff --git a/res/layout/preference_color_picker.xml b/res/layout/preference_color_picker.xml
deleted file mode 100644
index d6f2498..0000000
--- a/res/layout/preference_color_picker.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 Daniel Nilsson
-     Copyright (C) 2013 Slimroms
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_marginStart="36dp"
-    android:layout_marginEnd="36dp"
-    android:padding="20dp"
-    android:orientation="vertical">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="6dp"
-        android:layout_marginTop="3dp"
-        android:gravity="center"
-        android:orientation="horizontal">
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginEnd="10dp"
-            android:text="@string/hex"
-            android:textSize="20sp" />
-
-        <EditText
-            android:id="@+id/hex"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:inputType="text"
-            android:maxLines="1"
-            android:maxLength="7"
-            android:hint="@string/hex_hint" />
-
-    </LinearLayout>
-
-    <com.bliss.support.colorpicker.ColorPickerView
-        android:id="@+id/color_picker_view"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:tag="portrait" />
-
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:text="@string/press_color_to_apply"
-        android:gravity="center"
-        android:layout_marginTop="10dp"
-        android:layout_marginBottom="10dp"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
-
-    <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="40dp"
-        android:orientation="horizontal"
-        android:layout_marginBottom="10dp">
-
-        <com.bliss.support.colorpicker.ColorPickerPanelView
-            android:id="@+id/old_color_panel"
-            android:layout_width="0px"
-            android:layout_height="fill_parent"
-            android:layout_weight="0.5" />
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="fill_parent"
-            android:text="@string/arrow_right"
-            android:textSize="20sp"
-            android:gravity="center"
-            android:layout_marginLeft="10dp"
-            android:layout_marginRight="10dp" />
-
-        <com.bliss.support.colorpicker.ColorPickerPanelView
-            android:id="@+id/new_color_panel"
-            android:layout_width="0px"
-            android:layout_height="wrap_content"
-            android:layout_weight="0.5" />
-
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 0fdaf59..91903c2 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Dirty Unicorns Project
+<!-- Copyright (C) 2017 The Dirty Unicorns Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -24,15 +24,6 @@
         <attr name="continuousUpdates" format="boolean" />
     </declare-styleable>
 
-    <!-- Value to pass to callback when restore button is pressed -->
-    <declare-styleable name="ColorPickerPreference">
-        <attr name="alphaSlider" format="boolean" />
-        <attr name="showPreview" format="boolean" />
-        <attr name="showReset" format="boolean" />
-        <attr name="dividerAbove" format="boolean" />
-        <attr name="dividerBelow" format="boolean" />
-    </declare-styleable>
-
     <!-- Color Blend -->
     <declare-styleable name="ColorBlendPreference">
         <!-- Preference keys -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 99f4c49..0b74af8 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -16,9 +16,6 @@
 
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
 
-    <!-- Color Picker -->
-    <dimen name="oval_notification_size">26dp</dimen>
-
     <!-- Color Blend -->
     <dimen name="color_blend_preview_size">36dp</dimen>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a82ec8c..0a0cb14 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,15 +16,6 @@
 
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
 
-    <!-- Color Picker -->
-    <string name="dialog_color_picker">Color Picker</string>
-    <string name="press_color_to_apply">Press on color below to apply</string>
-    <string name="arrow_right">→</string>
-    <string name="arrow_down">↓</string>
-    <string name="hex">Hex:</string>
-    <string name="hex_hint">#ff000000</string>
-    <string name="set">Set</string>
-    <string name="color_default">Default</string>
 
     <!-- Custom seekbar -->
     <string name="custom_seekbar_value">Value: <xliff:g id="v">%s</xliff:g></string>
diff --git a/src/com/bliss/support/colorpicker/AlphaPatternDrawable.java b/src/com/bliss/support/colorpicker/AlphaPatternDrawable.java
deleted file mode 100644
index 3649b5f..0000000
--- a/src/com/bliss/support/colorpicker/AlphaPatternDrawable.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2010 Daniel Nilsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.Canvas;
-import android.graphics.ColorFilter;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-
-/**
- * This drawable that draws a simple white and gray chessboard pattern.
- * It's pattern you will often see as a background behind a
- * partly transparent image in many applications.
- * @author Daniel Nilsson
- */
-public class AlphaPatternDrawable extends Drawable {
-
-    private int mRectangleSize = 10;
-
-    private Paint mPaint = new Paint();
-    private Paint mPaintWhite = new Paint();
-    private Paint mPaintGray = new Paint();
-
-    private int numRectanglesHorizontal;
-    private int numRectanglesVertical;
-
-    /**
-     * Bitmap in which the pattern will be cahched.
-     */
-    private Bitmap        mBitmap;
-
-    public AlphaPatternDrawable(int rectangleSize) {
-        mRectangleSize = rectangleSize;
-        mPaintWhite.setColor(0xffffffff);
-        mPaintGray.setColor(0xffcbcbcb);
-    }
-
-    @Override
-    public void draw(Canvas canvas) {
-        if (mBitmap != null) {
-            canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
-        }
-    }
-
-    @Override
-    public int getOpacity() {
-        return 0;
-    }
-
-    @Override
-    public void setAlpha(int alpha) {
-        throw new UnsupportedOperationException("Alpha is not supported by this drawwable.");
-    }
-
-    @Override
-    public void setColorFilter(ColorFilter cf) {
-        throw new UnsupportedOperationException("ColorFilter is not supported by this drawwable.");
-    }
-
-    @Override
-    protected void onBoundsChange(Rect bounds) {
-        super.onBoundsChange(bounds);
-
-        int height = bounds.height();
-        int width = bounds.width();
-
-        numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
-        numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
-
-        generatePatternBitmap();
-
-    }
-
-    /**
-     * This will generate a bitmap with the pattern
-     * as big as the rectangle we were allow to draw on.
-     * We do this to chache the bitmap so we don't need to
-     * recreate it each time draw() is called since it
-     * takes a few milliseconds.
-     */
-    private void generatePatternBitmap(){
-
-        if(getBounds().width() <= 0 || getBounds().height() <= 0){
-            return;
-        }
-
-        mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
-        Canvas canvas = new Canvas(mBitmap);
-
-        Rect r = new Rect();
-        boolean verticalStartWhite = true;
-        for (int i = 0; i <= numRectanglesVertical; i++) {
-
-            boolean isWhite = verticalStartWhite;
-            for (int j = 0; j <= numRectanglesHorizontal; j++) {
-
-                r.top = i * mRectangleSize;
-                r.left = j * mRectangleSize;
-                r.bottom = r.top + mRectangleSize;
-                r.right = r.left + mRectangleSize;
-
-                canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
-
-                isWhite = !isWhite;
-            }
-
-            verticalStartWhite = !verticalStartWhite;
-
-        }
-
-    }
-
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerDialog.java b/src/com/bliss/support/colorpicker/ColorPickerDialog.java
deleted file mode 100644
index 395e36e..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerDialog.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2010 Daniel Nilsson
- * Copyright (C) 2013 Slimroms
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.graphics.PixelFormat;
-import android.os.Bundle;
-import androidx.annotation.NonNull;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.Window;
-import android.widget.EditText;
-import android.view.KeyEvent;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-
-import com.bliss.support.R;
-
-public class ColorPickerDialog extends AlertDialog implements ColorPickerView.OnColorChangedListener, View.OnClickListener, View.OnKeyListener {
-
-    private ColorPickerView mColorPicker;
-    private ColorPickerPanelView mOldColor;
-    private ColorPickerPanelView mNewColor;
-    private EditText mHex;
-
-    private OnColorChangedListener mListener;
-
-    public interface OnColorChangedListener {
-        void onColorChanged(int color);
-    }
-
-    public ColorPickerDialog(Context context, int initialColor) {
-        super(context);
-
-        init(initialColor);
-    }
-
-    private void init(int color) {
-        if (getWindow() != null) {
-            getWindow().setFormat(PixelFormat.RGBA_8888);
-            requestWindowFeature(Window.FEATURE_NO_TITLE);
-            setUp(color);
-        }
-    }
-
-    private void setColorFromHex() {
-        String text = mHex.getText().toString();
-        try {
-            int newColor = ColorPickerPreference.convertToColorInt(text);
-            mColorPicker.setColor(newColor, true);
-        } catch (Exception ignored) {
-        }
-    }
-
-    private void setUp(int color) {
-
-        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-
-        assert inflater != null;
-        View layout = inflater.inflate(R.layout.preference_color_picker, null);
-
-        mColorPicker = layout.findViewById(R.id.color_picker_view);
-        mOldColor = layout.findViewById(R.id.old_color_panel);
-        mNewColor = layout.findViewById(R.id.new_color_panel);
-
-        mHex = layout.findViewById(R.id.hex);
-
-        ((LinearLayout) mOldColor.getParent()).setPadding(Math.round(mColorPicker.getDrawingOffset()),
-                0, Math.round(mColorPicker.getDrawingOffset()), 0);
-
-        mOldColor.setOnClickListener(this);
-        mNewColor.setOnClickListener(this);
-        mColorPicker.setOnColorChangedListener(this);
-        mOldColor.setColor(color);
-        mColorPicker.setColor(color, true);
-
-        if (mHex != null) {
-            mHex.setText(ColorPickerPreference.convertToRGB(color));
-            mHex.setOnKeyListener(this);
-        }
-
-        setView(layout);
-    }
-
-    @Override
-    public void onColorChanged(int color) {
-
-        mNewColor.setColor(color);
-        try {
-            if (mHex != null) {
-                mHex.setText(ColorPickerPreference.convertToRGB(color));
-            }
-        } catch (Exception ignored) {
-        }
-    }
-
-    void setAlphaSliderVisible(boolean visible) {
-        mColorPicker.setAlphaSliderVisible(visible);
-    }
-
-    /**
-     * Set a OnColorChangedListener to get notified when the color selected by the user has changed.
-     *
-     * @param listener
-     */
-    public void setOnColorChangedListener(OnColorChangedListener listener) {
-        mListener = listener;
-    }
-
-    public int getColor() {
-        return mColorPicker.getColor();
-    }
-
-    @Override
-    public boolean onKey(View v, int keyCode, KeyEvent event) {
-        if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
-                    (keyCode == KeyEvent.KEYCODE_ENTER)) {
-            setColorFromHex();
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void onClick(View v) {
-        if (v.getId() == R.id.new_color_panel) {
-            if (mListener != null) {
-                mListener.onColorChanged(mNewColor.getColor());
-            }
-        }
-        dismiss();
-    }
-
-    @NonNull
-    @Override
-    public Bundle onSaveInstanceState() {
-        Bundle state = super.onSaveInstanceState();
-        state.putInt("old_color", mOldColor.getColor());
-        state.putInt("new_color", mNewColor.getColor());
-        dismiss();
-        return state;
-    }
-
-    @Override
-    public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
-        super.onRestoreInstanceState(savedInstanceState);
-        mOldColor.setColor(savedInstanceState.getInt("old_color"));
-        mColorPicker.setColor(savedInstanceState.getInt("new_color"), true);
-    }
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerPanelView.java b/src/com/bliss/support/colorpicker/ColorPickerPanelView.java
deleted file mode 100644
index aa6311d..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerPanelView.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2010 Daniel Nilsson
- * Copyright (C) 2013 Slimroms
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.RectF;
-import android.util.AttributeSet;
-import android.view.View;
-
-/**
- * This class draws a panel which which will be filled with a color which can be set.
- * It can be used to show the currently selected color which you will get from
- * the {@link ColorPickerView}.
- * @author Daniel Nilsson
- *
- */
-public class ColorPickerPanelView extends View {
-
-    /**
-     * The width in pixels of the border
-     * surrounding the color panel.
-     */
-    private final static float    BORDER_WIDTH_PX = 1;
-
-    private static float mDensity = 1f;
-
-    private int         mBorderColor = 0xff6E6E6E;
-    private int         mColor = 0xff000000;
-
-    private Paint        mBorderPaint;
-    private Paint        mColorPaint;
-
-    private RectF        mDrawingRect;
-    private RectF        mColorRect;
-
-    private AlphaPatternDrawable mAlphaPattern;
-
-
-    public ColorPickerPanelView(Context context){
-        this(context, null);
-    }
-
-    public ColorPickerPanelView(Context context, AttributeSet attrs){
-        this(context, attrs, 0);
-    }
-
-    public ColorPickerPanelView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-        init();
-    }
-
-    private void init(){
-        mBorderPaint = new Paint();
-        mColorPaint = new Paint();
-        mDensity = getContext().getResources().getDisplayMetrics().density;
-    }
-
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-
-        final RectF    rect = mColorRect;
-
-        if(BORDER_WIDTH_PX > 0){
-            mBorderPaint.setColor(mBorderColor);
-            canvas.drawRect(mDrawingRect, mBorderPaint);
-        }
-
-        if(mAlphaPattern != null){
-            mAlphaPattern.draw(canvas);
-        }
-
-        mColorPaint.setColor(mColor);
-
-        canvas.drawRect(rect, mColorPaint);
-    }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-
-        int width = MeasureSpec.getSize(widthMeasureSpec);
-        int height = MeasureSpec.getSize(heightMeasureSpec);
-
-        setMeasuredDimension(width, height);
-    }
-
-    @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        super.onSizeChanged(w, h, oldw, oldh);
-
-        mDrawingRect = new RectF();
-        mDrawingRect.left =  getPaddingLeft();
-        mDrawingRect.right  = w - getPaddingRight();
-        mDrawingRect.top = getPaddingTop();
-        mDrawingRect.bottom = h - getPaddingBottom();
-
-        setUpColorRect();
-
-    }
-
-    private void setUpColorRect(){
-        final RectF    dRect = mDrawingRect;
-
-        float left = dRect.left + BORDER_WIDTH_PX;
-        float top = dRect.top + BORDER_WIDTH_PX;
-        float bottom = dRect.bottom - BORDER_WIDTH_PX;
-        float right = dRect.right - BORDER_WIDTH_PX;
-
-        mColorRect = new RectF(left,top, right, bottom);
-
-        mAlphaPattern = new AlphaPatternDrawable((int)(5 * mDensity));
-
-        mAlphaPattern.setBounds(
-            Math.round(mColorRect.left),
-            Math.round(mColorRect.top),
-            Math.round(mColorRect.right),
-            Math.round(mColorRect.bottom)
-        );
-
-    }
-
-    /**
-     * Set the color that should be shown by this view.
-     * @param color
-     */
-    public void setColor(int color){
-        mColor = color;
-        invalidate();
-    }
-
-    /**
-     * Get the color currently show by this view.
-     * @return
-     */
-    public int getColor(){
-        return mColor;
-    }
-
-    /**
-     * Set the color of the border surrounding the panel.
-     * @param color
-     */
-    public void setBorderColor(int color){
-        mBorderColor = color;
-        invalidate();
-    }
-
-    /**
-     * Get the color of the border surrounding the panel.
-     */
-    public int getBorderColor(){
-        return mBorderColor;
-    }
-
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerPreference.java b/src/com/bliss/support/colorpicker/ColorPickerPreference.java
deleted file mode 100644
index 44ba936..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerPreference.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright (C) 2011 Sergey Margaritov
- * Copyright (C) 2013 Slimroms
- * Copyright (C) 2015 The TeamEos Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-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;
-import androidx.preference.*;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.WindowManager;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-
-import com.bliss.support.R;
-
-/**
- * A preference type that allows a user to choose a time
- *
- * @author Sergey Margaritov
- */
-public class ColorPickerPreference extends Preference implements
-        Preference.OnPreferenceClickListener, ColorPickerDialog.OnColorChangedListener {
-
-    private static final String ANDROIDNS = "http://schemas.android.com/apk/res/android";
-    private static final String SETTINGS_NS = "http://schemas.android.com/apk/res/com.android.settings";
-
-    PreferenceViewHolder mView;
-    LinearLayout mWidgetFrameView;
-    ColorPickerDialog mDialog;
-    private int mDefaultValue = Color.BLACK;
-    private int mCurrentValue = mDefaultValue;
-    private float mDensity = 0;
-    private boolean mAlphaSliderEnabled = false;
-    private boolean mIsLedColorPicker;
-    private boolean mShowLedPreview;
-    private boolean mShowReset;
-    private boolean mShowPreview;
-    private boolean mDividerAbove;
-    private boolean mDividerBelow;
-    private EditText mEditText;
-
-    //private boolean mIsCrappyLedDevice;
-
-    public ColorPickerPreference(Context context, AttributeSet attrs, int defStyleAttr) {
-        this(context, attrs, defStyleAttr, 0);
-    }
-
-    public ColorPickerPreference(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public ColorPickerPreference(Context context) {
-        this(context, null);
-    }
-
-    public ColorPickerPreference(Context context, AttributeSet attrs, int defStyleAttr,
-            int defStyleRes) {
-        super(context, attrs, defStyleAttr, defStyleRes);
-        init(context, attrs);
-    }
-
-    @Override
-    protected Object onGetDefaultValue(TypedArray ta, int index) {
-        int defaultValue = ta.getInt(index, Color.BLACK);
-        return defaultValue;
-    }
-
-    @Override
-    protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue) {
-        // when using PreferenceDataStore, restorePersistedValue is always true (see Preference class for reference)
-        // so we load the persistent value with getPersistedInt if available in the data store,
-        // and use defaultValue as fallback (onGetDefaultValue has been already called and it loaded the android:defaultValue attr from our xml).
-        if (defaultValue == null) {
-            // if we forgot to add android:defaultValue, default to black color
-            defaultValue = Color.BLACK;
-        }
-        mCurrentValue = getPersistedInt((Integer) defaultValue);
-        onColorChanged(mCurrentValue);
-    }
-
-    private void init(Context context, AttributeSet attrs) {
-        mDensity = getContext().getResources().getDisplayMetrics().density;
-        setOnPreferenceClickListener(this);
-        if (attrs != null) {
-            mAlphaSliderEnabled = attrs.getAttributeBooleanValue(null, "alphaSlider", false);
-            mDefaultValue = attrs.getAttributeIntValue(ANDROIDNS, "defaultValue", Color.BLACK);
-            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);
-        }
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder view) {
-        mView = view;
-        super.onBindViewHolder(view);
-        view.setDividerAllowedAbove(mDividerAbove);
-        view.setDividerAllowedBelow(mDividerBelow);
-
-        view.itemView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                showDialog(null);
-            }
-        });
-        mWidgetFrameView = ((LinearLayout) view
-                .findViewById(android.R.id.widget_frame));
-        mWidgetFrameView.setOrientation(LinearLayout.HORIZONTAL);
-        mWidgetFrameView.setVisibility(View.VISIBLE);
-        mWidgetFrameView.setMinimumWidth(0);
-        mWidgetFrameView.setPadding(
-                mWidgetFrameView.getPaddingLeft(),
-                mWidgetFrameView.getPaddingTop(),
-                (int) (mDensity * 8),
-                mWidgetFrameView.getPaddingBottom()
-                );
-        setDefaultButton();
-        setPreviewColor();
-    }
-
-    /**
-     * Restore a default value, not necessarily a color
-     * For example: Set default value to -1 to remove a color filter
-     *
-     * @author Randall Rushing aka Bigrushdog
-     */
-    private void setDefaultButton() {
-        if (!mShowReset || mView == null || mWidgetFrameView == null)
-            return;
-
-        // remove already created default button
-        int count = mWidgetFrameView.getChildCount();
-        if (count > 0) {
-            View oldView = mWidgetFrameView.findViewWithTag("default");
-            View spacer = mWidgetFrameView.findViewWithTag("spacer");
-            if (oldView != null) {
-                mWidgetFrameView.removeView(oldView);
-            }
-            if (spacer != null) {
-                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");
-        defView.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onColorChanged(mDefaultValue);
-            }
-        });
-        // sorcery for a linear layout ugh
-        View spacer = new View(getContext());
-        spacer.setTag("spacer");
-        spacer.setLayoutParams(new LinearLayout.LayoutParams((int) (mDensity * 16),
-                LayoutParams.MATCH_PARENT));
-        mWidgetFrameView.addView(spacer);
-    }
-
-    private void setPreviewColor() {
-        if (!mShowPreview || mView == null || mWidgetFrameView == null)
-            return;
-
-        // remove already create preview image
-        int count = mWidgetFrameView.getChildCount();
-        if (count > 0) {
-            View preview = mWidgetFrameView.findViewWithTag("preview");
-            if (preview != null) {
-                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) ?
-                (mCurrentValue - 0x101010) : mCurrentValue;
-        iView.setImageDrawable(createOvalShape(size, 0xFF000000 + imageColor));
-        iView.setTag("preview");
-    }
-
-    @Override
-    public void setEnabled (boolean enabled) {
-        super.setEnabled(enabled);
-        setPreviewColor();
-        setDefaultButton();
-    }
-
-    @Override
-    public void onColorChanged(int color) {
-        mCurrentValue = color;
-        setPreviewColor();
-        persistInt(color);
-        try {
-            getOnPreferenceChangeListener().onPreferenceChange(this, color);
-        } catch (NullPointerException e) {
-        }
-        try {
-            mEditText.setText(Integer.toString(color, 16));
-        } catch (NullPointerException e) {
-        }
-    }
-
-    public boolean onPreferenceClick(Preference preference) {
-        return false;
-    }
-
-    protected void showDialog(Bundle state) {
-        mDialog = new ColorPickerDialog(getContext(), mCurrentValue);
-        mDialog.setOnColorChangedListener(this);
-        if (mAlphaSliderEnabled) {
-            mDialog.setAlphaSliderVisible(true);
-        }
-        if (state != null) {
-            mDialog.onRestoreInstanceState(state);
-        }
-        mDialog.show();
-        mDialog.getWindow().setSoftInputMode(
-                android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
-    }
-
-    /**
-     * Toggle Alpha Slider visibility (by default it's disabled)
-     *
-     * @param enable
-     */
-    public void setAlphaSliderEnabled(boolean enable) {
-        mAlphaSliderEnabled = enable;
-    }
-
-    /**
-     * For custom purposes. Not used by ColorPickerPreferrence
-     *
-     * set color preview value from outside
-     * @author kufikugel
-     */
-    public void setNewPreviewColor(int color) {
-        onColorChanged(color);
-    }
-
-    public void setDefaultValue(int value) {
-        mDefaultValue = value;
-    }
-
-    /**
-     * For custom purposes. Not used by ColorPickerPreferrence
-     *
-     * @param color
-     * @author Unknown
-     */
-    public static String convertToARGB(int color) {
-        String alpha = Integer.toHexString(Color.alpha(color));
-        String red = Integer.toHexString(Color.red(color));
-        String green = Integer.toHexString(Color.green(color));
-        String blue = Integer.toHexString(Color.blue(color));
-
-        if (alpha.length() == 1) {
-            alpha = "0" + alpha;
-        }
-
-        if (red.length() == 1) {
-            red = "0" + red;
-        }
-
-        if (green.length() == 1) {
-            green = "0" + green;
-        }
-
-        if (blue.length() == 1) {
-            blue = "0" + blue;
-        }
-
-        return "#" + alpha + red + green + blue;
-    }
-
-    public static String convertToRGB(int color) {
-        String red = Integer.toHexString(Color.red(color));
-        String green = Integer.toHexString(Color.green(color));
-        String blue = Integer.toHexString(Color.blue(color));
-
-        if (red.length() == 1) {
-            red = "0" + red;
-        }
-
-        if (green.length() == 1) {
-            green = "0" + green;
-        }
-
-        if (blue.length() == 1) {
-            blue = "0" + blue;
-        }
-
-        return "#" + red + green + blue;
-    }
-
-    /**
-     * For custom purposes. Not used by ColorPickerPreferrence
-     *
-     * @param argb
-     * @throws NumberFormatException
-     * @author Unknown
-     */
-    public static int convertToColorInt(String argb) throws NumberFormatException {
-
-        if (argb.startsWith("#")) {
-            argb = argb.replace("#", "");
-        }
-
-        int alpha = -1, red = -1, green = -1, blue = -1;
-
-        if (argb.length() == 8) {
-            alpha = Integer.parseInt(argb.substring(0, 2), 16);
-            red = Integer.parseInt(argb.substring(2, 4), 16);
-            green = Integer.parseInt(argb.substring(4, 6), 16);
-            blue = Integer.parseInt(argb.substring(6, 8), 16);
-        }
-        else if (argb.length() == 6) {
-            alpha = 255;
-            red = Integer.parseInt(argb.substring(0, 2), 16);
-            green = Integer.parseInt(argb.substring(2, 4), 16);
-            blue = Integer.parseInt(argb.substring(4, 6), 16);
-        }
-
-        return Color.argb(alpha, red, green, blue);
-    }
-
-    @Override
-    protected Parcelable onSaveInstanceState() {
-        final Parcelable superState = super.onSaveInstanceState();
-        if (mDialog == null || !mDialog.isShowing()) {
-            return superState;
-        }
-
-        final SavedState myState = new SavedState(superState);
-        myState.dialogBundle = mDialog.onSaveInstanceState();
-        return myState;
-    }
-
-    @Override
-    protected void onRestoreInstanceState(Parcelable state) {
-        if (state == null || !(state instanceof SavedState)) {
-            // Didn't save state for us in onSaveInstanceState
-            super.onRestoreInstanceState(state);
-            return;
-        }
-
-        SavedState myState = (SavedState) state;
-        super.onRestoreInstanceState(myState.getSuperState());
-        showDialog(myState.dialogBundle);
-    }
-
-    private static class SavedState extends BaseSavedState {
-        Bundle dialogBundle;
-
-        public SavedState(Parcel source) {
-            super(source);
-            dialogBundle = source.readBundle();
-        }
-
-        @Override
-        public void writeToParcel(Parcel dest, int flags) {
-            super.writeToParcel(dest, flags);
-            dest.writeBundle(dialogBundle);
-        }
-
-        public SavedState(Parcelable superState) {
-            super(superState);
-        }
-
-        @SuppressWarnings("unused")
-        public static final Parcelable.Creator<SavedState> CREATOR =
-                new Parcelable.Creator<SavedState>() {
-            public SavedState createFromParcel(Parcel in) {
-                return new SavedState(in);
-            }
-
-            public SavedState[] newArray(int size) {
-                return new SavedState[size];
-            }
-        };
-    }
-
-    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;
-    }
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerSecurePreference.java b/src/com/bliss/support/colorpicker/ColorPickerSecurePreference.java
deleted file mode 100644
index 3ba8d23..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerSecurePreference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 Sergey Margaritov
- * Copyright (C) 2013 Slimroms
- * Copyright (C) 2015 The TeamEos Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.bliss.support.preferences.SecureSettingsStore;
-
-public class ColorPickerSecurePreference extends ColorPickerPreference {
-
-    public ColorPickerSecurePreference(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-        setPreferenceDataStore(new SecureSettingsStore(context.getContentResolver()));
-    }
-
-    public ColorPickerSecurePreference(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        setPreferenceDataStore(new SecureSettingsStore(context.getContentResolver()));
-    }
-
-    public ColorPickerSecurePreference(Context context) {
-        super(context, null);
-        setPreferenceDataStore(new SecureSettingsStore(context.getContentResolver()));
-    }
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerSystemPreference.java b/src/com/bliss/support/colorpicker/ColorPickerSystemPreference.java
deleted file mode 100644
index 911091d..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerSystemPreference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 Sergey Margaritov
- * Copyright (C) 2013 Slimroms
- * Copyright (C) 2015 The TeamEos Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.content.Context;
-import android.util.AttributeSet;
-
-import com.bliss.support.preferences.SystemSettingsStore;
-
-public class ColorPickerSystemPreference extends ColorPickerPreference {
-
-    public ColorPickerSystemPreference(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
-    }
-
-    public ColorPickerSystemPreference(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
-    }
-
-    public ColorPickerSystemPreference(Context context) {
-        super(context, null);
-        setPreferenceDataStore(new SystemSettingsStore(context.getContentResolver()));
-    }
-}
diff --git a/src/com/bliss/support/colorpicker/ColorPickerView.java b/src/com/bliss/support/colorpicker/ColorPickerView.java
deleted file mode 100644
index f9bda64..0000000
--- a/src/com/bliss/support/colorpicker/ColorPickerView.java
+++ /dev/null
@@ -1,962 +0,0 @@
-/*
- * Copyright (C) 2010 Daniel Nilsson
- * Copyright (C) 2013 Slimroms
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.bliss.support.colorpicker;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.ComposeShader;
-import android.graphics.LinearGradient;
-import android.graphics.Paint;
-import android.graphics.Paint.Align;
-import android.graphics.Paint.Style;
-import android.graphics.Point;
-import android.graphics.PorterDuff;
-import android.graphics.RectF;
-import android.graphics.Shader;
-import android.graphics.Shader.TileMode;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.View;
-
-/**
- * Displays a color picker to the user and allow them
- * to select a color. A slider for the alpha channel is
- * also available. Enable it by setting
- * setAlphaSliderVisible(boolean) to true.
- * @author Daniel Nilsson
- */
-public class ColorPickerView extends View {
-
-    private final static int    PANEL_SAT_VAL = 0;
-    private final static int    PANEL_HUE = 1;
-    private final static int    PANEL_ALPHA = 2;
-
-    /**
-     * The width in pixels of the border
-     * surrounding all color panels.
-     */
-    private final static float    BORDER_WIDTH_PX = 1;
-
-    /**
-     * The width in dp of the hue panel.
-     */
-    private float         HUE_PANEL_WIDTH = 30f;
-    /**
-     * The height in dp of the alpha panel
-     */
-    private float        ALPHA_PANEL_HEIGHT = 20f;
-    /**
-     * The distance in dp between the different
-     * color panels.
-     */
-    private float         PANEL_SPACING = 10f;
-    /**
-     * The radius in dp of the color palette tracker circle.
-     */
-    private float         PALETTE_CIRCLE_TRACKER_RADIUS = 5f;
-    /**
-     * The dp which the tracker of the hue or alpha panel
-     * will extend outside of its bounds.
-     */
-    private float        RECTANGLE_TRACKER_OFFSET = 2f;
-
-
-    private float         mDensity = 1f;
-
-    private OnColorChangedListener    mListener;
-
-    private Paint         mSatValPaint;
-    private Paint        mSatValTrackerPaint;
-
-    private Paint        mHuePaint;
-    private Paint        mHueTrackerPaint;
-
-    private Paint        mAlphaPaint;
-    private Paint        mAlphaTextPaint;
-
-    private Paint        mBorderPaint;
-
-    private Shader        mValShader;
-    private Shader        mSatShader;
-    private Shader        mHueShader;
-    private Shader        mAlphaShader;
-
-    private int            mAlpha = 0xff;
-    private float        mHue = 360f;
-    private float         mSat = 0f;
-    private float         mVal = 0f;
-
-    private String        mAlphaSliderText = "";
-    private int         mSliderTrackerColor = 0xff1c1c1c;
-    private int         mBorderColor = 0xff6E6E6E;
-    private boolean        mShowAlphaPanel = false;
-
-    /*
-     * To remember which panel that has the "focus" when
-     * processing hardware button data.
-     */
-    private int            mLastTouchedPanel = PANEL_SAT_VAL;
-
-    /**
-     * Offset from the edge we must have or else
-     * the finger tracker will get clipped when
-     * it is drawn outside of the view.
-     */
-    private float         mDrawingOffset;
-
-
-    /*
-     * Distance form the edges of the view
-     * of where we are allowed to draw.
-     */
-    private RectF    mDrawingRect;
-
-    private RectF    mSatValRect;
-    private RectF     mHueRect;
-    private RectF    mAlphaRect;
-
-    private AlphaPatternDrawable    mAlphaPattern;
-
-    private Point    mStartTouchPoint = null;
-
-    public interface OnColorChangedListener {
-        public void onColorChanged(int color);
-    }
-
-    public ColorPickerView(Context context){
-        this(context, null);
-    }
-
-    public ColorPickerView(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public ColorPickerView(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-        init();
-    }
-
-    private void init(){
-        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-        mDensity = getContext().getResources().getDisplayMetrics().density;
-        PALETTE_CIRCLE_TRACKER_RADIUS *= mDensity;
-        RECTANGLE_TRACKER_OFFSET *= mDensity;
-        HUE_PANEL_WIDTH *= mDensity;
-        ALPHA_PANEL_HEIGHT *= mDensity;
-        PANEL_SPACING = PANEL_SPACING * mDensity;
-
-        mDrawingOffset = calculateRequiredOffset();
-
-        initPaintTools();
-
-        //Needed for receiving trackball motion events.
-        setFocusable(true);
-        setFocusableInTouchMode(true);
-    }
-
-    private void initPaintTools(){
-
-        mSatValPaint = new Paint();
-        mSatValTrackerPaint = new Paint();
-        mHuePaint = new Paint();
-        mHueTrackerPaint = new Paint();
-        mAlphaPaint = new Paint();
-        mAlphaTextPaint = new Paint();
-        mBorderPaint = new Paint();
-
-
-        mSatValTrackerPaint.setStyle(Style.STROKE);
-        mSatValTrackerPaint.setStrokeWidth(2f * mDensity);
-        mSatValTrackerPaint.setAntiAlias(true);
-
-        mHueTrackerPaint.setColor(mSliderTrackerColor);
-        mHueTrackerPaint.setStyle(Style.STROKE);
-        mHueTrackerPaint.setStrokeWidth(2f * mDensity);
-        mHueTrackerPaint.setAntiAlias(true);
-
-        mAlphaTextPaint.setColor(0xff1c1c1c);
-        mAlphaTextPaint.setTextSize(14f * mDensity);
-        mAlphaTextPaint.setAntiAlias(true);
-        mAlphaTextPaint.setTextAlign(Align.CENTER);
-        mAlphaTextPaint.setFakeBoldText(true);
-
-
-    }
-
-    private float calculateRequiredOffset(){
-        float offset = Math.max(PALETTE_CIRCLE_TRACKER_RADIUS, RECTANGLE_TRACKER_OFFSET);
-        offset = Math.max(offset, BORDER_WIDTH_PX * mDensity);
-
-        return offset * 1.5f;
-    }
-
-    private int[] buildHueColorArray(){
-
-        int[] hue = new int[361];
-
-        int count = 0;
-        for(int i = hue.length -1; i >= 0; i--, count++){
-            hue[count] = Color.HSVToColor(new float[]{i, 1f, 1f});
-        }
-
-        return hue;
-    }
-
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-
-        if(mDrawingRect.width() <= 0 || mDrawingRect.height() <= 0) return;
-
-        drawSatValPanel(canvas);
-        drawHuePanel(canvas);
-        drawAlphaPanel(canvas);
-
-    }
-
-    private void drawSatValPanel(Canvas canvas){
-
-        final RectF    rect = mSatValRect;
-
-        if(BORDER_WIDTH_PX > 0){
-            mBorderPaint.setColor(mBorderColor);
-            canvas.drawRect(mDrawingRect.left,
-                mDrawingRect.top, rect.right + BORDER_WIDTH_PX,
-                rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
-        }
-
-        if (mValShader == null) {
-            mValShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom,
-                    0xffffffff, 0xff000000, TileMode.CLAMP);
-        }
-
-        int rgb = Color.HSVToColor(new float[]{mHue,1f,1f});
-
-        mSatShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top,
-                0xffffffff, rgb, TileMode.CLAMP);
-        ComposeShader mShader = new ComposeShader(
-            mValShader, mSatShader, PorterDuff.Mode.MULTIPLY);
-        mSatValPaint.setShader(mShader);
-
-        canvas.drawRect(rect, mSatValPaint);
-
-        Point p = satValToPoint(mSat, mVal);
-
-        mSatValTrackerPaint.setColor(0xff000000);
-        canvas.drawCircle(
-            p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS - 1f * mDensity, mSatValTrackerPaint);
-
-        mSatValTrackerPaint.setColor(0xffdddddd);
-        canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS, mSatValTrackerPaint);
-
-    }
-
-    private void drawHuePanel(Canvas canvas){
-
-        final RectF rect = mHueRect;
-
-        if(BORDER_WIDTH_PX > 0){
-            mBorderPaint.setColor(mBorderColor);
-            canvas.drawRect(rect.left - BORDER_WIDTH_PX,
-                    rect.top - BORDER_WIDTH_PX,
-                    rect.right + BORDER_WIDTH_PX,
-                    rect.bottom + BORDER_WIDTH_PX,
-                    mBorderPaint);
-        }
-
-        if (mHueShader == null) {
-            mHueShader = new LinearGradient(
-                rect.left, rect.top, rect.left, rect.bottom,
-                buildHueColorArray(), null, TileMode.CLAMP);
-            mHuePaint.setShader(mHueShader);
-        }
-
-        canvas.drawRect(rect, mHuePaint);
-
-        float rectHeight = 4 * mDensity / 2;
-
-        Point p = hueToPoint(mHue);
-
-        RectF r = new RectF();
-        r.left = rect.left - RECTANGLE_TRACKER_OFFSET;
-        r.right = rect.right + RECTANGLE_TRACKER_OFFSET;
-        r.top = p.y - rectHeight;
-        r.bottom = p.y + rectHeight;
-
-
-        canvas.drawRoundRect(r, 2, 2, mHueTrackerPaint);
-
-    }
-
-    private void drawAlphaPanel(Canvas canvas){
-
-        if(!mShowAlphaPanel || mAlphaRect == null || mAlphaPattern == null) return;
-
-        final RectF rect = mAlphaRect;
-
-        if(BORDER_WIDTH_PX > 0){
-            mBorderPaint.setColor(mBorderColor);
-            canvas.drawRect(rect.left - BORDER_WIDTH_PX,
-                    rect.top - BORDER_WIDTH_PX,
-                    rect.right + BORDER_WIDTH_PX,
-                    rect.bottom + BORDER_WIDTH_PX,
-                    mBorderPaint);
-        }
-
-
-        mAlphaPattern.draw(canvas);
-
-        float[] hsv = new float[]{mHue,mSat,mVal};
-        int color = Color.HSVToColor(hsv);
-        int acolor = Color.HSVToColor(0, hsv);
-
-        mAlphaShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top,
-                color, acolor, TileMode.CLAMP);
-
-
-        mAlphaPaint.setShader(mAlphaShader);
-
-        canvas.drawRect(rect, mAlphaPaint);
-
-        if(mAlphaSliderText != null && mAlphaSliderText!= ""){
-            canvas.drawText(mAlphaSliderText, rect.centerX(),
-                rect.centerY() + 4 * mDensity, mAlphaTextPaint);
-        }
-
-        float rectWidth = 4 * mDensity / 2;
-
-        Point p = alphaToPoint(mAlpha);
-
-        RectF r = new RectF();
-        r.left = p.x - rectWidth;
-        r.right = p.x + rectWidth;
-        r.top = rect.top - RECTANGLE_TRACKER_OFFSET;
-        r.bottom = rect.bottom + RECTANGLE_TRACKER_OFFSET;
-
-        canvas.drawRoundRect(r, 2, 2, mHueTrackerPaint);
-
-    }
-
-
-    private Point hueToPoint(float hue){
-
-        final RectF rect = mHueRect;
-        final float height = rect.height();
-
-        Point p = new Point();
-
-        p.y = (int) (height - (hue * height / 360f) + rect.top);
-        p.x = (int) rect.left;
-
-        return p;
-    }
-
-    private Point satValToPoint(float sat, float val){
-
-        final RectF rect = mSatValRect;
-        final float height = rect.height();
-        final float width = rect.width();
-
-        Point p = new Point();
-
-        p.x = (int) (sat * width + rect.left);
-        p.y = (int) ((1f - val) * height + rect.top);
-
-        return p;
-    }
-
-    private Point alphaToPoint(int alpha){
-
-        final RectF rect = mAlphaRect;
-        final float width = rect.width();
-
-        Point p = new Point();
-
-        p.x = (int) (width - (alpha * width / 0xff) + rect.left);
-        p.y = (int) rect.top;
-
-        return p;
-
-    }
-
-    private float[] pointToSatVal(float x, float y){
-
-        final RectF rect = mSatValRect;
-        float[] result = new float[2];
-
-        float width = rect.width();
-        float height = rect.height();
-
-        if (x < rect.left){
-            x = 0f;
-        }
-        else if(x > rect.right){
-            x = width;
-        }
-        else{
-            x = x - rect.left;
-        }
-
-        if (y < rect.top){
-            y = 0f;
-        }
-        else if(y > rect.bottom){
-            y = height;
-        }
-        else{
-            y = y - rect.top;
-        }
-
-
-        result[0] = 1.f / width * x;
-        result[1] = 1.f - (1.f / height * y);
-
-        return result;
-    }
-
-    private float pointToHue(float y){
-
-        final RectF rect = mHueRect;
-
-        float height = rect.height();
-
-        if (y < rect.top){
-            y = 0f;
-        }
-        else if(y > rect.bottom){
-            y = height;
-        }
-        else{
-            y = y - rect.top;
-        }
-
-        return 360f - (y * 360f / height);
-    }
-
-    private int pointToAlpha(int x){
-
-        final RectF rect = mAlphaRect;
-        final int width = (int) rect.width();
-
-        if(x < rect.left){
-            x = 0;
-        }
-        else if(x > rect.right){
-            x = width;
-        }
-        else{
-            x = x - (int)rect.left;
-        }
-
-        return 0xff - (x * 0xff / width);
-
-    }
-
-
-    @Override
-    public boolean onTrackballEvent(MotionEvent event) {
-
-        float x = event.getX();
-        float y = event.getY();
-
-        boolean update = false;
-
-
-        if(event.getAction() == MotionEvent.ACTION_MOVE){
-
-            switch(mLastTouchedPanel){
-
-            case PANEL_SAT_VAL:
-
-                float sat, val;
-
-                sat = mSat + x/50f;
-                val = mVal - y/50f;
-
-                if(sat < 0f){
-                    sat = 0f;
-                }
-                else if(sat > 1f){
-                    sat = 1f;
-                }
-
-                if(val < 0f){
-                    val = 0f;
-                }
-                else if(val > 1f){
-                    val = 1f;
-                }
-
-                mSat = sat;
-                mVal = val;
-
-                update = true;
-
-                break;
-
-            case PANEL_HUE:
-
-                float hue = mHue - y * 10f;
-
-                if(hue < 0f){
-                    hue = 0f;
-                }
-                else if(hue > 360f){
-                    hue = 360f;
-                }
-
-                mHue = hue;
-
-                update = true;
-
-                break;
-
-            case PANEL_ALPHA:
-
-                if(!mShowAlphaPanel || mAlphaRect == null){
-                    update = false;
-                }
-                else{
-
-                    int alpha = (int) (mAlpha - x*10);
-
-                    if(alpha < 0){
-                        alpha = 0;
-                    }
-                    else if(alpha > 0xff){
-                        alpha = 0xff;
-                    }
-
-                    mAlpha = alpha;
-
-
-                    update = true;
-                }
-
-                break;
-            }
-
-
-        }
-
-
-        if(update){
-
-            if(mListener != null){
-                mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
-            }
-
-            invalidate();
-            return true;
-        }
-
-
-        return super.onTrackballEvent(event);
-    }
-
-    @Override
-    public boolean onTouchEvent(MotionEvent event) {
-
-        boolean update = false;
-
-        switch(event.getAction()){
-
-        case MotionEvent.ACTION_DOWN:
-
-            mStartTouchPoint = new Point((int)event.getX(), (int)event.getY());
-
-            update = moveTrackersIfNeeded(event);
-
-            break;
-
-        case MotionEvent.ACTION_MOVE:
-
-            update = moveTrackersIfNeeded(event);
-
-            break;
-
-        case MotionEvent.ACTION_UP:
-
-            mStartTouchPoint = null;
-
-            update = moveTrackersIfNeeded(event);
-
-            break;
-
-        }
-
-        if(update){
-
-            if(mListener != null){
-                mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
-            }
-
-            invalidate();
-            return true;
-        }
-
-
-        return super.onTouchEvent(event);
-    }
-
-    private boolean moveTrackersIfNeeded(MotionEvent event){
-
-        if(mStartTouchPoint == null) return false;
-
-        boolean update = false;
-
-        int startX = mStartTouchPoint.x;
-        int startY = mStartTouchPoint.y;
-
-
-        if(mHueRect.contains(startX, startY)){
-            mLastTouchedPanel = PANEL_HUE;
-
-            mHue = pointToHue(event.getY());
-
-            update = true;
-        }
-        else if(mSatValRect.contains(startX, startY)){
-
-            mLastTouchedPanel = PANEL_SAT_VAL;
-
-            float[] result = pointToSatVal(event.getX(), event.getY());
-
-            mSat = result[0];
-            mVal = result[1];
-
-            update = true;
-        }
-        else if(mAlphaRect != null && mAlphaRect.contains(startX, startY)){
-
-            mLastTouchedPanel = PANEL_ALPHA;
-
-            mAlpha = pointToAlpha((int)event.getX());
-
-            update = true;
-        }
-
-
-        return update;
-    }
-
-    @Override
-    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-
-        int width = 0;
-        int height = 0;
-
-        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
-        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
-
-        int widthAllowed = MeasureSpec.getSize(widthMeasureSpec);
-        int heightAllowed = MeasureSpec.getSize(heightMeasureSpec);
-
-        widthAllowed = chooseWidth(widthMode, widthAllowed);
-        heightAllowed = chooseHeight(heightMode, heightAllowed);
-
-        if(!mShowAlphaPanel){
-
-            height = (int) (widthAllowed - PANEL_SPACING - HUE_PANEL_WIDTH);
-
-            //If calculated height (based on the width) is more than the allowed height.
-            if(height > heightAllowed) {
-                height = heightAllowed;
-                width = (int) (height + PANEL_SPACING + HUE_PANEL_WIDTH);
-            }
-            else{
-                width = widthAllowed;
-            }
-        }
-        else{
-
-            width = (int) (heightAllowed - ALPHA_PANEL_HEIGHT + HUE_PANEL_WIDTH);
-
-            if(width > widthAllowed){
-                width = widthAllowed;
-                height = (int) (widthAllowed - HUE_PANEL_WIDTH + ALPHA_PANEL_HEIGHT);
-            }
-            else{
-                height = heightAllowed;
-            }
-
-        }
-
-        setMeasuredDimension(width, height);
-    }
-
-    private int chooseWidth(int mode, int size){
-        if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) {
-            return size;
-        } else { // (mode == MeasureSpec.UNSPECIFIED)
-            return getPrefferedWidth();
-        }
-    }
-
-    private int chooseHeight(int mode, int size){
-        if (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) {
-            return size;
-        } else { // (mode == MeasureSpec.UNSPECIFIED)
-            return getPrefferedHeight();
-        }
-    }
-
-    private int getPrefferedWidth(){
-
-        int width = getPrefferedHeight();
-
-        if(mShowAlphaPanel){
-            width -= (PANEL_SPACING + ALPHA_PANEL_HEIGHT);
-        }
-
-
-        return (int) (width + HUE_PANEL_WIDTH + PANEL_SPACING);
-
-    }
-
-    private int getPrefferedHeight(){
-
-        int height = (int)(200 * mDensity);
-
-        if(mShowAlphaPanel){
-            height += PANEL_SPACING + ALPHA_PANEL_HEIGHT;
-        }
-
-        return height;
-    }
-
-
-
-    @Override
-    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
-        super.onSizeChanged(w, h, oldw, oldh);
-
-        mDrawingRect = new RectF();
-        mDrawingRect.left = mDrawingOffset + getPaddingLeft();
-        mDrawingRect.right  = w - mDrawingOffset - getPaddingRight();
-        mDrawingRect.top = mDrawingOffset + getPaddingTop();
-        mDrawingRect.bottom = h - mDrawingOffset - getPaddingBottom();
-
-        setUpSatValRect();
-        setUpHueRect();
-        setUpAlphaRect();
-    }
-
-    private void setUpSatValRect(){
-
-        final RectF    dRect = mDrawingRect;
-        float panelSide = dRect.height() - BORDER_WIDTH_PX * 2;
-
-        if(mShowAlphaPanel){
-            panelSide -= PANEL_SPACING + ALPHA_PANEL_HEIGHT;
-        }
-
-        float left = dRect.left + BORDER_WIDTH_PX;
-        float top = dRect.top + BORDER_WIDTH_PX;
-        float bottom = top + panelSide;
-        float right = left + panelSide;
-
-        mSatValRect = new RectF(left,top, right, bottom);
-    }
-
-    private void setUpHueRect(){
-        final RectF    dRect = mDrawingRect;
-
-        float left = dRect.right - HUE_PANEL_WIDTH + BORDER_WIDTH_PX;
-        float top = dRect.top + BORDER_WIDTH_PX;
-        float bottom = dRect.bottom - BORDER_WIDTH_PX - (mShowAlphaPanel
-            ? (PANEL_SPACING + ALPHA_PANEL_HEIGHT) : 0);
-        float right = dRect.right - BORDER_WIDTH_PX;
-
-        mHueRect = new RectF(left, top, right, bottom);
-    }
-
-    private void setUpAlphaRect() {
-
-        if(!mShowAlphaPanel) return;
-
-        final RectF    dRect = mDrawingRect;
-
-        float left = dRect.left + BORDER_WIDTH_PX;
-        float top = dRect.bottom - ALPHA_PANEL_HEIGHT + BORDER_WIDTH_PX;
-        float bottom = dRect.bottom - BORDER_WIDTH_PX;
-        float right = dRect.right - BORDER_WIDTH_PX;
-
-        mAlphaRect = new RectF(left, top, right, bottom);
-
-        mAlphaPattern = new AlphaPatternDrawable((int) (5 * mDensity));
-        mAlphaPattern.setBounds(
-            Math.round(mAlphaRect.left),
-            Math.round(mAlphaRect.top),
-            Math.round(mAlphaRect.right),
-            Math.round(mAlphaRect.bottom)
-        );
-
-    }
-
-
-    /**
-     * Set a OnColorChangedListener to get notified when the color
-     * selected by the user has changed.
-     * @param listener
-     */
-    public void setOnColorChangedListener(OnColorChangedListener listener){
-        mListener = listener;
-    }
-
-    /**
-     * Set the color of the border surrounding all panels.
-     * @param color
-     */
-    public void setBorderColor(int color){
-        mBorderColor = color;
-        invalidate();
-    }
-
-    /**
-     * Get the color of the border surrounding all panels.
-     */
-    public int getBorderColor(){
-        return mBorderColor;
-    }
-
-    /**
-     * Get the current color this view is showing.
-     * @return the current color.
-     */
-    public int getColor(){
-        return Color.HSVToColor(mAlpha, new float[]{mHue,mSat,mVal});
-    }
-
-    /**
-     * Set the color the view should show.
-     * @param color The color that should be selected.
-     */
-    public void setColor(int color){
-        setColor(color, false);
-    }
-
-    /**
-     * Set the color this view should show.
-     * @param color The color that should be selected.
-     * @param callback If you want to get a callback to
-     * your OnColorChangedListener.
-     */
-    public void setColor(int color, boolean callback){
-
-        int alpha = Color.alpha(color);
-        int red = Color.red(color);
-        int blue = Color.blue(color);
-        int green = Color.green(color);
-
-        float[] hsv = new float[3];
-
-        Color.RGBToHSV(red, green, blue, hsv);
-
-        mAlpha = alpha;
-        mHue = hsv[0];
-        mSat = hsv[1];
-        mVal = hsv[2];
-
-        if(callback && mListener != null){
-            mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));
-        }
-
-        invalidate();
-    }
-
-    /**
-     * Get the drawing offset of the color picker view.
-     * The drawing offset is the distance from the side of
-     * a panel to the side of the view minus the padding.
-     * Useful if you want to have your own panel below showing
-     * the currently selected color and want to align it perfectly.
-     * @return The offset in pixels.
-     */
-    public float getDrawingOffset(){
-        return mDrawingOffset;
-    }
-
-    /**
-     * Set if the user is allowed to adjust the alpha panel. Default is false.
-     * If it is set to false no alpha will be set.
-     * @param visible
-     */
-    public void setAlphaSliderVisible(boolean visible){
-
-        if(mShowAlphaPanel != visible){
-            mShowAlphaPanel = visible;
-
-            /*
-             * Reset all shader to force a recreation.
-             * Otherwise they will not look right after
-             * the size of the view has changed.
-             */
-            mValShader = null;
-            mSatShader = null;
-            mHueShader = null;
-            mAlphaShader = null;;
-
-            requestLayout();
-        }
-
-    }
-
-    public void setSliderTrackerColor(int color){
-        mSliderTrackerColor = color;
-
-        mHueTrackerPaint.setColor(mSliderTrackerColor);
-
-        invalidate();
-    }
-
-    public int getSliderTrackerColor(){
-        return mSliderTrackerColor;
-    }
-
-    /**
-     * Set the text that should be shown in the
-     * alpha slider. Set to null to disable text.
-     * @param res string resource id.
-     */
-    public void setAlphaSliderText(int res){
-        String text = getContext().getString(res);
-        setAlphaSliderText(text);
-    }
-
-    /**
-     * Set the text that should be shown in the
-     * alpha slider. Set to null to disable text.
-     * @param text Text that should be shown.
-     */
-    public void setAlphaSliderText(String text){
-        mAlphaSliderText = text;
-        invalidate();
-    }
-
-    /**
-     * Get the current value of the text
-     * that will be shown in the alpha
-     * slider.
-     * @return
-     */
-    public String getAlphaSliderText(){
-        return mAlphaSliderText;
-    }
-}
