[TP] Clock color saturation slider
Add clock color saturation slider
Test: Manually tested that the slider works with motion gesture
Bug: 241966062
Change-Id: I2327e7c58c665169b4b89e09566be13f76a30a66
diff --git a/res/drawable/ic_contrast.xml b/res/drawable/ic_contrast.xml
new file mode 100644
index 0000000..6e9f3bd
--- /dev/null
+++ b/res/drawable/ic_contrast.xml
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:autoMirrored="true"
+ android:tint="@color/text_color_primary_inverse"
+ android:viewportHeight="24"
+ android:viewportWidth="24">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M12,22Q9.925,22 8.1,21.212Q6.275,20.425 4.925,19.075Q3.575,17.725 2.788,15.9Q2,14.075 2,12Q2,9.925 2.788,8.1Q3.575,6.275 4.925,4.925Q6.275,3.575 8.1,2.787Q9.925,2 12,2Q14.075,2 15.9,2.787Q17.725,3.575 19.075,4.925Q20.425,6.275 21.212,8.1Q22,9.925 22,12Q22,14.075 21.212,15.9Q20.425,17.725 19.075,19.075Q17.725,20.425 15.9,21.212Q14.075,22 12,22ZM13,19.925Q15.975,19.55 17.988,17.312Q20,15.075 20,12Q20,8.925 17.988,6.687Q15.975,4.45 13,4.075Z" />
+</vector>
\ No newline at end of file
diff --git a/res/drawable/saturation_progress_drawable.xml b/res/drawable/saturation_progress_drawable.xml
new file mode 100644
index 0000000..6ba7e81
--- /dev/null
+++ b/res/drawable/saturation_progress_drawable.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source 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.
+ -->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
+ android:paddingMode="stack" >
+ <item android:id="@android:id/background"
+ android:gravity="center_vertical|fill_horizontal">
+ <inset
+ android:insetLeft="22dp"
+ android:insetRight="22dp" >
+ <shape>
+ <size android:height="4dp" />
+ <corners android:radius="2dp" />
+ <solid android:color="@color/color_surface_variant" />
+ </shape>
+ </inset>
+ </item>
+ <item android:id="@android:id/progress"
+ android:gravity="center_vertical|fill_horizontal">
+ <com.android.customization.picker.clock.ui.view.SaturationProgressDrawable
+ android:drawable="@drawable/saturation_progress_full_drawable"
+ />
+ </item>
+</layer-list>
\ No newline at end of file
diff --git a/res/drawable/saturation_progress_full_drawable.xml b/res/drawable/saturation_progress_full_drawable.xml
new file mode 100644
index 0000000..9d14bcd
--- /dev/null
+++ b/res/drawable/saturation_progress_full_drawable.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source 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.
+ -->
+
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
+ android:autoMirrored="true">
+ <item android:id="@+id/slider_foreground"
+ android:height="48dp">
+ <shape>
+ <size android:height="48dp" />
+ <solid android:color="@color/color_accent_primary" />
+ <corners android:radius="24dp"/>
+ </shape>
+ </item>
+ <item
+ android:id="@+id/slider_icon"
+ android:gravity="center_vertical|right"
+ android:height="20dp"
+ android:width="20dp"
+ android:right="14dp"
+ android:drawable="@drawable/ic_contrast" />
+</layer-list>
\ No newline at end of file
diff --git a/res/layout/fragment_clock_settings.xml b/res/layout/fragment_clock_settings.xml
index 696d6eb..3258083 100644
--- a/res/layout/fragment_clock_settings.xml
+++ b/res/layout/fragment_clock_settings.xml
@@ -98,31 +98,50 @@
android:layout_height="wrap_content"
android:paddingTop="16dp">
- <FrameLayout
- android:id="@+id/color_options_container"
+ <LinearLayout
+ android:id="@+id/color_picker_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/color_options"
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:clipToPadding="false"
- android:paddingHorizontal="16dp" />
+ android:layout_marginBottom="16dp">
- <!--
- This is just an invisible placeholder put in place so that the parent keeps its
- height stable as the RecyclerView updates from 0 items to N items. Keeping it stable
- allows the layout logic to keep the size of the preview container stable as well,
- which bodes well for setting up the SurfaceView for remote rendering without
- changing its size after the content is loaded into the RecyclerView.
- -->
- <include
- layout="@layout/color_option_with_background"
- android:layout_width="wrap_content"
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/color_options"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:clipToPadding="false"
+ android:paddingHorizontal="16dp" />
+
+ <!--
+ This is just an invisible placeholder put in place so that the parent keeps its
+ height stable as the RecyclerView updates from 0 items to N items. Keeping it
+ stable allows the layout logic to keep the size of the preview container stable
+ as well, which bodes well for setting up the SurfaceView for remote rendering
+ without changing its size after the content is loaded into the RecyclerView.
+ -->
+ <include
+ layout="@layout/color_option_with_background"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="invisible" />
+ </FrameLayout>
+
+ <SeekBar
+ android:id="@+id/slider"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:visibility="invisible" />
- </FrameLayout>
+ android:layout_gravity="center_vertical"
+ android:minHeight="48dp"
+ android:thumb="@null"
+ android:background="@null"
+ android:paddingHorizontal="16dp"
+ android:progressDrawable="@drawable/saturation_progress_drawable"
+ android:splitTrack="false" />
+ </LinearLayout>
<com.android.customization.picker.clock.ui.view.ClockSizeRadioButtonGroup
android:id="@+id/clock_size_radio_button_group"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 288dd19..377d4eb 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -18,4 +18,9 @@
<resources>
<item name="linear_layout_horizontal_display_options_max" format="float" type="dimen">4.35
</item>
+
+ <declare-styleable name="SaturationAlphaTintDrawableWrapper">
+ <attr name="android:tint" />
+ <attr name="android:alpha" />
+ </declare-styleable>
</resources>
\ No newline at end of file