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

Commit 8208fd4c authored by Michal Brzezinski's avatar Michal Brzezinski Committed by Michał Brzeziński
Browse files

Fixing too wide hover state in shade header

The problem is: shade_header_system_icons will be forced by constraints to stretch from date view to right edge of shade. Without start constraint it will overlap with date when font is big enough.
What I've tried:
- modifying qs_header constraints so that it will be wrap_content but still respect "start" constraint using various flavours of "layout_constraintWidth_default", "layout_constraintWidth", "layout_constraintWidth_max", "layout_constrainedWidth" and different widths: either 0dp or wrap_content
- using constraint chain "spread_inside" attribute - it didn't respect "start" constraint
- adding Space between date and system icons - this forces system icons to be too small

None of above worked so I resorted to adding container inside shade_header_system_icons that will be just to represent hover bounds and will be right aligned inside stretched parent.

Fixes: 295138618
Test: hover over system_icons in expanded QS state and see hover bounds are correct
Test: change font size and display size to the biggest possible values and see system icons doesn't overlap with date
Change-Id: I892c645d1c01d9491321c833fb17c563e1291254
parent c040151c
Loading
Loading
Loading
Loading
+24 −21
Original line number Diff line number Diff line
@@ -118,20 +118,22 @@ frame when animating QS <-> QQS transition
        app:layout_constraintStart_toEndOf="@id/date"
        app:layout_constraintTop_toTopOf="@id/clock" />

    <LinearLayout
    <FrameLayout
        android:id="@+id/shade_header_system_icons"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/shade_header_system_icons_height"
        android:clickable="true"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:paddingStart="@dimen/shade_header_system_icons_padding_start"
        android:paddingEnd="@dimen/shade_header_system_icons_padding_end"
        android:paddingTop="@dimen/shade_header_system_icons_padding_top"
        android:paddingBottom="@dimen/shade_header_system_icons_padding_bottom"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="@id/privacy_container"
        app:layout_constraintTop_toTopOf="@id/clock">
        <LinearLayout
            android:id="@+id/hover_system_icons_container"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="right|center_vertical"
            android:paddingStart="@dimen/hover_system_icons_container_padding_start"
            android:paddingEnd="@dimen/hover_system_icons_container_padding_end"
            android:paddingTop="@dimen/hover_system_icons_container_padding_top"
            android:paddingBottom="@dimen/hover_system_icons_container_padding_bottom">

            <com.android.systemui.statusbar.phone.StatusIconContainer
                android:id="@+id/statusIcons"
@@ -146,6 +148,7 @@ frame when animating QS <-> QQS transition
                android:layout_height="wrap_content"
                app:textAppearance="@style/TextAppearance.QS.Status" />
        </LinearLayout>
    </FrameLayout>

    <FrameLayout
        android:id="@+id/privacy_container"
+4 −4
Original line number Diff line number Diff line
@@ -80,10 +80,10 @@

    <dimen name="large_screen_shade_header_height">42dp</dimen>
    <!-- start padding is smaller to account for status icon margins coming from drawable itself -->
    <dimen name="shade_header_system_icons_padding_start">3dp</dimen>
    <dimen name="shade_header_system_icons_padding_end">4dp</dimen>
    <dimen name="shade_header_system_icons_padding_top">2dp</dimen>
    <dimen name="shade_header_system_icons_padding_bottom">2dp</dimen>
    <dimen name="hover_system_icons_container_padding_start">3dp</dimen>
    <dimen name="hover_system_icons_container_padding_end">4dp</dimen>
    <dimen name="hover_system_icons_container_padding_top">2dp</dimen>
    <dimen name="hover_system_icons_container_padding_bottom">2dp</dimen>

    <!-- Lockscreen shade transition values -->
    <dimen name="lockscreen_shade_transition_by_tap_distance">200dp</dimen>
+4 −4
Original line number Diff line number Diff line
@@ -496,10 +496,10 @@
    <dimen name="large_screen_shade_header_min_height">@dimen/qs_header_row_min_height</dimen>
    <dimen name="large_screen_shade_header_left_padding">@dimen/qs_horizontal_margin</dimen>
    <dimen name="shade_header_system_icons_height">@dimen/large_screen_shade_header_min_height</dimen>
    <dimen name="shade_header_system_icons_padding_start">0dp</dimen>
    <dimen name="shade_header_system_icons_padding_end">0dp</dimen>
    <dimen name="shade_header_system_icons_padding_top">0dp</dimen>
    <dimen name="shade_header_system_icons_padding_bottom">0dp</dimen>
    <dimen name="hover_system_icons_container_padding_start">0dp</dimen>
    <dimen name="hover_system_icons_container_padding_end">0dp</dimen>
    <dimen name="hover_system_icons_container_padding_top">0dp</dimen>
    <dimen name="hover_system_icons_container_padding_bottom">0dp</dimen>

    <!-- The top margin of the panel that holds the list of notifications.
         On phones it's always 0dp but it's overridden in Car UI
