Update to use MaterialSwitch
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: manually verified
Bug: 390233022
Change-Id: I1df036c7a2d3851421febb8d09cf67f5b08d79f4
diff --git a/res/layout/customization_option_entry_themed_icons.xml b/res/layout/customization_option_entry_themed_icons.xml
index 5694eef..d10f9e9 100644
--- a/res/layout/customization_option_entry_themed_icons.xml
+++ b/res/layout/customization_option_entry_themed_icons.xml
@@ -49,7 +49,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/option_entry_title" />
- <Switch
+ <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/option_entry_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -57,6 +57,5 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
- style="@style/Switch.SettingsLib"
- tools:ignore="UseSwitchCompatOrMaterialXml" />
+ 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_font_content.xml b/res/layout/floating_sheet_clock_font_content.xml
index 3ce65e4..164b625 100644
--- a/res/layout/floating_sheet_clock_font_content.xml
+++ b/res/layout/floating_sheet_clock_font_content.xml
@@ -112,7 +112,7 @@
style="@style/CustomizationOptionEntryTitleTextStyle"
android:text="@string/tab_placeholder_text" />
- <Switch
+ <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/clock_axis_switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -121,7 +121,7 @@
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"
- style="@style/Switch.SettingsLib" />
+ android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
<ImageView
android:id="@+id/divider"
@@ -149,7 +149,7 @@
style="@style/CustomizationOptionEntryTitleTextStyle"
android:text="@string/tab_placeholder_text" />
- <Switch
+ <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/clock_axis_switch2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -157,5 +157,5 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginVertical="@dimen/clock_axis_control_switch_row_margin_vertical"
- style="@style/Switch.SettingsLib" />
+ 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_style_content.xml b/res/layout/floating_sheet_clock_style_content.xml
index 582ad4f..0339e26 100644
--- a/res/layout/floating_sheet_clock_style_content.xml
+++ b/res/layout/floating_sheet_clock_style_content.xml
@@ -86,7 +86,7 @@
app:layout_constraintTop_toBottomOf="@+id/clock_style_clock_size_title"
app:layout_constraintBottom_toBottomOf="parent" />
- <Switch
+ <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/clock_style_clock_size_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -94,6 +94,5 @@
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"
- style="@style/Switch.SettingsLib"
- tools:ignore="UseSwitchCompatOrMaterialXml" />
+ android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/floating_sheet_colors.xml b/res/layout/floating_sheet_colors.xml
index 1cc0583..549f606 100644
--- a/res/layout/floating_sheet_colors.xml
+++ b/res/layout/floating_sheet_colors.xml
@@ -65,14 +65,14 @@
android:layout_weight="1"
android:text="@string/mode_title" />
- <Switch
+ <com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/dark_mode_toggle"
- style="@style/Switch.SettingsLib"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:focusable="false"
- android:minHeight="0dp" />
+ android:minHeight="0dp"
+ android:theme="@style/Theme.Material3.DynamicColors.DayNight" />
</LinearLayout>
</LinearLayout>
diff --git a/src/com/android/customization/picker/mode/ui/binder/DarkModeBinder.kt b/src/com/android/customization/picker/mode/ui/binder/DarkModeBinder.kt
index b9c7041..ef9e662 100644
--- a/src/com/android/customization/picker/mode/ui/binder/DarkModeBinder.kt
+++ b/src/com/android/customization/picker/mode/ui/binder/DarkModeBinder.kt
@@ -16,16 +16,20 @@
package com.android.customization.picker.mode.ui.binder
-import android.widget.Switch
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.android.customization.picker.mode.ui.viewmodel.DarkModeViewModel
+import com.google.android.material.materialswitch.MaterialSwitch
import kotlinx.coroutines.launch
object DarkModeBinder {
- fun bind(darkModeToggle: Switch, viewModel: DarkModeViewModel, lifecycleOwner: LifecycleOwner) {
+ fun bind(
+ darkModeToggle: MaterialSwitch,
+ viewModel: DarkModeViewModel,
+ lifecycleOwner: LifecycleOwner,
+ ) {
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch { viewModel.isEnabled.collect { darkModeToggle.isEnabled = it } }
diff --git a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
index a5dd89a..3196257 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
@@ -28,7 +28,6 @@
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.SeekBar
-import android.widget.Switch
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
@@ -57,6 +56,7 @@
import com.android.wallpaper.picker.customization.ui.view.adapter.FloatingToolbarTabAdapter
import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewModel
import com.android.wallpaper.picker.option.ui.adapter.OptionItemAdapter2
+import com.google.android.material.materialswitch.MaterialSwitch
import java.lang.ref.WeakReference
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.flow.Flow
@@ -173,7 +173,8 @@
)
// Clock size switch
- val clockSizeSwitch = view.requireViewById<Switch>(R.id.clock_style_clock_size_switch)
+ val clockSizeSwitch =
+ view.requireViewById<MaterialSwitch>(R.id.clock_style_clock_size_switch)
clockStyleContent.viewTreeObserver.addOnGlobalLayoutListener(
object : OnGlobalLayoutListener {
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
index 7dda5cc..d8b14b2 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerCustomizationOptionBinder.kt
@@ -21,7 +21,6 @@
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
-import android.widget.Switch
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.ContextCompat
@@ -57,6 +56,7 @@
import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewModel
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationOptionsViewModel
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationPickerViewModel2
+import com.google.android.material.materialswitch.MaterialSwitch
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Dispatchers
@@ -205,7 +205,7 @@
.find { it.first == ThemePickerHomeCustomizationOption.THEMED_ICONS }
?.second
val optionThemedIconsSwitch =
- optionThemedIcons?.findViewById<Switch>(R.id.option_entry_switch)
+ optionThemedIcons?.findViewById<MaterialSwitch>(R.id.option_entry_switch)
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
diff --git a/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt b/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt
index 6eb374b..22e5dea 100644
--- a/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt
+++ b/src/com/android/wallpaper/customization/ui/view/ClockFontSwitchViewHolder.kt
@@ -16,13 +16,13 @@
package com.android.wallpaper.customization.ui.view
-import android.widget.Switch
import android.widget.TextView
import androidx.core.view.isVisible
import com.android.systemui.plugins.clocks.ClockFontAxis
+import com.google.android.material.materialswitch.MaterialSwitch
import kotlin.math.abs
-class ClockFontSwitchViewHolder(val name: TextView, val switch: Switch) {
+class ClockFontSwitchViewHolder(val name: TextView, val switch: MaterialSwitch) {
private var switchMaxValue: Float? = null