cmparts: Add LiveDisplay settings

 * Welcome to CMParts, have a nice day!

Change-Id: Ie89830c6315ed583942cb62c3d03e9f3137bf168
diff --git a/res/drawable/color_temperature_preview.xml b/res/drawable/color_temperature_preview.xml
new file mode 100644
index 0000000..0a358f6
--- /dev/null
+++ b/res/drawable/color_temperature_preview.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2015 The CyanogenMod 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <gradient
+        android:angle="0"
+        android:startColor="#ff3800"
+        android:endColor="#bfd3ff" />
+</shape>
diff --git a/res/drawable/color_tuning_preview.xml b/res/drawable/color_tuning_preview.xml
new file mode 100644
index 0000000..589237a
--- /dev/null
+++ b/res/drawable/color_tuning_preview.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The CyanogenMod 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <gradient
+        android:angle="0"
+        android:startColor="#000000"
+        android:endColor="#FFFFFF" />
+</shape>
diff --git a/res/layout/display_color_calibration.xml b/res/layout/display_color_calibration.xml
new file mode 100644
index 0000000..bc1b001
--- /dev/null
+++ b/res/layout/display_color_calibration.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2013-2015 The CyanogenMod 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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+		    xmlns:cm="http://schemas.android.com/apk/res/org.cyanogenmod.cmparts"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center_horizontal"
+            android:paddingStart="20dip"
+            android:paddingEnd="20dip"
+            android:paddingBottom="20dip">
+
+        <TextView android:id="@+id/color_red_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/color_red_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/color_red_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/color_red_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_red_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <TextView android:id="@+id/color_green_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_red_seekbar"
+                android:text="@string/color_green_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/color_green_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_red_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/color_green_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_green_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <TextView android:id="@+id/color_blue_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_green_seekbar"
+                android:text="@string/color_blue_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/color_blue_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_green_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/color_blue_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/color_blue_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <ImageView android:id="@+id/black_scale_picture_color"
+                android:src="@drawable/color_tuning_preview"
+                android:layout_width="match_parent"
+                android:layout_height="40dip"
+                android:layout_below="@id/color_blue_seekbar"
+                android:paddingTop="20dip" />
+
+    </RelativeLayout>
+</ScrollView>
diff --git a/res/layout/display_picture_adjustment.xml b/res/layout/display_picture_adjustment.xml
new file mode 100644
index 0000000..ebbcb59
--- /dev/null
+++ b/res/layout/display_picture_adjustment.xml
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2013-2015 The CyanogenMod 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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+            xmlns:cm="http://schemas.android.com/apk/res/org.cyanogenmod.cmparts"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center_horizontal"
+            android:paddingStart="20dip"
+            android:paddingEnd="20dip"
+            android:paddingBottom="20dip">
+
+        <TextView android:id="@+id/adj_hue_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/adj_hue_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/adj_hue_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/adj_hue_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_hue_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <TextView android:id="@+id/adj_saturation_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_hue_seekbar"
+                android:text="@string/adj_saturation_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/adj_saturation_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_hue_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/adj_saturation_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_saturation_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <TextView android:id="@+id/adj_intensity_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_saturation_seekbar"
+                android:text="@string/adj_intensity_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/adj_intensity_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_saturation_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/adj_intensity_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_intensity_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <TextView android:id="@+id/adj_contrast_text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_intensity_seekbar"
+                android:text="@string/adj_contrast_title"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/adj_contrast_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_intensity_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <org.cyanogenmod.cmparts.IntervalSeekBar android:id="@+id/adj_contrast_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/adj_contrast_text"
+                android:paddingTop="2dip"
+                cm:min="0.20"
+                cm:max="1.00"
+                cm:defaultValue="1.00"
+                cm:digits="4" />
+
+        <ImageView android:id="@+id/black_scale_picture_adjustment"
+                android:src="@drawable/color_tuning_preview"
+                android:layout_width="match_parent"
+                android:layout_height="40dip"
+                android:layout_below="@id/adj_contrast_seekbar"
+                android:paddingTop="20dip" />
+
+    </RelativeLayout>
+</ScrollView>
diff --git a/res/layout/display_temperature.xml b/res/layout/display_temperature.xml
new file mode 100644
index 0000000..c10f7c4
--- /dev/null
+++ b/res/layout/display_temperature.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2015 The CyanogenMod 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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:gravity="center_horizontal"
+            android:paddingStart="20dip"
+            android:paddingEnd="20dip"
+            android:paddingBottom="20dip">
+
+        <TextView android:id="@+id/day_temperature_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/live_display_day"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/day_temperature_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <SeekBar android:id="@+id/day_temperature_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/day_temperature_text"
+                android:paddingTop="2dip" />
+
+        <TextView android:id="@+id/night_temperature_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/day_temperature_seekbar"
+                android:text="@string/live_display_night"
+                android:paddingTop="10dip" />
+        <TextView android:id="@+id/night_temperature_value"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/day_temperature_seekbar"
+                android:layout_alignParentRight="true"
+                android:paddingTop="10dip" />
+        <SeekBar android:id="@+id/night_temperature_seekbar"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/night_temperature_text"
+                android:paddingTop="2dip" />
+
+        <ImageView android:id="@+id/black_scale_picture_color"
+                android:src="@drawable/color_temperature_preview"
+                android:layout_width="match_parent"
+                android:layout_height="40dip"
+                android:layout_below="@id/night_temperature_seekbar"
+                android:paddingTop="20dip" />
+
+    </RelativeLayout>
+</ScrollView>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index eb01190..e871ff3 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -16,4 +16,11 @@
 
 <resources>
     <attr name="preferenceBackgroundColor" format="color" />
