Collapsing shade when user clicks on shade_header_system_icons from shade header

Bug: 249859409
Test: ShadeHeaderControllerTest#testLargeScreenActive_collapseActionRun_onSystemIconsClick
Change-Id: I06221389a03fd5345b1a9107daebb7c60fa8a33c
This commit is contained in:
Michal Brzezinski
2023-06-27 18:12:59 +01:00
committed by Michał Brzeziński
parent e911ce0914
commit 2b97d96a56
3 changed files with 20 additions and 0 deletions

View File

@@ -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));

View File

@@ -122,6 +122,8 @@ constructor(
}
}
var shadeCollapseAction: Runnable? = null
private lateinit var iconManager: StatusBarIconController.TintedIconManager
private lateinit var carrierIconSlots: List<String>
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()

View File

@@ -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<String>
private val configurationController = FakeConfigurationController()
@@ -146,6 +148,7 @@ class ShadeHeaderControllerTest : SysuiTestCase() {
.thenReturn(batteryMeterView)
whenever<StatusIconContainer>(view.findViewById(R.id.statusIcons)).thenReturn(statusIcons)
whenever<View>(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