From ccfd9427cef83a1359b381e7629472cf167749c4 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Wed, 21 Sep 2022 11:54:52 +0100 Subject: [PATCH] Making sure QS tile pages are reset when collapsing split shade Expanded state passed to QSPanelController was always true for split shade. Making it work as qsExpanded in QSFragment means controller can react to not expanded state correctly and reset tile pages. That required some extra changes in NPVC, otherwise QS expansion was broken when rotating between split and portrait shade. This should have been done some time ago already as QS expanded state is working properly in split shade, that is qsExpanded is true when split shade is expanded, false otherwise. Fixes: 247799702 Test: QSFragmentTest Test: expand split shade -> swipe to another qs tiles page -> close split shade and expand it again -> qs tiles should be back to the first page Change-Id: Id5865a18273e9e3becbdc3a85be975ea1e0dae7b --- .../com/android/systemui/qs/QSFragment.java | 15 ++++++------- .../NotificationPanelViewController.java | 22 +++++++++---------- .../android/systemui/qs/QSFragmentTest.java | 13 +++++++++++ 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index 7b27cf45979f1..653d9dd8b6a49 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -442,20 +442,19 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca } private void updateQsState() { - final boolean expanded = mQsExpanded || mInSplitShade; - final boolean expandVisually = expanded || mStackScrollerOverscrolling + final boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling || mHeaderAnimating; - mQSPanelController.setExpanded(expanded); + mQSPanelController.setExpanded(mQsExpanded); boolean keyguardShowing = isKeyguardState(); - mHeader.setVisibility((expanded || !keyguardShowing || mHeaderAnimating + mHeader.setVisibility((mQsExpanded || !keyguardShowing || mHeaderAnimating || mShowCollapsedOnKeyguard) ? View.VISIBLE : View.INVISIBLE); mHeader.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard) - || (expanded && !mStackScrollerOverscrolling), mQuickQSPanelController); + || (mQsExpanded && !mStackScrollerOverscrolling), mQuickQSPanelController); boolean qsPanelVisible = !mQsDisabled && expandVisually; - boolean footerVisible = qsPanelVisible && (expanded || !keyguardShowing || mHeaderAnimating - || mShowCollapsedOnKeyguard); + boolean footerVisible = qsPanelVisible && (mQsExpanded || !keyguardShowing + || mHeaderAnimating || mShowCollapsedOnKeyguard); mFooter.setVisibility(footerVisible ? View.VISIBLE : View.INVISIBLE); if (mQSFooterActionController != null) { mQSFooterActionController.setVisible(footerVisible); @@ -463,7 +462,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca mQSFooterActionsViewModel.onVisibilityChangeRequested(footerVisible); } mFooter.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard) - || (expanded && !mStackScrollerOverscrolling)); + || (mQsExpanded && !mStackScrollerOverscrolling)); mQSPanelController.setVisibility(qsPanelVisible ? View.VISIBLE : View.INVISIBLE); if (DEBUG) { Log.d(TAG, "Footer: " + footerVisible + ", QS Panel: " + qsPanelVisible); diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 1011a6d831e60..03dd3369773ec 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -3123,26 +3123,24 @@ public final class NotificationPanelViewController extends PanelViewController { } if (mQsExpandImmediate || (mQsExpanded && !mQsTracking && mQsExpansionAnimator == null && !mQsExpansionFromOverscroll)) { - float t; - if (mKeyguardShowing) { - + float qsExpansionFraction; + if (mSplitShadeEnabled) { + qsExpansionFraction = 1; + } else if (mKeyguardShowing) { // On Keyguard, interpolate the QS expansion linearly to the panel expansion - t = expandedHeight / (getMaxPanelHeight()); + qsExpansionFraction = expandedHeight / (getMaxPanelHeight()); } else { // In Shade, interpolate linearly such that QS is closed whenever panel height is // minimum QS expansion + minStackHeight - float - panelHeightQsCollapsed = + float panelHeightQsCollapsed = mNotificationStackScrollLayoutController.getIntrinsicPadding() + mNotificationStackScrollLayoutController.getLayoutMinHeight(); float panelHeightQsExpanded = calculatePanelHeightQsExpanded(); - t = - (expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded - - panelHeightQsCollapsed); + qsExpansionFraction = (expandedHeight - panelHeightQsCollapsed) + / (panelHeightQsExpanded - panelHeightQsCollapsed); } - float - targetHeight = - mQsMinExpansionHeight + t * (mQsMaxExpansionHeight - mQsMinExpansionHeight); + float targetHeight = mQsMinExpansionHeight + + qsExpansionFraction * (mQsMaxExpansionHeight - mQsMinExpansionHeight); setQsExpansion(targetHeight); } updateExpandedHeight(expandedHeight); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java index 5d5918de3d9e0..2a66773f924e2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java @@ -402,6 +402,19 @@ public class QSFragmentTest extends SysuiBaseFragmentTest { verify(mQSPanelController).setListening(eq(true), anyBoolean()); } + @Test + public void passCorrectExpansionState_inSplitShade() { + QSFragment fragment = resumeAndGetFragment(); + enableSplitShade(); + clearInvocations(mQSPanelController); + + fragment.setExpanded(true); + verify(mQSPanelController).setExpanded(true); + + fragment.setExpanded(false); + verify(mQSPanelController).setExpanded(false); + } + @Override protected Fragment instantiate(Context context, String className, Bundle arguments) { MockitoAnnotations.initMocks(this);