Add Color Blend Preference
Change-Id: Ia1d9575791e94f98ff66a89410e204d26cef2e40
diff --git a/res/layout/color_blend_preference_dialog.xml b/res/layout/color_blend_preference_dialog.xml
new file mode 100644
index 0000000..8f08107
--- /dev/null
+++ b/res/layout/color_blend_preference_dialog.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 Android Ice Cold 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:theme="?android:attr/dialogPreferenceStyle"
+ android:padding="?android:attr/dialogPreferredPadding">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <View
+ android:id="@+id/color_start"
+ android:layout_width="@dimen/color_blend_preview_size"
+ android:layout_height="@dimen/color_blend_preview_size" />
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="2" />
+
+ <View
+ android:id="@+id/color_between"
+ android:layout_width="@dimen/color_blend_preview_size"
+ android:layout_height="@dimen/color_blend_preview_size" />
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="2" />
+
+ <View
+ android:id="@+id/color_end"
+ android:layout_width="@dimen/color_blend_preview_size"
+ android:layout_height="@dimen/color_blend_preview_size" />
+
+ <Space
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/color_preview_start_text"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"/>
+
+ <TextView
+ android:id="@+id/color_preview_between_text"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"/>
+
+ <TextView
+ android:id="@+id/color_preview_end_text"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center"/>
+
+ </LinearLayout>
+
+ <TextView
+ android:id="@+id/color_preview_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <SeekBar
+ android:id="@+id/color_preview_slider"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:min="0"
+ android:max="100"
+ android:progress="50" />
+
+</LinearLayout>
diff --git a/res/layout/color_blend_preview.xml b/res/layout/color_blend_preview.xml
new file mode 100644
index 0000000..f07c73b
--- /dev/null
+++ b/res/layout/color_blend_preview.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 Android Ice Cold 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="36dp"
+ android:layout_height="12dp"
+ android:layout_margin="8dp"
+ android:orientation="horizontal">
+
+ <View
+ android:id="@+id/color_preview_start"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <View
+ android:id="@+id/color_preview_between"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <View
+ android:id="@+id/color_preview_end"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+</LinearLayout>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index fb90900..618d3a4 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -28,4 +28,20 @@
<attr name="defaultColorValue" format="integer" />
</declare-styleable>
+ <!-- Color Blend -->
+ <declare-styleable name="ColorBlendPreference">
+ <!-- Preference keys -->
+ <attr name="keyColorStart" format="string" />
+ <attr name="keyColorEnd" format="string" />
+ <attr name="keyBlendReverse" format="string" />
+ <!-- Default values -->
+ <attr name="defaultValueColorStart" format="color" />
+ <attr name="defaultValueColorEnd" format="color" />
+ <attr name="defaultValueBlendReverse" format="boolean" />
+ <!-- Preview strings -->
+ <attr name="previewStartText" format="string" />
+ <attr name="previewEndText" format="string" />
+ <attr name="previewBetweenText" format="string" />
+ </declare-styleable>
+
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a3aa829..99f4c49 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -19,4 +19,7 @@
<!-- Color Picker -->
<dimen name="oval_notification_size">26dp</dimen>
+ <!-- Color Blend -->
+ <dimen name="color_blend_preview_size">36dp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index eb1a4f8..7d64ee8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -32,4 +32,13 @@
<string name="custom_seekbar_default_value_to_set">Default value: <xliff:g id="v">%s</xliff:g>\nLong tap to set</string>
<string name="custom_seekbar_default_value_is_set">Default value is set</string>
+ <!-- Color Blend -->
+ <string name="color_blend_ok">@android:string/ok</string>
+ <string name="color_blend_cancel">@android:string/cancel</string>
+ <string name="color_blend_reset">Reset</string>
+ <string name="color_blend_preview">Preview: %1$d%%</string>
+ <string name="color_preview_start">Start</string>
+ <string name="color_preview_end">End</string>
+ <string name="color_preview_between">Between</string>
+
</resources>