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
This commit is contained in:
Anton Potapov
2023-01-13 20:15:25 +00:00
parent fa87b00c96
commit 54ab1dfb36
6 changed files with 58 additions and 80 deletions

View File

@@ -25,6 +25,7 @@
android:focusable="true"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingStart="8dp"
>
<LinearLayout

View File

@@ -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,

View File

@@ -1,5 +1,4 @@
<?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"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/clock"
app:layout_constraintEnd_toStartOf="@id/carrier_group"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0"
/>
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>

View File

@@ -69,7 +69,8 @@ object CombinedShadeHeadersConstraintManagerImpl : CombinedShadeHeadersConstrain
}
return ConstraintsChanges(
qqsConstraintsChanges = change,
qsConstraintsChanges = change
qsConstraintsChanges = change,
largeScreenConstraintsChanges = change,
)
}

View File

@@ -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,15 +436,14 @@ 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()
updatePosition()
updateScrollY()
}
header.jumpToState(header.startState)
updatePosition()
updateScrollY()
}
private fun updatePosition() {

View File

@@ -109,11 +109,12 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
@Test
fun testEdgeElementsAlignedWithEdge_largeScreen() {
with(largeScreenConstraint) {
assertThat(getConstraint(R.id.clock).layout.startToStart).isEqualTo(PARENT_ID)
assertThat(getConstraint(R.id.clock).layout.horizontalBias).isEqualTo(0f)
assertThat(getConstraint(R.id.clock).layout.startToEnd).isEqualTo(R.id.begin_guide)
assertThat(getConstraint(R.id.clock).layout.horizontalBias).isEqualTo(0.5f)
assertThat(getConstraint(R.id.privacy_container).layout.endToEnd).isEqualTo(PARENT_ID)
assertThat(getConstraint(R.id.privacy_container).layout.horizontalBias).isEqualTo(1f)
assertThat(getConstraint(R.id.privacy_container).layout.endToStart)
.isEqualTo(R.id.end_guide)
assertThat(getConstraint(R.id.privacy_container).layout.horizontalBias).isEqualTo(0.5f)
}
}
@@ -219,7 +220,12 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
.isEqualTo(cutoutEnd - padding)
}
assertThat(changes.largeScreenConstraintsChanges).isNull()
with(largeScreenConstraint) {
assertThat(getConstraint(R.id.begin_guide).layout.guideBegin)
.isEqualTo(cutoutStart - padding)
assertThat(getConstraint(R.id.end_guide).layout.guideEnd)
.isEqualTo(cutoutEnd - padding)
}
}
@Test
@@ -246,7 +252,10 @@ class CombinedShadeHeaderConstraintsTest : SysuiTestCase() {
assertThat(getConstraint(R.id.end_guide).layout.guideEnd).isEqualTo(0)
}
assertThat(changes.largeScreenConstraintsChanges).isNull()
with(largeScreenConstraint) {
assertThat(getConstraint(R.id.begin_guide).layout.guideBegin).isEqualTo(0)
assertThat(getConstraint(R.id.end_guide).layout.guideEnd).isEqualTo(0)
}
}
@Test