Remove font customization and introduce clock size tab
Test: Manually tested
Bug: 395647577
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I0fc4191740bfea9164a600a9cd528f62cc5ef174
diff --git a/res/drawable/ic_font_size_filled_24px.xml b/res/drawable/ic_font_size_filled_24px.xml
new file mode 100644
index 0000000..b37e8e6
--- /dev/null
+++ b/res/drawable/ic_font_size_filled_24px.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2024 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.
+ ~
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="960"
+ android:viewportHeight="960"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M560,800L560,280L360,280L360,160L880,160L880,280L680,280L680,800L560,800ZM200,800L200,480L80,480L80,360L440,360L440,480L320,480L320,800L200,800Z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/clock_style_option.xml b/res/layout/clock_style_option.xml
index fa20706..c59a9d4 100644
--- a/res/layout/clock_style_option.xml
+++ b/res/layout/clock_style_option.xml
@@ -14,57 +14,25 @@
limitations under the License.
-->
<!-- Content description is set programmatically on the parent FrameLayout -->
-<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="@dimen/floating_sheet_clock_style_option_width"
- android:layout_height="@dimen/floating_sheet_clock_style_option_height"
- xmlns:app="http://schemas.android.com/apk/res-auto"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="@dimen/floating_sheet_clock_style_option_size"
+ android:layout_height="@dimen/floating_sheet_clock_style_option_size"
android:clipToPadding="false"
android:clipChildren="false">
<com.android.wallpaper.picker.option.ui.view.OptionItemBackground
android:id="@id/background"
- android:layout_width="@dimen/floating_sheet_clock_style_option_background_size"
- android:layout_height="@dimen/floating_sheet_clock_style_option_background_size"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
- android:importantForAccessibility="no"
- android:layout_gravity="bottom" />
+ android:layout_width="@dimen/floating_sheet_clock_style_option_size"
+ android:layout_height="@dimen/floating_sheet_clock_style_option_size"
+ android:layout_gravity="center"
+ android:importantForAccessibility="no" />
<ImageView
android:id="@+id/foreground"
android:layout_width="@dimen/floating_sheet_clock_style_option_thumbnail_size"
android:layout_height="@dimen/floating_sheet_clock_style_option_thumbnail_size"
- android:layout_marginBottom="@dimen/floating_sheet_clock_style_thumbnail_margin_bottom"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintBottom_toBottomOf="parent"
+ android:layout_gravity="center"
android:src="@drawable/ic_clock_24px" />
-
- <FrameLayout
- android:id="@+id/edit_icon"
- android:layout_width="@dimen/floating_sheet_clock_edit_icon_size"
- android:layout_height="@dimen/floating_sheet_clock_edit_icon_size"
- android:layout_marginTop="@dimen/floating_sheet_clock_edit_icon_margin"
- android:layout_marginEnd="@dimen/floating_sheet_clock_edit_icon_margin"
- app:layout_constraintEnd_toEndOf="@+id/background"
- app:layout_constraintTop_toTopOf="@+id/background" >
- <ImageView
- android:id="@+id/edit_icon_background"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/edit_icon_background"
- android:importantForAccessibility="no" />
-
- <ImageView
- android:id="@+id/edit_icon_foreground"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:src="@drawable/edit_icon_foreground"
- android:importantForAccessibility="no" />
- </FrameLayout>
-
-
-</androidx.constraintlayout.widget.ConstraintLayout>
+</FrameLayout>
diff --git a/res/layout/floating_sheet_clock.xml b/res/layout/floating_sheet_clock.xml
index 6b757be..2e98b4f 100644
--- a/res/layout/floating_sheet_clock.xml
+++ b/res/layout/floating_sheet_clock.xml
@@ -41,8 +41,8 @@
android:layout_height="wrap_content" />
<include
- layout="@layout/floating_sheet_clock_font_content"
- android:id="@+id/clock_floating_sheet_font_content"
+ layout="@layout/floating_sheet_clock_size_content"
+ android:id="@+id/clock_floating_sheet_size_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
@@ -66,28 +66,5 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
-
- <LinearLayout
- android:id="@+id/clock_font_toolbar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:layout_gravity="center_horizontal">
-
- <ImageView
- android:id="@+id/clock_font_revert"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/clock_font_revert"
- android:contentDescription="@string/clock_font_editor_revert" />
-
- <ImageView
- android:id="@+id/clock_font_apply"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingStart="@dimen/clock_font_apply_padding_start"
- android:src="@drawable/clock_font_apply"
- android:contentDescription="@string/clock_font_editor_apply" />
- </LinearLayout>
</FrameLayout>
</LinearLayout>
diff --git a/res/layout/floating_sheet_clock_font_content.xml b/res/layout/floating_sheet_clock_font_content.xml
deleted file mode 100644
index ba6c70c..0000000
--- a/res/layout/floating_sheet_clock_font_content.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
- ~ Copyright (C) 2024 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.
- -->
-
-<androidx.constraintlayout.widget.ConstraintLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:id="@+id/clock_floating_sheet_font_content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingVertical="@dimen/floating_sheet_content_vertical_padding"
- android:paddingHorizontal="@dimen/floating_sheet_content_horizontal_padding"
- android:clipChildren="false"
- android:clipToPadding="false">
-
- <TextView
- android:id="@+id/clock_axis_slider_name1"
- android:layout_width="@dimen/clock_font_axis_name_width"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toTopOf="@+id/barrier1"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/clock_axis_slider1"
- android:layout_marginVertical="@dimen/clock_axis_control_slider_row_margin_vertical"
- android:layout_marginEnd="@dimen/clock_axis_control_text_margin_end"
- android:lines="1"
- android:ellipsize="end"
- style="@style/CustomizationOptionEntryTitleTextStyle"
- android:text="@string/tab_placeholder_text" />
-
- <com.google.android.material.slider.Slider
- android:id="@+id/clock_axis_slider1"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:minHeight="@dimen/accessibility_min_height"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toTopOf="@+id/barrier1"
- app:layout_constraintStart_toEndOf="@+id/clock_axis_slider_name1"
- app:layout_constraintEnd_toEndOf="parent"
- android:layout_marginVertical="@dimen/clock_axis_control_slider_row_margin_vertical"
- app:trackHeight="@dimen/slider_track_height"
- app:thumbHeight="@dimen/slider_thumb_height"
- android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
-
- <androidx.constraintlayout.widget.Barrier
- android:id="@+id/barrier1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:barrierDirection="bottom"
- app:constraint_referenced_ids="clock_axis_slider1,clock_axis_slider_name1" />
-
- <TextView
- android:id="@+id/clock_axis_slider_name2"
- android:layout_width="@dimen/clock_font_axis_name_width"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier1"
- app:layout_constraintBottom_toTopOf="@+id/barrier2"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/clock_axis_slider2"
- android:layout_marginVertical="@dimen/clock_axis_control_slider_row_margin_vertical"
- android:layout_marginEnd="@dimen/clock_axis_control_text_margin_end"
- android:lines="1"
- android:ellipsize="end"
- style="@style/CustomizationOptionEntryTitleTextStyle"
- android:text="@string/tab_placeholder_text" />
-
- <com.google.android.material.slider.Slider
- android:id="@+id/clock_axis_slider2"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:minHeight="@dimen/accessibility_min_height"
- app:layout_constraintTop_toBottomOf="@+id/barrier1"
- app:layout_constraintBottom_toTopOf="@+id/barrier2"
- app:layout_constraintStart_toEndOf="@+id/clock_axis_slider_name2"
- app:layout_constraintEnd_toEndOf="parent"
- android:layout_marginVertical="@dimen/clock_axis_control_slider_row_margin_vertical"
- app:trackHeight="@dimen/slider_track_height"
- app:thumbHeight="@dimen/slider_thumb_height"
- android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
-
- <androidx.constraintlayout.widget.Barrier
- android:id="@+id/barrier2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:barrierDirection="bottom"
- app:constraint_referenced_ids="clock_axis_slider2,clock_axis_slider_name2" />
-
- <TextView
- android:id="@+id/clock_axis_switch_name1"
- android:layout_width="@dimen/clock_font_axis_name_width"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier2"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- android:layout_marginVertical="@dimen/clock_axis_control_switch_row_margin_vertical"
- android:lines="1"
- android:ellipsize="end"
- style="@style/CustomizationOptionEntryTitleTextStyle"
- android:text="@string/tab_placeholder_text" />
-
- <com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/clock_axis_switch1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier2"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toEndOf="@+id/clock_axis_switch_name1"
- android:layout_marginVertical="@dimen/clock_axis_control_switch_row_margin_vertical"
- android:layout_marginStart="@dimen/clock_axis_control_text_margin_end"
- android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
-
- <ImageView
- android:id="@+id/divider"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier2"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="0.5"
- android:src="@drawable/clock_font_switch_divider"
- android:importantForAccessibility="no" />
-
- <TextView
- android:id="@+id/clock_axis_switch_name2"
- android:layout_width="@dimen/clock_font_axis_name_width"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier2"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/clock_axis_switch2"
- android:layout_marginVertical="@dimen/clock_axis_control_switch_row_margin_vertical"
- android:layout_marginEnd="@dimen/clock_axis_control_text_margin_end"
- android:lines="1"
- android:ellipsize="end"
- style="@style/CustomizationOptionEntryTitleTextStyle"
- android:text="@string/tab_placeholder_text" />
-
- <com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/clock_axis_switch2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_constraintTop_toBottomOf="@+id/barrier2"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- android:layout_marginVertical="@dimen/clock_axis_control_switch_row_margin_vertical"
- android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
-</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/res/layout/floating_sheet_clock_size_content.xml b/res/layout/floating_sheet_clock_size_content.xml
new file mode 100644
index 0000000..e6c41f2
--- /dev/null
+++ b/res/layout/floating_sheet_clock_size_content.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2025 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.
+ -->
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingVertical="@dimen/floating_sheet_content_vertical_padding"
+ android:clipToPadding="false"
+ android:clipChildren="false">
+
+ <TextView
+ android:id="@+id/clock_style_clock_size_title"
+ style="@style/CustomizationOptionEntryTitleTextStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:text="@string/clock_size_large"
+ android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
+ android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
+ app:layout_constraintTop_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@+id/clock_style_clock_size_description" />
+
+ <TextView
+ android:id="@+id/clock_style_clock_size_description"
+ style="@style/CustomizationOptionEntrySubtitleTextStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
+ android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
+ android:text="@string/clock_size_large_description"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
+ app:layout_constraintTop_toBottomOf="@+id/clock_style_clock_size_title"
+ app:layout_constraintBottom_toBottomOf="parent" />
+
+ <com.google.android.material.materialswitch.MaterialSwitch
+ android:id="@+id/clock_style_clock_size_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/floating_sheet_content_horizontal_padding"
+ app:layout_constraintTop_toTopOf="@+id/clock_style_clock_size_title"
+ app:layout_constraintBottom_toBottomOf="@+id/clock_style_clock_size_description"
+ app:layout_constraintEnd_toEndOf="parent"
+ android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/floating_sheet_clock_style_content.xml b/res/layout/floating_sheet_clock_style_content.xml
index 0339e26..2dc9b33 100644
--- a/res/layout/floating_sheet_clock_style_content.xml
+++ b/res/layout/floating_sheet_clock_style_content.xml
@@ -13,86 +13,33 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<androidx.constraintlayout.widget.ConstraintLayout
+<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/floating_sheet_clock_style_content_top_padding"
- android:paddingBottom="@dimen/floating_sheet_clock_style_content_bottom_padding"
+ android:paddingVertical="@dimen/floating_sheet_content_vertical_padding"
android:clipToPadding="false"
android:clipChildren="false">
- <FrameLayout
- android:id="@+id/clock_style_list_container"
- android:layout_width="0dp"
+ <!--
+ This is 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.
+
+ It's critical for any TextViews inside the included layout to have text.
+ -->
+ <include
+ layout="@layout/clock_style_option"
+ android:layout_width="@dimen/floating_sheet_clock_style_option_size"
+ android:layout_height="@dimen/floating_sheet_clock_style_option_size"
+ android:visibility="invisible" />
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/clock_style_list"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintBottom_toTopOf="@+id/clock_style_clock_size_title"
- android:layout_marginBottom="@dimen/floating_sheet_clock_style_option_list_margin_bottom"
- android:clipToPadding="false"
- android:clipChildren="false">
-
- <!--
- This is 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.
-
- It's critical for any TextViews inside the included layout to have text.
- -->
- <include
- layout="@layout/clock_style_option"
- android:layout_width="@dimen/floating_sheet_clock_style_option_width"
- android:layout_height="@dimen/floating_sheet_clock_style_option_height"
- android:visibility="invisible" />
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/clock_style_list"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clipChildren="false"
- android:clipToPadding="false"/>
- </FrameLayout>
-
- <TextView
- android:id="@+id/clock_style_clock_size_title"
- style="@style/CustomizationOptionEntryTitleTextStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="@string/clock_size_large"
- android:layout_marginTop="8dp"
- android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
- android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
- app:layout_constraintTop_toBottomOf="@+id/clock_style_list_container"
- app:layout_constraintBottom_toTopOf="@+id/clock_style_clock_size_description" />
-
- <TextView
- android:id="@+id/clock_style_clock_size_description"
- style="@style/CustomizationOptionEntrySubtitleTextStyle"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/floating_sheet_content_horizontal_padding"
- android:layout_marginEnd="@dimen/floating_sheet_clock_style_clock_size_text_margin_end"
- android:text="@string/clock_size_large_description"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/clock_style_clock_size_switch"
- app:layout_constraintTop_toBottomOf="@+id/clock_style_clock_size_title"
- app:layout_constraintBottom_toBottomOf="parent" />
-
- <com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/clock_style_clock_size_switch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginEnd="@dimen/floating_sheet_content_horizontal_padding"
- app:layout_constraintTop_toTopOf="@+id/clock_style_clock_size_title"
- app:layout_constraintBottom_toBottomOf="@+id/clock_style_clock_size_description"
- app:layout_constraintEnd_toEndOf="parent"
- android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
-</androidx.constraintlayout.widget.ConstraintLayout>
+ android:clipChildren="false"
+ android:clipToPadding="false"/>
+</FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d335636..531523b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -182,8 +182,6 @@
<!-- Floating sheet dimensions -->
<dimen name="floating_sheet_content_vertical_padding">20dp</dimen>
<dimen name="floating_sheet_content_horizontal_padding">20dp</dimen>
- <dimen name="floating_sheet_clock_style_content_top_padding">2dp</dimen>
- <dimen name="floating_sheet_clock_style_content_bottom_padding">20dp</dimen>
<dimen name="floating_sheet_horizontal_padding">16dp</dimen>
<dimen name="floating_sheet_tab_toolbar_vertical_margin">8dp</dimen>
<dimen name="floating_sheet_tab_clock_font_toolbar_top_margin">16dp</dimen>
@@ -191,14 +189,10 @@
<dimen name="floating_sheet_list_item_horizontal_space">4dp</dimen>
<dimen name="floating_sheet_grid_list_item_horizontal_space">10dp</dimen>
<dimen name="floating_sheet_list_item_vertical_space">4dp</dimen>
- <dimen name="floating_sheet_clock_style_option_list_margin_bottom">8dp</dimen>
- <dimen name="floating_sheet_clock_style_option_width">80dp</dimen>
- <dimen name="floating_sheet_clock_style_option_height">98dp</dimen>
- <dimen name="floating_sheet_clock_style_option_background_size">80dp</dimen>
+ <dimen name="floating_sheet_clock_style_option_size">80dp</dimen>
<dimen name="floating_sheet_clock_style_option_thumbnail_size">56dp</dimen>
<dimen name="floating_sheet_clock_edit_icon_size">48dp</dimen>
<dimen name="floating_sheet_clock_edit_icon_margin">-18dp</dimen>
- <dimen name="floating_sheet_clock_style_thumbnail_margin_bottom">12dp</dimen>
<dimen name="floating_sheet_clock_style_clock_size_text_margin_end">16dp</dimen>
<dimen name="floating_sheet_color_option_size">54dp</dimen>
<dimen name="floating_sheet_color_option_stroke_width">3dp</dimen>
diff --git a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
index 09a55e9..c08bafa 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
@@ -25,7 +25,6 @@
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver.OnGlobalLayoutListener
-import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.core.graphics.drawable.DrawableCompat
@@ -42,13 +41,9 @@
import com.android.customization.picker.color.ui.view.ColorOptionIconView2
import com.android.customization.picker.color.ui.viewmodel.ColorOptionIconViewModel
import com.android.customization.picker.common.ui.view.SingleRowListItemSpacing
-import com.android.systemui.plugins.clocks.AxisType
import com.android.themepicker.R
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK
-import com.android.wallpaper.customization.ui.view.ClockFontSliderViewHolder
-import com.android.wallpaper.customization.ui.view.ClockFontSwitchViewHolder
import com.android.wallpaper.customization.ui.viewmodel.ClockFloatingSheetHeightsViewModel
-import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.ClockStyleModel
import com.android.wallpaper.customization.ui.viewmodel.ClockPickerViewModel.Tab
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
@@ -124,8 +119,6 @@
// Clock style
val clockStyleContent = view.requireViewById<View>(R.id.clock_floating_sheet_style_content)
- val clockSizeSwitch =
- clockStyleContent.requireViewById<MaterialSwitch>(R.id.clock_style_clock_size_switch)
val isClockStyleActive = {
isFloatingSheetActive() && viewModel.selectedTab.value == Tab.STYLE
}
@@ -139,59 +132,6 @@
view.requireViewById<RecyclerView>(R.id.clock_style_list).apply {
initStyleList(appContext, clockStyleAdapter)
}
- ColorUpdateBinder.bind(
- setColor = { color ->
- clockStyleContent
- .requireViewById<TextView>(R.id.clock_style_clock_size_title)
- .setTextColor(color)
- },
- color = colorUpdateViewModel.colorOnSurface,
- shouldAnimate = isClockStyleActive,
- lifecycleOwner = lifecycleOwner,
- )
- ColorUpdateBinder.bind(
- setColor = { color ->
- clockStyleContent
- .requireViewById<TextView>(R.id.clock_style_clock_size_description)
- .setTextColor(color)
- },
- color = colorUpdateViewModel.colorOnSurfaceVariant,
- shouldAnimate = isClockStyleActive,
- lifecycleOwner = lifecycleOwner,
- )
-
- // Clock font editor
- val clockFontContent =
- view.requireViewById<ViewGroup>(R.id.clock_floating_sheet_font_content)
- val clockFontToolbar = view.requireViewById<ViewGroup>(R.id.clock_font_toolbar)
- clockFontToolbar.requireViewById<View>(R.id.clock_font_revert).setOnClickListener {
- viewModel.cancelFontAxes()
- }
- clockFontToolbar.requireViewById<View>(R.id.clock_font_apply).setOnClickListener {
- viewModel.confirmFontAxes()
- }
- val isClockFontActive = {
- isFloatingSheetActive() && viewModel.selectedTab.value == Tab.FONT
- }
- ColorUpdateBinder.bind(
- setColor = { color ->
- clockFontContent
- .requireViewById<TextView>(R.id.clock_axis_slider_name1)
- .setTextColor(color)
- clockFontContent
- .requireViewById<TextView>(R.id.clock_axis_slider_name2)
- .setTextColor(color)
- clockFontContent
- .requireViewById<TextView>(R.id.clock_axis_switch_name1)
- .setTextColor(color)
- clockFontContent
- .requireViewById<TextView>(R.id.clock_axis_switch_name2)
- .setTextColor(color)
- },
- color = colorUpdateViewModel.colorOnSurface,
- shouldAnimate = isClockFontActive,
- lifecycleOwner = lifecycleOwner,
- )
// Clock color
val clockColorContent = view.requireViewById<View>(R.id.clock_floating_sheet_color_content)
@@ -251,6 +191,31 @@
lifecycleOwner = lifecycleOwner,
)
+ // Clock size
+ val clockSizeContent = view.requireViewById<View>(R.id.clock_floating_sheet_size_content)
+ val clockSizeSwitch =
+ clockSizeContent.requireViewById<MaterialSwitch>(R.id.clock_style_clock_size_switch)
+ ColorUpdateBinder.bind(
+ setColor = { color ->
+ clockSizeContent
+ .requireViewById<TextView>(R.id.clock_style_clock_size_title)
+ .setTextColor(color)
+ },
+ color = colorUpdateViewModel.colorOnSurface,
+ shouldAnimate = isClockStyleActive,
+ lifecycleOwner = lifecycleOwner,
+ )
+ ColorUpdateBinder.bind(
+ setColor = { color ->
+ clockSizeContent
+ .requireViewById<TextView>(R.id.clock_style_clock_size_description)
+ .setTextColor(color)
+ },
+ color = colorUpdateViewModel.colorOnSurfaceVariant,
+ shouldAnimate = isClockStyleActive,
+ lifecycleOwner = lifecycleOwner,
+ )
+
clockStyleContent.viewTreeObserver.addOnGlobalLayoutListener(
object : OnGlobalLayoutListener {
override fun onGlobalLayout() {
@@ -285,18 +250,18 @@
}
)
- clockFontContent.viewTreeObserver.addOnGlobalLayoutListener(
+ clockSizeContent.viewTreeObserver.addOnGlobalLayoutListener(
object : OnGlobalLayoutListener {
override fun onGlobalLayout() {
if (
- clockFontContent.height != 0 &&
- _clockFloatingSheetHeights.value.clockFontContentHeight == null
+ clockSizeContent.height != 0 &&
+ _clockFloatingSheetHeights.value.clockSizeContentHeight == null
) {
_clockFloatingSheetHeights.value =
_clockFloatingSheetHeights.value.copy(
- clockFontContentHeight = clockFontContent.height
+ clockSizeContentHeight = clockSizeContent.height
)
- clockColorContent.viewTreeObserver.removeOnGlobalLayoutListener(this)
+ clockSizeContent.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
}
}
@@ -313,18 +278,18 @@
val (
clockStyleContentHeight,
clockColorContentHeight,
- clockFontContentHeight) =
+ clockSizeContentHeight) =
heights
clockStyleContentHeight ?: return@collect
clockColorContentHeight ?: return@collect
- clockFontContentHeight ?: return@collect
+ clockSizeContentHeight ?: return@collect
val fromHeight = floatingSheetContainer.height
val toHeight =
when (selectedTab) {
Tab.STYLE -> clockStyleContentHeight
Tab.COLOR -> clockColorContentHeight
- Tab.FONT -> clockFontContentHeight
+ Tab.SIZE -> clockSizeContentHeight
}
// Start to animate the content height
ValueAnimator.ofInt(fromHeight, toHeight)
@@ -343,18 +308,14 @@
clockStyleContent.alpha = 1f
clockColorContent.isVisible = selectedTab == Tab.COLOR
clockColorContent.alpha = 1f
- clockFontContent.isVisible = selectedTab == Tab.FONT
- clockFontContent.alpha = 1f
+ clockSizeContent.isVisible = selectedTab == Tab.SIZE
+ clockSizeContent.alpha = 1f
currentContent =
when (selectedTab) {
Tab.STYLE -> clockStyleContent
Tab.COLOR -> clockColorContent
- Tab.FONT -> clockFontContent
+ Tab.SIZE -> clockSizeContent
}
- // Also update the floating toolbar when the height
- // animation ends.
- tabs.isVisible = selectedTab != Tab.FONT
- clockFontToolbar.isVisible = selectedTab == Tab.FONT
}
}
)
@@ -431,121 +392,6 @@
}
}
}
-
- bindClockFontContent(
- clockFontContent = clockFontContent,
- viewModel = viewModel,
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = isClockFontActive,
- lifecycleOwner = lifecycleOwner,
- )
- }
-
- private fun bindClockFontContent(
- clockFontContent: View,
- viewModel: ClockPickerViewModel,
- colorUpdateViewModel: ColorUpdateViewModel,
- shouldAnimateColor: () -> Boolean,
- lifecycleOwner: LifecycleOwner,
- ) {
- val slider1 =
- clockFontContent.requireViewById<Slider>(R.id.clock_axis_slider1).also {
- SliderColorBinder.bind(
- slider = it,
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- }
- val slider2 =
- clockFontContent.requireViewById<Slider>(R.id.clock_axis_slider2).also {
- SliderColorBinder.bind(
- slider = it,
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- }
- val sliderViewList =
- listOf(
- ClockFontSliderViewHolder(
- name = clockFontContent.requireViewById(R.id.clock_axis_slider_name1),
- slider = slider1,
- ),
- ClockFontSliderViewHolder(
- name = clockFontContent.requireViewById(R.id.clock_axis_slider_name2),
- slider = slider2,
- ),
- )
- val switchViewList =
- listOf(
- ClockFontSwitchViewHolder(
- name = clockFontContent.requireViewById(R.id.clock_axis_switch_name1),
- switch = clockFontContent.requireViewById(R.id.clock_axis_switch1),
- ),
- ClockFontSwitchViewHolder(
- name = clockFontContent.requireViewById(R.id.clock_axis_switch_name2),
- switch = clockFontContent.requireViewById(R.id.clock_axis_switch2),
- ),
- )
- val sliderViewMap: MutableMap<String, ClockFontSliderViewHolder> = mutableMapOf()
- val switchViewMap: MutableMap<String, ClockFontSwitchViewHolder> = mutableMapOf()
-
- lifecycleOwner.lifecycleScope.launch {
- lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch {
- viewModel.previewingClockFontAxes.filterNotNull().collect { fontAxes ->
- // This data flow updates only when a new clock style is selected. We
- // initiate the clock font content with regard to that clock style.
- sliderViewMap.clear()
- switchViewMap.clear()
-
- // Initiate the slider views
- val floatAxisList = fontAxes.filter { it.type == AxisType.Float }
- sliderViewList.forEachIndexed { i, viewHolder ->
- val floatAxis = floatAxisList.getOrNull(i)
- viewHolder.setIsVisible(floatAxis != null)
- floatAxis?.let {
- sliderViewMap[floatAxis.key] = viewHolder
- viewHolder.initView(it) { value ->
- viewModel.updatePreviewFontAxis(floatAxis.key, value)
- }
- }
- }
-
- // Initiate the switch views
- val booleanAxisList = fontAxes.filter { it.type == AxisType.Boolean }
- switchViewList.forEachIndexed { i, viewHolder ->
- val booleanAxis = booleanAxisList.getOrNull(i)
- viewHolder.setIsVisible(booleanAxis != null)
- booleanAxis?.let {
- switchViewMap[it.key] = viewHolder
- viewHolder.initView(
- clockFontAxis = booleanAxis,
- onFontAxisValueUpdated = { value ->
- viewModel.updatePreviewFontAxis(booleanAxis.key, value)
- },
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- }
- }
- }
- }
-
- launch {
- viewModel.previewingClockFontAxisMap.collect { axisMap ->
- // This data flow updates when user configures the sliders and switches
- // in the clock font content.
- axisMap.forEach { (key, value) ->
- sliderViewMap[key]?.setValue(value)
- switchViewMap[key]?.setValue(value)
- }
- }
- }
- }
- }
}
private fun createClockStyleOptionItemAdapter(
@@ -560,29 +406,7 @@
view
.findViewById<ImageView>(R.id.foreground)
?.setImageDrawable(styleModel.thumbnail)
- val job =
- lifecycleOwner.lifecycleScope.launch {
- lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- styleModel.showEditButton.collect {
- view.findViewById<FrameLayout>(R.id.edit_icon)?.isVisible = it
- }
- }
- }
- val binding =
- ColorUpdateBinder.bind(
- setColor = { color ->
- view.findViewById<ImageView>(R.id.edit_icon_background)?.drawable?.let {
- DrawableCompat.setTint(DrawableCompat.wrap(it), color)
- }
- },
- color = colorUpdateViewModel.colorOnPrimaryFixedVariant,
- shouldAnimate = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- return@OptionItemAdapter2 DisposableHandle {
- job.cancel()
- binding.destroy()
- }
+ return@OptionItemAdapter2 null
},
colorUpdateViewModel = WeakReference(colorUpdateViewModel),
shouldAnimateColor = shouldAnimateColor,
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
index cb4ab57..f818ff8 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
@@ -16,8 +16,6 @@
package com.android.wallpaper.customization.ui.binder
-import android.animation.ValueAnimator
-import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.Button
import android.widget.FrameLayout
import android.widget.Toolbar
@@ -35,7 +33,6 @@
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK
import com.android.wallpaper.customization.ui.util.ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.SHORTCUTS
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
-import com.android.wallpaper.customization.ui.viewmodel.ToolbarHeightsViewModel
import com.android.wallpaper.picker.customization.ui.binder.ColorUpdateBinder
import com.android.wallpaper.picker.customization.ui.binder.DefaultToolbarBinder
import com.android.wallpaper.picker.customization.ui.binder.ToolbarBinder
@@ -43,7 +40,6 @@
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationOptionsViewModel
import javax.inject.Inject
import javax.inject.Singleton
-import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
@@ -61,8 +57,6 @@
lifecycleOwner: LifecycleOwner,
onNavBack: () -> Unit,
) {
- val toolbarHeights: MutableStateFlow<ToolbarHeightsViewModel?> = MutableStateFlow(null)
-
defaultToolbarBinder.bind(
navButton,
toolbar,
@@ -79,45 +73,6 @@
)
}
- navButton.viewTreeObserver.addOnGlobalLayoutListener(
- object : OnGlobalLayoutListener {
- override fun onGlobalLayout() {
- if (navButton.height != 0) {
- toolbarHeights.value =
- toolbarHeights.value?.copy(navButtonHeight = navButton.height)
- ?: ToolbarHeightsViewModel(navButtonHeight = navButton.height)
- }
- navButton.viewTreeObserver.removeOnGlobalLayoutListener(this)
- }
- }
- )
-
- toolbar.viewTreeObserver.addOnGlobalLayoutListener(
- object : OnGlobalLayoutListener {
- override fun onGlobalLayout() {
- if (toolbar.height != 0) {
- toolbarHeights.value =
- toolbarHeights.value?.copy(toolbarHeight = toolbar.height)
- ?: ToolbarHeightsViewModel(toolbarHeight = toolbar.height)
- }
- navButton.viewTreeObserver.removeOnGlobalLayoutListener(this)
- }
- }
- )
-
- applyButton.viewTreeObserver.addOnGlobalLayoutListener(
- object : OnGlobalLayoutListener {
- override fun onGlobalLayout() {
- if (applyButton.height != 0) {
- toolbarHeights.value =
- toolbarHeights.value?.copy(applyButtonHeight = applyButton.height)
- ?: ToolbarHeightsViewModel(applyButtonHeight = applyButton.height)
- }
- applyButton.viewTreeObserver.removeOnGlobalLayoutListener(this)
- }
- }
- )
-
ColorUpdateBinder.bind(
setColor = { color ->
DrawableCompat.setTint(DrawableCompat.wrap(applyButton.background), color)
@@ -177,53 +132,6 @@
toolbar.title = toolbar.resources.getString(stringResId)
}
}
-
- launch {
- combine(toolbarHeights, viewModel.isToolbarCollapsed, ::Pair).collect {
- (toolbarHeights, isToolbarCollapsed) ->
- val (navButtonHeight, toolbarHeight, applyButtonHeight) =
- toolbarHeights ?: return@collect
- navButtonHeight ?: return@collect
- toolbarHeight ?: return@collect
- applyButtonHeight ?: return@collect
-
- val navButtonToHeight = if (isToolbarCollapsed) 0 else navButtonHeight
- val toolbarToHeight = if (isToolbarCollapsed) 0 else toolbarHeight
- val applyButtonToHeight = if (isToolbarCollapsed) 0 else applyButtonHeight
- ValueAnimator.ofInt(navButton.height, navButtonToHeight)
- .apply {
- addUpdateListener { valueAnimator ->
- val value = valueAnimator.animatedValue as Int
- navButton.layoutParams =
- navButton.layoutParams.apply { height = value }
- }
- duration = ANIMATION_DURATION
- }
- .start()
-
- ValueAnimator.ofInt(toolbar.height, toolbarToHeight)
- .apply {
- addUpdateListener { valueAnimator ->
- val value = valueAnimator.animatedValue as Int
- toolbar.layoutParams =
- toolbar.layoutParams.apply { height = value }
- }
- duration = ANIMATION_DURATION
- }
- .start()
-
- ValueAnimator.ofInt(applyButton.height, applyButtonToHeight)
- .apply {
- addUpdateListener { valueAnimator ->
- val value = valueAnimator.animatedValue as Int
- applyButton.layoutParams =
- applyButton.layoutParams.apply { height = value }
- }
- duration = ANIMATION_DURATION
- }
- .start()
- }
- }
}
}
}
diff --git a/src/com/android/wallpaper/customization/ui/view/ClockFontSliderViewHolder.kt b/src/com/android/wallpaper/customization/ui/view/ClockFontSliderViewHolder.kt
deleted file mode 100644
index fb14342..0000000
--- a/src/com/android/wallpaper/customization/ui/view/ClockFontSliderViewHolder.kt
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2024 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.
- */
-
-package com.android.wallpaper.customization.ui.view
-
-import android.widget.TextView
-import androidx.core.view.isInvisible
-import com.android.systemui.plugins.clocks.ClockFontAxis
-import com.google.android.material.slider.LabelFormatter
-import com.google.android.material.slider.Slider
-
-class ClockFontSliderViewHolder(val name: TextView, val slider: Slider) {
-
- fun setIsVisible(isVisible: Boolean) {
- name.isInvisible = !isVisible
- slider.isInvisible = !isVisible
- }
-
- fun initView(clockFontAxis: ClockFontAxis, onFontAxisValueUpdated: (value: Float) -> Unit) {
- name.text = clockFontAxis.name
- slider.apply {
- valueFrom = clockFontAxis.minValue
- valueTo = clockFontAxis.maxValue
- value = clockFontAxis.currentValue
- labelBehavior = LabelFormatter.LABEL_GONE
- addOnChangeListener { _, value, fromUser ->
- if (fromUser) {
- onFontAxisValueUpdated.invoke(value)
- }
- }
- }
- }
-
- fun setValue(value: Float) {
- slider.value = value
- }
-}
diff --git a/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt b/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt
deleted file mode 100644
index fcf70d3..0000000
--- a/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2024 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.
- */
-
-package com.android.wallpaper.customization.ui.view
-
-import android.widget.TextView
-import androidx.core.view.isVisible
-import androidx.lifecycle.LifecycleOwner
-import com.android.systemui.plugins.clocks.ClockFontAxis
-import com.android.wallpaper.customization.ui.binder.SwitchColorBinder
-import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewModel
-import com.google.android.material.materialswitch.MaterialSwitch
-import kotlin.math.abs
-
-class ClockFontSwitchViewHolder(val name: TextView, val switch: MaterialSwitch) {
-
- private var switchMaxValue: Float? = null
-
- fun setIsVisible(isVisible: Boolean) {
- name.isVisible = isVisible
- switch.isVisible = isVisible
- }
-
- fun initView(
- clockFontAxis: ClockFontAxis,
- onFontAxisValueUpdated: (value: Float) -> Unit,
- colorUpdateViewModel: ColorUpdateViewModel,
- shouldAnimateColor: () -> Boolean,
- lifecycleOwner: LifecycleOwner,
- ) {
- switchMaxValue = clockFontAxis.maxValue
- name.text = clockFontAxis.name
- switch.apply {
- isChecked = abs(clockFontAxis.currentValue - clockFontAxis.maxValue) < 0.01f
- var binding: SwitchColorBinder.Binding =
- SwitchColorBinder.bind(
- switch = switch,
- isChecked = isChecked,
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- setOnCheckedChangeListener { v, _ ->
- binding.destroy()
- binding =
- SwitchColorBinder.bind(
- switch = switch,
- isChecked = v.isChecked,
- colorUpdateViewModel = colorUpdateViewModel,
- shouldAnimateColor = shouldAnimateColor,
- lifecycleOwner = lifecycleOwner,
- )
- val value = if (v.isChecked) clockFontAxis.maxValue else clockFontAxis.minValue
- onFontAxisValueUpdated.invoke(value)
- }
- }
- }
-
- fun setValue(value: Float) {
- switchMaxValue?.let { switch.isChecked = abs(value - it) < 0.01f }
- }
-}
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ClockFloatingSheetHeightsViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ClockFloatingSheetHeightsViewModel.kt
index 249f862..42ed420 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ClockFloatingSheetHeightsViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ClockFloatingSheetHeightsViewModel.kt
@@ -19,5 +19,5 @@
data class ClockFloatingSheetHeightsViewModel(
val clockStyleContentHeight: Int? = null,
val clockColorContentHeight: Int? = null,
- val clockFontContentHeight: Int? = null,
+ val clockSizeContentHeight: Int? = null,
)
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
index dca361f..5ab54fd 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModel.kt
@@ -51,7 +51,6 @@
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
-import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
@@ -74,7 +73,7 @@
enum class Tab {
STYLE,
COLOR,
- FONT,
+ SIZE,
}
private val colorMap = ClockColorViewModel.getPresetColorMap(context.resources)
@@ -92,9 +91,9 @@
contentDescription = Text.Resource(R.string.clock_style),
),
text = context.getString(R.string.clock_style),
- isSelected = it == Tab.STYLE || it == Tab.FONT,
+ isSelected = it == Tab.STYLE,
onClick =
- if (it == Tab.STYLE || it == Tab.FONT) null
+ if (it == Tab.STYLE) null
else {
{ _selectedTab.value = Tab.STYLE }
},
@@ -113,6 +112,20 @@
{ _selectedTab.value = Tab.COLOR }
},
),
+ FloatingToolbarTabViewModel(
+ icon =
+ Icon.Resource(
+ res = R.drawable.ic_font_size_filled_24px,
+ contentDescription = Text.Resource(R.string.clock_size),
+ ),
+ text = context.getString(R.string.clock_size),
+ isSelected = it == Tab.SIZE,
+ onClick =
+ if (it == Tab.SIZE) null
+ else {
+ { _selectedTab.value = Tab.SIZE }
+ },
+ ),
)
}
@@ -135,7 +148,7 @@
suspend fun getUdfpsLocation() = clockPickerInteractor.getUdfpsLocation()
- data class ClockStyleModel(val thumbnail: Drawable, val showEditButton: StateFlow<Boolean>)
+ data class ClockStyleModel(val thumbnail: Drawable)
@OptIn(ExperimentalCoroutinesApi::class)
val clockStyleOptions: StateFlow<List<OptionItemViewModel2<ClockStyleModel>>> =
@@ -159,26 +172,21 @@
resources: Resources
): OptionItemViewModel2<ClockStyleModel> {
val isSelectedFlow = previewingClock.map { it.clockId == clockId }.stateIn(viewModelScope)
- val isEditable = fontAxes.isNotEmpty()
- val showEditButton = isSelectedFlow.map { it && isEditable }.stateIn(viewModelScope)
val contentDescription =
resources.getString(R.string.select_clock_action_description, description)
return OptionItemViewModel2<ClockStyleModel>(
key = MutableStateFlow(clockId) as StateFlow<String>,
- payload = ClockStyleModel(thumbnail = thumbnail, showEditButton = showEditButton),
+ payload = ClockStyleModel(thumbnail = thumbnail),
text = Text.Loaded(contentDescription),
isTextUserVisible = false,
isSelected = isSelectedFlow,
onClicked =
isSelectedFlow.map { isSelected ->
- if (isSelected && isEditable) {
- fun() {
- _selectedTab.value = Tab.FONT
- }
+ if (isSelected) {
+ null
} else {
fun() {
overridingClock.value = this
- overrideClockFontAxisMap.value = emptyMap()
}
}
},
@@ -202,7 +210,7 @@
!overrideClockFontAxisMap.all { (key, value) -> selectedClockFontAxisMap[key] == value }
}
val previewingClockFontAxisMap =
- combine(overrideClockFontAxisMap, selectedClockFontAxisMap.filterNotNull()) {
+ combine(overrideClockFontAxisMap, selectedClockFontAxisMap) {
overrideAxisMap,
selectedAxisMap ->
if (overrideAxisMap.isEmpty()) {
@@ -223,15 +231,6 @@
overrideClockFontAxisMap.value = axisMap.toMap()
}
- fun confirmFontAxes() {
- _selectedTab.value = Tab.STYLE
- }
-
- fun cancelFontAxes() {
- overrideClockFontAxisMap.value = emptyMap()
- _selectedTab.value = Tab.STYLE
- }
-
// Clock size
private val overridingClockSize = MutableStateFlow<ClockSize?>(null)
private val isClockSizeEdited =
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
index 95f55c0..9414cc7 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
@@ -32,7 +32,6 @@
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
@@ -77,16 +76,6 @@
defaultCustomizationOptionsViewModel.discardChangesDialogViewModel
override fun handleBackPressed(): Boolean {
-
- if (
- defaultCustomizationOptionsViewModel.selectedOption.value ==
- ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK &&
- clockPickerViewModel.selectedTab.value == ClockPickerViewModel.Tab.FONT
- ) {
- clockPickerViewModel.cancelFontAxes()
- return true
- }
-
if (isApplyButtonEnabled.value) {
defaultCustomizationOptionsViewModel.showDiscardChangesDialogViewModel()
return true
@@ -212,14 +201,6 @@
val isApplyButtonVisible: Flow<Boolean> = selectedOption.map { it != null }
- val isToolbarCollapsed: Flow<Boolean> =
- combine(selectedOption, clockPickerViewModel.selectedTab) { selectedOption, selectedTab ->
- selectedOption ==
- ThemePickerCustomizationOptionUtil.ThemePickerLockCustomizationOption.CLOCK &&
- selectedTab == ClockPickerViewModel.Tab.FONT
- }
- .distinctUntilChanged()
-
@ViewModelScoped
@AssistedFactory
interface Factory : CustomizationOptionsViewModelFactory {
diff --git a/tests/robotests/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModelTest.kt b/tests/robotests/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModelTest.kt
index 482af7e..315f071 100644
--- a/tests/robotests/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModelTest.kt
+++ b/tests/robotests/src/com/android/wallpaper/customization/ui/viewmodel/ClockPickerViewModelTest.kt
@@ -135,27 +135,11 @@
}
@Test
- fun selectedTab_fontEditorWhenClickSelectedClock() = runTest {
- val clockStyleOptions = collectLastValue(underTest.clockStyleOptions)
- val selectedTab = collectLastValue(underTest.selectedTab)
- // Advance CLOCKS_EVENT_UPDATE_DELAY_MILLIS since there is a delay from clockStyleOptions
- advanceTimeBy(ClockPickerViewModel.CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
- assertThat(selectedTab()).isEqualTo(Tab.STYLE)
-
- val firstClock = clockStyleOptions()!![0]
- val onClicked = collectLastValue(firstClock.onClicked)
- if (!firstClock.isSelected.value) onClicked()?.invoke()
- onClicked()?.invoke()
-
- assertThat(selectedTab()).isEqualTo(Tab.FONT)
- }
-
- @Test
fun tabs_whenInitialState() = runTest {
val tabs = collectLastValue(underTest.tabs)
val resultTabs = checkNotNull(tabs())
- assertThat(resultTabs).hasSize(2)
+ assertThat(resultTabs).hasSize(3)
resultTabs.forEachIndexed { index, floatingToolbarTabViewModel ->
when (index) {
0 -> {
@@ -184,6 +168,19 @@
isOnClickNull = false,
)
}
+ 2 -> {
+ assertFloatingToolbarTabViewModel(
+ viewModel = floatingToolbarTabViewModel,
+ icon =
+ Icon.Resource(
+ res = R.drawable.ic_font_size_filled_24px,
+ contentDescription = Text.Resource(R.string.clock_size),
+ ),
+ text = context.getString(R.string.clock_size),
+ isSelected = false,
+ isOnClickNull = false,
+ )
+ }
}
}
}
@@ -241,7 +238,7 @@
val option1OnClicked = collectLastValue(clockStyleOptions()!![1].onClicked)
assertThat(option0IsSelected()).isTrue()
- assertThat(option0OnClicked()).isNotNull()
+ assertThat(option0OnClicked()).isNull()
option1OnClicked()?.invoke()
// Advance CLOCKS_EVENT_UPDATE_DELAY_MILLIS since there is a delay from clockColorOptions
@@ -249,7 +246,7 @@
assertThat(option0IsSelected()).isFalse()
assertThat(option1IsSelected()).isTrue()
- assertThat(option1OnClicked()).isNotNull()
+ assertThat(option1OnClicked()).isNull()
}
@Test
@@ -266,76 +263,6 @@
}
@Test
- fun previewingFontAxes_defaultWhenNoOverrides() = runTest {
- val previewingFontAxes = collectLastValue(underTest.previewingClockFontAxisMap)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 50f))
- }
-
- @Test
- fun previewingFontAxes_updateAxisChangesSetting() = runTest {
- val previewingFontAxes = collectLastValue(underTest.previewingClockFontAxisMap)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 50f))
-
- underTest.updatePreviewFontAxis("key", 100f)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 100f))
-
- underTest.updatePreviewFontAxis("extra", 10f)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 100f, "extra" to 10f))
- }
-
- @Test
- fun previewingFontAxes_applyFontEditorExitsTab_keepsPreviewAxis() = runTest {
- val previewingFontAxes = collectLastValue(underTest.previewingClockFontAxisMap)
- val clockStyleOptions = collectLastValue(underTest.clockStyleOptions)
- val selectedTab = collectLastValue(underTest.selectedTab)
- // Advance CLOCKS_EVENT_UPDATE_DELAY_MILLIS since there is a delay from clockStyleOptions
- advanceTimeBy(ClockPickerViewModel.CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
-
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 50f))
- assertThat(selectedTab()).isEqualTo(Tab.STYLE)
-
- val firstClock = clockStyleOptions()!![0]
- val onClicked = collectLastValue(firstClock.onClicked)
- if (!firstClock.isSelected.value) onClicked()?.invoke()
- onClicked()?.invoke()
- underTest.updatePreviewFontAxis("key", 100f)
-
- assertThat(selectedTab()).isEqualTo(Tab.FONT)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 100f))
-
- underTest.confirmFontAxes()
-
- assertThat(selectedTab()).isEqualTo(Tab.STYLE)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 100f))
- }
-
- @Test
- fun previewingFontAxes_revertFontEditorExitsTab_revertsPreviewAxis() = runTest {
- val previewingFontAxes = collectLastValue(underTest.previewingClockFontAxisMap)
- val clockStyleOptions = collectLastValue(underTest.clockStyleOptions)
- val selectedTab = collectLastValue(underTest.selectedTab)
- // Advance CLOCKS_EVENT_UPDATE_DELAY_MILLIS since there is a delay from clockStyleOptions
- advanceTimeBy(ClockPickerViewModel.CLOCKS_EVENT_UPDATE_DELAY_MILLIS)
-
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 50f))
- assertThat(selectedTab()).isEqualTo(Tab.STYLE)
-
- val firstClock = clockStyleOptions()!![0]
- val onClicked = collectLastValue(firstClock.onClicked)
- if (!firstClock.isSelected.value) onClicked()?.invoke()
- onClicked()?.invoke()
- underTest.updatePreviewFontAxis("key", 100f)
-
- assertThat(selectedTab()).isEqualTo(Tab.FONT)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 100f))
-
- underTest.cancelFontAxes()
-
- assertThat(selectedTab()).isEqualTo(Tab.STYLE)
- assertThat(previewingFontAxes()).isEqualTo(mapOf("key" to 50f))
- }
-
- @Test
fun sliderProgress_whenOnSliderProgressChanged() = runTest {
val sliderProgress = collectLastValue(underTest.previewingSliderProgress)
@@ -488,25 +415,6 @@
}
@Test
- fun apply_notNullWhenFontAxisChanged() = runTest {
- val onApply = collectLastValue(underTest.onApply)
-
- underTest.updatePreviewFontAxis("key", 100f)
-
- assertThat(onApply()).isNotNull()
- }
-
- @Test
- fun apply_nullAfterApplyingFontAxis() = runTest {
- val onApply = collectLastValue(underTest.onApply)
-
- underTest.updatePreviewFontAxis("key", 100f)
- onApply()?.invoke()
-
- assertThat(onApply()).isNull()
- }
-
- @Test
fun apply_notNullWhenClockSizeChanged() = runTest {
val onApply = collectLastValue(underTest.onApply)
val onClockSizeSwitchCheckedChange =