Fix clock stlye floaring sheet height
Sometimes, due to the race condition, the clock content height can be
small since we are getting the height too late after the slider is
taken.
Instead, we only get the clock style list's height and add the slider's
height in case if we need to show both.
Test: Manually tested. See bug.
Bug: 418437663
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I97c92f72f234f5f185b9634c492575d9cda2b3fe
diff --git a/res/layout/floating_sheet_clock_style_content.xml b/res/layout/floating_sheet_clock_style_content.xml
index 259f376..e8f51a5 100644
--- a/res/layout/floating_sheet_clock_style_content.xml
+++ b/res/layout/floating_sheet_clock_style_content.xml
@@ -23,6 +23,7 @@
android:clipChildren="false">
<FrameLayout
+ android:id="@+id/clock_style_list_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
diff --git a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
index 9d57031..1d72a48 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ClockFloatingSheetBinder.kt
@@ -131,6 +131,7 @@
)
val clockStyleList: RecyclerView = view.requireViewById(R.id.clock_style_list)
clockStyleList.initStyleList(appContext, clockStyleAdapter)
+ val clockStyleListContainer: View = view.requireViewById(R.id.clock_style_list_container)
val axisPresetSlider: Slider =
clockStyleContent.requireViewById(R.id.clock_axis_preset_slider)
@@ -220,16 +221,16 @@
object : OnGlobalLayoutListener {
override fun onGlobalLayout() {
if (
- clockStyleContent.height != 0 &&
+ clockStyleListContainer.height != 0 &&
axisPresetSlider.height != 0 &&
(_clockFloatingSheetHeights.value.clockStyleContentHeight !=
- clockSizeContent.height ||
+ clockStyleListContainer.height ||
_clockFloatingSheetHeights.value.axisPresetSliderHeight !=
axisPresetSlider.height)
) {
_clockFloatingSheetHeights.value =
_clockFloatingSheetHeights.value.copy(
- clockStyleContentHeight = clockStyleContent.height,
+ clockStyleContentHeight = clockStyleListContainer.height,
axisPresetSliderHeight = axisPresetSlider.height,
)
clockStyleContent.viewTreeObserver.removeOnGlobalLayoutListener(this)
@@ -274,6 +275,12 @@
}
)
+ val clockStyleContentVerticalPadding =
+ view.resources.getDimensionPixelSize(R.dimen.floating_sheet_content_vertical_padding)
+ val clockStyleContentSliderMargin =
+ view.resources.getDimensionPixelSize(
+ R.dimen.clock_axis_control_slider_row_margin_vertical
+ )
lifecycleOwner.lifecycleScope.launch {
var currentTab: Tab = Tab.STYLE
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
@@ -302,8 +309,14 @@
val toHeight =
when (selectedTab) {
Tab.STYLE ->
- if (shouldShowPresetSlider) clockStyleContentHeight
- else clockStyleContentHeight - axisPresetSliderHeight
+ if (shouldShowPresetSlider)
+ clockStyleContentHeight +
+ axisPresetSliderHeight +
+ 2 * clockStyleContentVerticalPadding +
+ clockStyleContentSliderMargin
+ else
+ clockStyleContentHeight +
+ 2 * clockStyleContentVerticalPadding
Tab.COLOR -> clockColorContentHeight
Tab.SIZE -> clockSizeContentHeight
}