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

Commit 675ff0fe authored by Anton Potapov's avatar Anton Potapov
Browse files

Fix QS header constraints so status icons are now ellipsized where there

is lack of space.

Previously:
There was a chain [date]-[space]-[status icons]-[battery]. That's why we should add bias and space to make it working.
But there're several problems with this:
 1) app:layout_width="WRAP_CONTENT" + app:layout_constrainedWidth=”true" != app:layout_width="0dp" + app:layout_constraintWidth_default="wrap". The first one gets view expanded like it's MATCH_PARENT.
 2) I've found out that wrapping views in constraint layout 2.0.0 may not always work as expected with app:layout_constrainedWidth=”true" (the view get's stretched as it's match_parent). layout_constraintWidth_max="wrap" should've help with this, but motion layout can't parse this attribute in constraint set. That's why my solution is to reimplement the layout a little bit
This behavior is reported here: https://github.com/androidx/constraintlayout/issues/713

Now:
[date] and [battery] are constrained to the sides and [status icons] occupy the whole space between them.
[date] is always WRAP_CONTENT because there's always some space and we want to show it.
[battery] and [status icons] are wrap content with constraints restrictions to make them fill all the space left

Test: manual: phone + tablet
Fixes: 260364389
Change-Id: I4d54b795cc4e96f6c204f2f00aff7607572d9aa3
parent 8165fae2
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -148,9 +148,4 @@
        <include layout="@layout/ongoing_privacy_chip"/>
    </FrameLayout>

    <Space
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:id="@+id/space"
    />
</com.android.systemui.util.NoRemeasureMotionLayout>
 No newline at end of file
+7 −23
Original line number Diff line number Diff line
@@ -56,13 +56,9 @@
        <Layout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/new_qs_header_non_clickable_element_height"
            app:layout_constrainedWidth="true"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@id/space"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@id/carrier_group"
            app:layout_constraintHorizontal_bias="0"
            app:layout_constraintHorizontal_chainStyle="spread_inside"
        />
    </Constraint>

@@ -87,39 +83,27 @@
    <Constraint
        android:id="@+id/statusIcons">
        <Layout
            android:layout_width="wrap_content"
            android:layout_width="0dp"
            android:layout_height="@dimen/new_qs_header_non_clickable_element_height"
            app:layout_constraintStart_toEndOf="@id/space"
            app:layout_constraintWidth_default="wrap"
            app:layout_constraintStart_toEndOf="@id/date"
            app:layout_constraintEnd_toStartOf="@id/batteryRemainingIcon"
            app:layout_constraintTop_toTopOf="@id/date"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="1"
            app:layout_constraintBottom_toBottomOf="@id/date"
            />
    </Constraint>

    <Constraint
        android:id="@+id/batteryRemainingIcon">
        <Layout
            android:layout_width="wrap_content"
            android:layout_width="0dp"
            android:layout_height="@dimen/new_qs_header_non_clickable_element_height"
            app:layout_constraintWidth_default="wrap"
            app:layout_constraintHeight_min="@dimen/new_qs_header_non_clickable_element_height"
            app:layout_constraintStart_toEndOf="@id/statusIcons"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/date"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="1"
            app:layout_constraintHorizontal_chainStyle="spread_inside"
            app:layout_constraintBottom_toBottomOf="@id/date"
            />
    </Constraint>


    <Constraint
        android:id="@id/space">
        <Layout
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintStart_toEndOf="@id/date"
            app:layout_constraintEnd_toStartOf="@id/statusIcons"
            />
    </Constraint>
</ConstraintSet>
 No newline at end of file
+5 −9
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shade

import android.testing.AndroidTestingRunner
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintSet
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
@@ -92,12 +93,12 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
            assertThat(getConstraint(R.id.clock).layout.horizontalBias).isEqualTo(0f)

            assertThat(getConstraint(R.id.date).layout.startToStart).isEqualTo(PARENT_ID)
            assertThat(getConstraint(R.id.date).layout.horizontalBias).isEqualTo(0f)
            assertThat(getConstraint(R.id.date).layout.horizontalBias).isEqualTo(0.5f)

            assertThat(getConstraint(R.id.batteryRemainingIcon).layout.endToEnd)
                .isEqualTo(PARENT_ID)
            assertThat(getConstraint(R.id.batteryRemainingIcon).layout.horizontalBias)
                .isEqualTo(1f)
                .isEqualTo(0.5f)

            assertThat(getConstraint(R.id.privacy_container).layout.endToEnd)
                .isEqualTo(R.id.end_guide)
@@ -331,10 +332,8 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
        val views = mapOf(
                R.id.clock to "clock",
                R.id.date to "date",
                R.id.statusIcons to "icons",
                R.id.privacy_container to "privacy",
                R.id.carrier_group to "carriers",
                R.id.batteryRemainingIcon to "battery",
        )
        views.forEach { (id, name) ->
            assertWithMessage("$name has 0 height in qqs")
@@ -352,11 +351,8 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
    fun testCheckViewsDontChangeSizeBetweenAnimationConstraints() {
        val views = mapOf(
                R.id.clock to "clock",
                R.id.date to "date",
                R.id.statusIcons to "icons",
                R.id.privacy_container to "privacy",
                R.id.carrier_group to "carriers",
                R.id.batteryRemainingIcon to "battery",
        )
        views.forEach { (id, name) ->
            expect.withMessage("$name changes height")
@@ -369,8 +365,8 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
    }

    private fun Int.fromConstraint() = when (this) {
        -1 -> "MATCH_PARENT"
        -2 -> "WRAP_CONTENT"
        ViewGroup.LayoutParams.MATCH_PARENT -> "MATCH_PARENT"
        ViewGroup.LayoutParams.WRAP_CONTENT -> "WRAP_CONTENT"
        else -> toString()
    }