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

Commit 54ab1dfb authored by Anton Potapov's avatar Anton Potapov
Browse files

Fix large screen QS and QQS lookup. Specially when privacy chip is shown.

There were several problems that were leading to the wrong behavior:
1) We didn't use special constraint set for large devices
2) Thats why the layout itself was a bit outdated and unoptimal
3) We didn't immediately change state after the transition is setup up.
   This led to carrier text missing
4) We set the transition after the listeners. This didn't cause any
   problems but it's an error prone approach when listeners are immediately
notified with the current state

Test: manual + auto
Fixes: 260134176
Change-Id: Id7d641d04a8086651af5e82a6ec3b6eaa92a0b5c
parent fa87b00c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
    android:focusable="true"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:paddingStart="8dp"
    >

        <LinearLayout
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

    <!-- QS-->
    <dimen name="qs_panel_padding_top">16dp</dimen>
    <dimen name="qs_panel_padding">24dp</dimen>
    <dimen name="qs_content_horizontal_padding">24dp</dimen>
    <dimen name="qs_horizontal_margin">24dp</dimen>
    <!-- in split shade qs_tiles_page_horizontal_margin should be equal of qs_horizontal_margin/2,
+31 −64
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2021 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,105 +14,73 @@
  ~ limitations under the License.
  -->

<ConstraintSet
    xmlns:android="http://schemas.android.com/apk/res/android"
<ConstraintSet xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/large_screen_header_constraint">

    <Constraint
        android:id="@+id/clock">
    <Constraint android:id="@+id/clock">
        <Layout
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@id/date"
            app:layout_constraintHorizontal_bias="0"
        />
        <Transform
            android:scaleX="1"
            android:scaleY="1"
            />
            app:layout_constraintStart_toEndOf="@id/begin_guide"
            app:layout_constraintTop_toTopOf="parent" />
        <PropertySet android:alpha="1" />
    </Constraint>

    <Constraint
        android:id="@+id/date">
    <Constraint android:id="@+id/date">
        <Layout
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintStart_toEndOf="@id/clock"
            app:layout_constraintEnd_toStartOf="@id/carrier_group"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginStart="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="0"
        />
            app:layout_constraintStart_toEndOf="@id/clock"
            app:layout_constraintTop_toTopOf="parent" />
        <PropertySet android:alpha="1" />
    </Constraint>

    <Constraint
        android:id="@+id/carrier_group">
    <Constraint android:id="@+id/carrier_group">
        <Layout
            app:layout_constraintWidth_min="48dp"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constrainedWidth="true"
            android:layout_gravity="end|center_vertical"
            android:layout_marginStart="8dp"
            app:layout_constraintStart_toEndOf="@id/date"
            app:layout_constraintEnd_toStartOf="@id/statusIcons"
            app:layout_constraintTop_toTopOf="@id/clock"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="1"
            />
        <PropertySet
            android:alpha="1"
        />
            app:layout_constraintEnd_toStartOf="@id/statusIcons"
            app:layout_constraintStart_toEndOf="@id/date"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintWidth_default="wrap"
            app:layout_constraintWidth_min="48dp" />
        <PropertySet android:alpha="1" />
    </Constraint>

    <Constraint
        android:id="@+id/statusIcons">
    <Constraint android:id="@+id/statusIcons">
        <Layout
            app:layout_constraintHeight_min="@dimen/large_screen_shade_header_min_height"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/large_screen_shade_header_min_height"
            app:layout_constraintStart_toEndOf="@id/carrier_group"
            app:layout_constraintEnd_toStartOf="@id/batteryRemainingIcon"
            app:layout_constraintTop_toTopOf="@id/clock"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="1"
            />
        <PropertySet
            android:alpha="1"
        />
            app:layout_constraintEnd_toStartOf="@id/batteryRemainingIcon"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintEnd_toEndOf="@id/carrier_group"/>
        <PropertySet android:alpha="1" />
    </Constraint>

    <Constraint
        android:id="@+id/batteryRemainingIcon">
    <Constraint android:id="@+id/batteryRemainingIcon">
        <Layout
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintHeight_min="@dimen/large_screen_shade_header_min_height"
            app:layout_constraintStart_toEndOf="@id/statusIcons"
            app:layout_constraintEnd_toStartOf="@id/privacy_container"
            app:layout_constraintTop_toTopOf="@id/clock"
            app:layout_constraintBottom_toBottomOf="parent"
        />
        <PropertySet
            android:alpha="1"
        />
            app:layout_constraintEnd_toStartOf="@id/privacy_container"
            app:layout_constraintTop_toTopOf="parent" />
        <PropertySet android:alpha="1" />
    </Constraint>

    <Constraint
        android:id="@+id/privacy_container">
    <Constraint android:id="@+id/privacy_container">
        <Layout
            android:layout_width="wrap_content"
            android:layout_height="@dimen/large_screen_shade_header_min_height"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/date"
            app:layout_constraintBottom_toBottomOf="@id/date"
            app:layout_constraintStart_toEndOf="@id/batteryRemainingIcon"
            app:layout_constraintHorizontal_bias="1"
        />
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@id/end_guide"
            app:layout_constraintTop_toTopOf="parent" />
    </Constraint>

</ConstraintSet>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -69,7 +69,8 @@ object CombinedShadeHeadersConstraintManagerImpl : CombinedShadeHeadersConstrain
        }
        return ConstraintsChanges(
            qqsConstraintsChanges = change,
            qsConstraintsChanges = change
            qsConstraintsChanges = change,
            largeScreenConstraintsChanges = change,
        )
    }

+8 −9
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class LargeScreenShadeHeaderController @Inject constructor(
            QQS_HEADER_CONSTRAINT -> "QQS Header"
            QS_HEADER_CONSTRAINT -> "QS Header"
            LARGE_SCREEN_HEADER_CONSTRAINT -> "Large Screen Header"
            else -> "Unknown state"
            else -> "Unknown state $this"
        }
    }

@@ -296,6 +296,9 @@ class LargeScreenShadeHeaderController @Inject constructor(

    override fun onViewAttached() {
        privacyIconsController.chipVisibilityListener = chipVisibilityListener
        updateVisibility()
        updateTransition()

        if (header is MotionLayout) {
            header.setOnApplyWindowInsetsListener(insetListener)
            clock.addOnLayoutChangeListener { v, _, _, _, _, _, _, _, _ ->
@@ -308,9 +311,6 @@ class LargeScreenShadeHeaderController @Inject constructor(
        dumpManager.registerDumpable(this)
        configurationController.addCallback(configurationControllerListener)
        demoModeController.addCallback(demoModeReceiver)

        updateVisibility()
        updateTransition()
    }

    override fun onViewDetached() {
@@ -436,16 +436,15 @@ class LargeScreenShadeHeaderController @Inject constructor(
        header as MotionLayout
        if (largeScreenActive) {
            logInstantEvent("Large screen constraints set")
            header.setTransition(HEADER_TRANSITION_ID)
            header.transitionToStart()
            header.setTransition(LARGE_SCREEN_HEADER_TRANSITION_ID)
        } else {
            logInstantEvent("Small screen constraints set")
            header.setTransition(HEADER_TRANSITION_ID)
            header.transitionToStart()
        }
        header.jumpToState(header.startState)
        updatePosition()
        updateScrollY()
    }
    }

    private fun updatePosition() {
        if (header is MotionLayout && !largeScreenActive && visible) {
Loading