Bind floating sheet option item colors (2/2)
Bind the option item colors in OptionItemBinder2, which is used across
clock, shortcuts, colors, and app shape.
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: manually verified
Bug: 363018910
Change-Id: I74a269275e774c8fab1ebc1f1e9cbd9180e7212b
diff --git a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
index ca2fcd0..943729b 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
@@ -119,7 +119,12 @@
// Clock style
val clockStyleContent = view.requireViewById<View>(R.id.clock_floating_sheet_style_content)
- val clockStyleAdapter = createClockStyleOptionItemAdapter(lifecycleOwner)
+ val clockStyleAdapter =
+ createClockStyleOptionItemAdapter(
+ colorUpdateViewModel = colorUpdateViewModel,
+ shouldAnimateColor = isFloatingSheetActive,
+ lifecycleOwner = lifecycleOwner,
+ )
val clockStyleList =
view.requireViewById<RecyclerView>(R.id.clock_style_list).apply {
initStyleList(appContext, clockStyleAdapter)
@@ -418,7 +423,9 @@
}
private fun createClockStyleOptionItemAdapter(
- lifecycleOwner: LifecycleOwner
+ colorUpdateViewModel: ColorUpdateViewModel,
+ shouldAnimateColor: () -> Boolean,
+ lifecycleOwner: LifecycleOwner,
): OptionItemAdapter2<ClockStyleModel> =
OptionItemAdapter2(
layoutResourceId = R.layout.clock_style_option,
@@ -437,6 +444,8 @@
}
return@OptionItemAdapter2 DisposableHandle { job.cancel() }
},
+ colorUpdateViewModel = WeakReference(colorUpdateViewModel),
+ shouldAnimateColor = shouldAnimateColor,
)
private fun RecyclerView.initStyleList(
diff --git a/src/com/android/wallpaper/customization/ui/binder/ColorsFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ColorsFloatingSheetBinder.kt
index cfb0ccc..30e4f9a 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ColorsFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ColorsFloatingSheetBinder.kt
@@ -91,7 +91,12 @@
val subhead = view.requireViewById<TextView>(R.id.color_type_tab_subhead)
val colorsAdapter =
- createOptionItemAdapter(view.resources.configuration.uiMode, lifecycleOwner)
+ createOptionItemAdapter(
+ uiMode = view.resources.configuration.uiMode,
+ colorUpdateViewModel = colorUpdateViewModel,
+ shouldAnimateColor = isFloatingSheetActive,
+ lifecycleOwner = lifecycleOwner,
+ )
val colorsList =
view.requireViewById<RecyclerView>(R.id.colors_horizontal_list).also {
it.initColorsList(view.context.applicationContext, colorsAdapter)
@@ -136,6 +141,8 @@
private fun createOptionItemAdapter(
uiMode: Int,
+ colorUpdateViewModel: ColorUpdateViewModel,
+ shouldAnimateColor: () -> Boolean,
lifecycleOwner: LifecycleOwner,
): OptionItemAdapter2<ColorOptionIconViewModel> =
OptionItemAdapter2(
@@ -152,6 +159,8 @@
// disposal when rebind.
return@OptionItemAdapter2 null
},
+ colorUpdateViewModel = WeakReference(colorUpdateViewModel),
+ shouldAnimateColor = shouldAnimateColor,
)
private fun RecyclerView.initColorsList(
diff --git a/src/com/android/wallpaper/customization/ui/binder/ShapeGridFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ShapeGridFloatingSheetBinder.kt
index bdfc91a..af5b20d 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ShapeGridFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ShapeGridFloatingSheetBinder.kt
@@ -112,7 +112,12 @@
val shapeContent = view.requireViewById<View>(R.id.app_shape_container)
val shapeOptionListAdapter =
- createShapeOptionItemAdapter(lifecycleOwner, backgroundDispatcher)
+ createShapeOptionItemAdapter(
+ colorUpdateViewModel = colorUpdateViewModel,
+ shouldAnimateColor = isFloatingSheetActive,
+ lifecycleOwner = lifecycleOwner,
+ backgroundDispatcher = backgroundDispatcher,
+ )
val shapeOptionList =
view.requireViewById<RecyclerView>(R.id.shape_options).also {
it.initShapeOptionList(view.context, shapeOptionListAdapter)
@@ -120,7 +125,12 @@
val gridContent = view.requireViewById<View>(R.id.app_grid_container)
val gridOptionListAdapter =
- createGridOptionItemAdapter(lifecycleOwner, backgroundDispatcher)
+ createGridOptionItemAdapter(
+ colorUpdateViewModel = colorUpdateViewModel,
+ shouldAnimateColor = isFloatingSheetActive,
+ lifecycleOwner = lifecycleOwner,
+ backgroundDispatcher = backgroundDispatcher,
+ )
val gridOptionList =
view.requireViewById<RecyclerView>(R.id.grid_options).also {
it.initGridOptionList(view.context, gridOptionListAdapter)
@@ -231,6 +241,8 @@
}
private fun createShapeOptionItemAdapter(
+ colorUpdateViewModel: ColorUpdateViewModel,
+ shouldAnimateColor: () -> Boolean,
lifecycleOwner: LifecycleOwner,
backgroundDispatcher: CoroutineDispatcher,
): OptionItemAdapter2<ShapeIconViewModel> =
@@ -243,6 +255,8 @@
imageView?.let { ShapeIconViewBinder.bind(imageView, shapeIcon) }
return@OptionItemAdapter2 null
},
+ colorUpdateViewModel = WeakReference(colorUpdateViewModel),
+ shouldAnimateColor = shouldAnimateColor,
)
private fun RecyclerView.initShapeOptionList(
@@ -268,6 +282,8 @@
}
private fun createGridOptionItemAdapter(
+ colorUpdateViewModel: ColorUpdateViewModel,
+ shouldAnimateColor: () -> Boolean,
lifecycleOwner: LifecycleOwner,
backgroundDispatcher: CoroutineDispatcher,
): OptionItemAdapter2<GridIconViewModel> =
@@ -280,6 +296,8 @@
imageView?.let { GridIconViewBinder.bind(imageView, gridIcon) }
return@OptionItemAdapter2 null
},
+ colorUpdateViewModel = WeakReference(colorUpdateViewModel),
+ shouldAnimateColor = shouldAnimateColor,
)
private fun RecyclerView.initGridOptionList(
diff --git a/src/com/android/wallpaper/customization/ui/binder/ShortcutFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ShortcutFloatingSheetBinder.kt
index 36fe399..32ec323 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ShortcutFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ShortcutFloatingSheetBinder.kt
@@ -93,7 +93,12 @@
lifecycleOwner = lifecycleOwner,
)
- val quickAffordanceAdapter = createOptionItemAdapter(lifecycleOwner)
+ val quickAffordanceAdapter =
+ createOptionItemAdapter(
+ colorUpdateViewModel = colorUpdateViewModel,
+ shouldAnimateColor = isFloatingSheetActive,
+ lifecycleOwner = lifecycleOwner,
+ )
val quickAffordanceList =
view.requireViewById<RecyclerView>(R.id.quick_affordance_horizontal_list).also {
it.initQuickAffordanceList(view.context.applicationContext, quickAffordanceAdapter)
@@ -176,7 +181,11 @@
)
}
- private fun createOptionItemAdapter(lifecycleOwner: LifecycleOwner): OptionItemAdapter2<Icon> =
+ private fun createOptionItemAdapter(
+ colorUpdateViewModel: ColorUpdateViewModel,
+ shouldAnimateColor: () -> Boolean,
+ lifecycleOwner: LifecycleOwner,
+ ): OptionItemAdapter2<Icon> =
OptionItemAdapter2(
layoutResourceId = R.layout.quick_affordance_list_item2,
lifecycleOwner = lifecycleOwner,
@@ -188,6 +197,8 @@
// disposal when rebind.
return@OptionItemAdapter2 null
},
+ colorUpdateViewModel = WeakReference(colorUpdateViewModel),
+ shouldAnimateColor = shouldAnimateColor,
)
private fun RecyclerView.initQuickAffordanceList(