Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f06cb68e authored by George Lin's avatar George Lin
Browse files

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
parent de8ffb76
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"
+18 −5
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ object ClockFloatingSheetBinder {
            )
        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 ClockFloatingSheetBinder {
            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 @@ object ClockFloatingSheetBinder {
            }
        )

        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 @@ object ClockFloatingSheetBinder {
                            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
                                }