+
+    <declare-styleable name="IntervalSeekBar">
+        <attr name="min" format="float" />
+        <attr name="max" format="float" />
+        <attr name="defaultValue" />
+        <attr name="digits" format="integer" />
+    </declare-styleable>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index bf1c733..0158414 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,8 +21,8 @@
     <string name="dlg_ok">OK</string>
     <string name="cancel">Cancel</string>
     <string name="add">Add</string>
-        <string name="choose_app">Choose app</string>
-        <string name="reset">Reset</string>
+    <string name="choose_app">Choose app</string>
+    <string name="reset">Reset</string>
     <string name="advanced">Advanced</string>
 
     <!-- Privacy Settings Header item -->
@@ -96,5 +96,52 @@
     <string name="led_notification_text">LED light enabled by settings</string>
     <string name="notification_light_no_apps_summary">To add per app control, activate \'%1$s\' and press \'\u002b\' on the menu bar</string>
 
+    <!-- LiveDisplay -->
+    <string name="live_display_summary">Optimize your screen based on time of day and ambient conditions to improve readability and reduce eyestrain</string>
+    <string name="live_display_mode">Display mode</string>
+    <string name="live_display_color_temperature_title">Color temperature</string>
+    <string name="live_display_color_temperature_summary">Day: <xliff:g id="day_temperature">%1$d</xliff:g>K  Night: <xliff:g id="night_temperature">%2$d</xliff:g>K</string>
+    <string name="live_display_color_temperature_label"><xliff:g id="degrees">%1$d</xliff:g>K</string>
+    <string name="live_display_day">Day</string>
+    <string name="live_display_night">Night</string>
+    <string name="live_display_outdoor_mode_title">Automatic outdoor mode</string>
+    <string name="live_display_outdoor_mode_summary">Increase brightness and saturation automatically under bright sunlight</string>
+    <string name="live_display_low_power_title">Reduce power consumption</string>
+    <string name="live_display_low_power_summary">Adjust display for lowest power consumption without degradation</string>
+    <string name="live_display_enhance_color_title">Enhance colors</string>
+    <string name="live_display_enhance_color_summary">Improve color vibrance of flesh tones, scenery, and other images</string>
+    <string name="live_display_color_profile_title">Color profile</string>
+    <string name="live_display_color_profile_standard_title">Standard</string>
+   <string name="live_display_color_profile_standard_summary">Accurate colors and bright whites</string>
+    <string name="live_display_color_profile_natural_title">Natural</string>
+    <string name="live_display_color_profile_natural_summary">Realistic colors and flesh tones</string>
+    <string name="live_display_color_profile_dynamic_title">Dynamic</string>
+    <string name="live_display_color_profile_dynamic_summary">Enhanced colors and bright whites</string>
+    <string name="live_display_color_profile_cinema_title">Cinema</string>
+    <string name="live_display_color_profile_cinema_summary">Perfect color reproduction for video</string>
+    <string name="live_display_color_profile_astronomy_title">Astronomy</string>
+    <string name="live_display_color_profile_astronomy_summary">Deep red for preserving night vision</string>
+    <string name="live_display_color_profile_photography_title">Photography</string>
+    <string name="live_display_color_profile_photography_summary">Perfect color reproduction for photos</string>
+    <string name="live_display_color_profile_basic_title">Basic</string>
+    <string name="live_display_color_profile_basic_summary">Use the display uncalibrated</string>
+    <string name="live_display_color_profile_adaptive_title">Adaptive</string>
+    <string name="live_display_color_profile_adaptive_summary">Colors adapt to ambient conditions</string>
+    <string name="color_calibration_title">Color calibration</string>
+    <string name="color_calibration_summary">Calibrate on-screen colors</string>
+    <string name="color_red_title">Red</string>
+    <string name="color_green_title">Green</string>
+    <string name="color_blue_title">Blue</string>
+    
+
+    <!-- LiveDisplay : Picture Adjustment -->
+    <string name="picture_adjustment_title">Picture adjustment</string>
+    <string name="picture_adjustment_summary">Adjust hue, saturation, intensity, and contrast</string>
+    <string name="adj_hue_title">Hue</string>
+    <string name="adj_saturation_title">Saturation</string>
+    <string name="adj_intensity_title">Intensity</string>
+    <string name="adj_contrast_title">Contrast</string>
+
 </resources>
 