+16 −11
Original line number Diff line number Diff line
@@ -135,7 +135,8 @@ constructor(
    private val date: TextView = header.requireViewById(R.id.date)
    private val iconContainer: StatusIconContainer = header.requireViewById(R.id.statusIcons)
    private val mShadeCarrierGroup: ShadeCarrierGroup = header.requireViewById(R.id.carrier_group)
    private val systemIcons: View = header.requireViewById(R.id.shade_header_system_icons)
    private val systemIconsHoverContainer: View =
        header.requireViewById(R.id.hover_system_icons_container)

    private var roundedCorners = 0
    private var cutout: DisplayCutout? = null
@@ -259,14 +260,18 @@ constructor(
                    header.paddingRight,
                    header.paddingBottom
                )
                systemIcons.setPaddingRelative(
                systemIconsHoverContainer.setPaddingRelative(
                    resources.getDimensionPixelSize(
                        R.dimen.shade_header_system_icons_padding_start
                        R.dimen.hover_system_icons_container_padding_start
                    ),
                    resources.getDimensionPixelSize(R.dimen.shade_header_system_icons_padding_top),
                    resources.getDimensionPixelSize(R.dimen.shade_header_system_icons_padding_end),
                    resources.getDimensionPixelSize(
                        R.dimen.shade_header_system_icons_padding_bottom
                        R.dimen.hover_system_icons_container_padding_top
                    ),
                    resources.getDimensionPixelSize(
                        R.dimen.hover_system_icons_container_padding_end
                    ),
                    resources.getDimensionPixelSize(
                        R.dimen.hover_system_icons_container_padding_bottom
                    )
                )
            }
@@ -330,8 +335,8 @@ constructor(
        demoModeController.addCallback(demoModeReceiver)
        statusBarIconController.addIconGroup(iconManager)
        nextAlarmController.addCallback(nextAlarmCallback)
        systemIcons.setOnHoverListener(
            statusOverlayHoverListenerFactory.createListener(systemIcons)
        systemIconsHoverContainer.setOnHoverListener(
            statusOverlayHoverListenerFactory.createListener(systemIconsHoverContainer)
        )
    }

@@ -343,7 +348,7 @@ constructor(
        demoModeController.removeCallback(demoModeReceiver)
        statusBarIconController.removeIconGroup(iconManager)
        nextAlarmController.removeCallback(nextAlarmCallback)
        systemIcons.setOnHoverListener(null)
        systemIconsHoverContainer.setOnHoverListener(null)
    }

    fun disable(state1: Int, state2: Int, animate: Boolean) {
@@ -479,11 +484,11 @@ constructor(
        if (largeScreenActive) {
            logInstantEvent("Large screen constraints set")
            header.setTransition(LARGE_SCREEN_HEADER_TRANSITION_ID)
            systemIcons.setOnClickListener { shadeCollapseAction?.run() }
            systemIconsHoverContainer.setOnClickListener { shadeCollapseAction?.run() }
        } else {
            logInstantEvent("Small screen constraints set")
            header.setTransition(HEADER_TRANSITION_ID)
            systemIcons.setOnClickListener(null)
            systemIconsHoverContainer.setOnClickListener(null)
        }
        header.jumpToState(header.startState)
        updatePosition()
+5 −4
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
    var viewVisibility = View.GONE
    var viewAlpha = 1f

    private val systemIcons = LinearLayout(context)
    private val systemIconsHoverContainer = LinearLayout(context)
    private lateinit var shadeHeaderController: ShadeHeaderController
    private lateinit var carrierIconSlots: List<String>
    private val configurationController = FakeConfigurationController()
@@ -150,7 +150,8 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
            .thenReturn(batteryMeterView)

        whenever<StatusIconContainer>(view.requireViewById(R.id.statusIcons)).thenReturn(statusIcons)
        whenever<View>(view.requireViewById(R.id.shade_header_system_icons)).thenReturn(systemIcons)
        whenever<View>(view.requireViewById(R.id.hover_system_icons_container))
            .thenReturn(systemIconsHoverContainer)

        viewContext = Mockito.spy(context)
        whenever(view.context).thenReturn(viewContext)
@@ -457,12 +458,12 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
    }

    @Test
    fun testLargeScreenActive_collapseActionRun_onSystemIconsClick() {
    fun testLargeScreenActive_collapseActionRun_onSystemIconsHoverContainerClick() {
        shadeHeaderController.largeScreenActive = true
        var wasRun = false
        shadeHeaderController.shadeCollapseAction = Runnable { wasRun = true }

        systemIcons.performClick()
        systemIconsHoverContainer.performClick()

        assertThat(wasRun).isTrue()
    }