From 2b97d96a564584e9eb6b803af612fcd5a9d9f702 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Tue, 27 Jun 2023 18:12:59 +0100 Subject: [PATCH] Collapsing shade when user clicks on shade_header_system_icons from shade header Bug: 249859409 Test: ShadeHeaderControllerTest#testLargeScreenActive_collapseActionRun_onSystemIconsClick Change-Id: I06221389a03fd5345b1a9107daebb7c60fa8a33c --- .../shade/NotificationPanelViewController.java | 2 ++ .../systemui/shade/ShadeHeaderController.kt | 4 ++++ .../systemui/shade/ShadeHeaderControllerTest.kt | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 599379f7d45c0..795df055c4de4 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1078,6 +1078,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mTapAgainViewController.init(); mShadeHeaderController.init(); + mShadeHeaderController.setShadeCollapseAction( + () -> collapse(/* delayed= */ false , /* speedUpFactor= */ 1.0f)); mKeyguardUnfoldTransition.ifPresent(u -> u.setup(mView)); mNotificationPanelUnfoldAnimationController.ifPresent(controller -> controller.setup(mNotificationContainerParent)); diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt index fedfb6e0e9e7b..3fb58dc04a9cb 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeHeaderController.kt @@ -122,6 +122,8 @@ constructor( } } + var shadeCollapseAction: Runnable? = null + private lateinit var iconManager: StatusBarIconController.TintedIconManager private lateinit var carrierIconSlots: List private lateinit var mShadeCarrierGroupController: ShadeCarrierGroupController @@ -464,9 +466,11 @@ constructor( if (largeScreenActive) { logInstantEvent("Large screen constraints set") header.setTransition(LARGE_SCREEN_HEADER_TRANSITION_ID) + systemIcons.setOnClickListener { shadeCollapseAction?.run() } } else { logInstantEvent("Small screen constraints set") header.setTransition(HEADER_TRANSITION_ID) + systemIcons.setOnClickListener(null) } header.jumpToState(header.startState) updatePosition() diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt index 2da2e9238d0ad..fd5b68bc94f5b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ShadeHeaderControllerTest.kt @@ -29,6 +29,7 @@ import android.view.DisplayCutout import android.view.View import android.view.ViewPropertyAnimator import android.view.WindowInsets +import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.widget.ConstraintSet @@ -127,6 +128,7 @@ class ShadeHeaderControllerTest : SysuiTestCase() { var viewVisibility = View.GONE var viewAlpha = 1f + private val systemIcons = LinearLayout(context) private lateinit var shadeHeaderController: ShadeHeaderController private lateinit var carrierIconSlots: List private val configurationController = FakeConfigurationController() @@ -146,6 +148,7 @@ class ShadeHeaderControllerTest : SysuiTestCase() { .thenReturn(batteryMeterView) whenever(view.findViewById(R.id.statusIcons)).thenReturn(statusIcons) + whenever(view.findViewById(R.id.shade_header_system_icons)).thenReturn(systemIcons) viewContext = Mockito.spy(context) whenever(view.context).thenReturn(viewContext) @@ -439,6 +442,17 @@ class ShadeHeaderControllerTest : SysuiTestCase() { verify(view).setTransition(ShadeHeaderController.HEADER_TRANSITION_ID) } + @Test + fun testLargeScreenActive_collapseActionRun_onSystemIconsClick() { + shadeHeaderController.largeScreenActive = true + var wasRun = false + shadeHeaderController.shadeCollapseAction = Runnable { wasRun = true } + + systemIcons.performClick() + + assertThat(wasRun).isTrue() + } + @Test fun testShadeExpandedFraction() { // View needs to be visible for this to actually take effect