+
diff --git a/res/xml/livedisplay.xml b/res/xml/livedisplay.xml
new file mode 100644
index 0000000..ef1d9bd
--- /dev/null
+++ b/res/xml/livedisplay.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2015 The CyanogenMod 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.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <PreferenceCategory
+        android:key="live_display_options"
+        android:title="@*cyanogenmod.platform:string/live_display_title">
+
+        <!-- Color profile -->
+        <ListPreference
+                android:key="live_display_color_profile"
+                android:title="@string/live_display_color_profile_title"
+                android:persistent="false" />
+
+        <ListPreference
+                android:key="live_display"
+                android:title="@string/live_display_mode"
+                android:persistent="false" />
+
+        <!-- Manual temperature selection -->
+        <org.cyanogenmod.cmparts.livedisplay.DisplayTemperature
+                android:key="live_display_color_temperature"
+                android:title="@string/live_display_color_temperature_title"
+                android:dialogTitle="@*cyanogenmod.platform:string/live_display_title"
+                android:persistent="false" />
+
+        <!-- Outdoor mode / SRE -->
+        <cyanogenmod.preference.CMSystemSettingSwitchPreference
+                android:key="display_auto_outdoor_mode"
+                android:title="@string/live_display_outdoor_mode_title"
+                android:summary="@string/live_display_outdoor_mode_summary"
+                android:defaultValue="@*cyanogenmod.platform:bool/config_defaultAutoOutdoorMode" />
+
+    </PreferenceCategory>
+
+    <PreferenceCategory
+            android:key="advanced"
+            android:title="@string/advanced">
+
+        <!-- RGB display color adjustments -->
+        <org.cyanogenmod.cmparts.livedisplay.DisplayColor
+                android:key="color_calibration"
+                android:title="@string/color_calibration_title"
+                android:dialogTitle="@string/color_calibration_title"
+                android:summary="@string/color_calibration_summary"
+                android:persistent="false"/>
+
+        <!-- HSIC display color adjustments -->
+        <org.cyanogenmod.cmparts.livedisplay.PictureAdjustment
+                android:key="picture_adjustment"
+                android:title="@string/picture_adjustment_title"
+                android:dialogTitle="@string/picture_adjustment_title"
+                android:summary="@string/picture_adjustment_summary"
+                android:persistent="false"/>
+
+        <!-- Adaptive backlight -->
+        <cyanogenmod.preference.CMSystemSettingSwitchPreference
+                android:key="display_low_power"
+                android:title="@string/live_display_low_power_title"
+                android:summary="@string/live_display_low_power_summary"
+                android:defaultValue="@*cyanogenmod.platform:bool/config_defaultCABC" />
+
+        <!-- Color enhancement -->
+        <cyanogenmod.preference.CMSystemSettingSwitchPreference
+                android:key="display_color_enhance"
+                android:title="@string/live_display_enhance_color_title"
+                android:summary="@string/live_display_enhance_color_summary"
+                android:defaultValue="@*cyanogenmod.platform:bool/config_defaultColorEnhancement" />
+
+    </PreferenceCategory>
+
+</PreferenceScreen>