From f46f7d429c1fbbf6e92219a00c18dc504079bb34 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Wed, 9 Mar 2022 18:00:54 +0000 Subject: [PATCH] Fix split shade issues when going from portrait expanded quick settings Fixes a couple of issues with the split shade when starting from normal shade with expanded quick settings to split shade: * Notifications are not scrollable updateQsState() wasn't called when switching between normal shade <-> split shade. It calls setScrollingEnabled which is based on whether quick settings in full screen or not (basically are we in split shade or not). * Footer is not visible There was a recent change that hides footer when quick settings expanded to avoid animation issues. We don't need this for split shade, so added a check so we don't hide them in split shade. * Notifications are not collapsed into shelf Stack height was not updated when quick settings are expanded, so the end of the stack was outside of the screen bounds. Added exception for non-fullscreen quick settings to update the height. * Notification stack is clipped incorrectly This is especially visible when swiping quickly, you can see that 'manage'/'clear all' buttons go outside of the shade background. Updated clipping calculation so notification background doesn't add corner radius to the coordinates by default and we add bottom margin to calculate the bottom part of the clipping rectangle. Bug: 222699879 Test: expanding/closing quick settings and switching between splitshade/non-splitshade => checking that the shade is rendered correctly Change-Id: Ieb9a8dddccf08f5b333a5065d78694278ca5ed55 --- .../android/systemui/scrim/ScrimDrawable.java | 2 +- .../stack/NotificationStackScrollLayout.java | 8 ++++++-- .../phone/NotificationPanelViewController.java | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/scrim/ScrimDrawable.java b/packages/SystemUI/src/com/android/systemui/scrim/ScrimDrawable.java index 3c6ab34733e58..bbba0071094b1 100644 --- a/packages/SystemUI/src/com/android/systemui/scrim/ScrimDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/scrim/ScrimDrawable.java @@ -199,7 +199,7 @@ public class ScrimDrawable extends Drawable { drawConcave(canvas); } else if (mCornerRadiusEnabled && mCornerRadius > 0) { canvas.drawRoundRect(getBounds().left, getBounds().top, getBounds().right, - getBounds().bottom + mCornerRadius, + getBounds().bottom, /* x radius*/ mCornerRadius, /* y radius*/ mCornerRadius, mPaint); } else { canvas.drawRect(getBounds().left, getBounds().top, getBounds().right, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index c89f4d7978197..5c68559ffb1ee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -689,7 +689,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable boolean showFooterView = (showDismissView || mController.getVisibleNotificationCount() > 0) && mIsCurrentUserSetup // see: b/193149550 && mStatusBarState != StatusBarState.KEYGUARD - && mQsExpansionFraction != 1 + // quick settings don't affect notifications when not in full screen + && (mQsExpansionFraction != 1 || !mQsFullScreen) && !mScreenOffAnimationController.shouldHideNotificationsFooter() && !mIsRemoteInputActive; boolean showHistory = mController.isHistoryEnabled(); @@ -799,6 +800,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable y = (int) (mAmbientState.getStackY() + mKeyguardNotificationAvailableSpace); drawDebugInfo(canvas, y, Color.RED, /* label= */ "mAmbientState.getStackY() + mKeyguardNotificationAvailableSpace = " + y); + + drawDebugInfo(canvas, mRoundedRectClippingBottom, Color.DKGRAY, + /* label= */ "mRoundedRectClippingBottom) = " + y); } private void drawDebugInfo(Canvas canvas, int y, int color, String label) { @@ -1311,7 +1315,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable if (mOnStackYChanged != null) { mOnStackYChanged.accept(listenerNeedsAnimation); } - if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) { + if ((mQsExpansionFraction <= 0 || !mQsFullScreen) && !shouldSkipHeightUpdate()) { final float endHeight = updateStackEndHeight(); updateStackHeight(endHeight, fraction); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 5746ffb6debe7..6cca9045d867e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -1098,6 +1098,8 @@ public class NotificationPanelViewController extends PanelViewController { if (splitNotificationShadeChanged) { updateClockAppearance(); + updateQsState(); + mNotificationStackScrollLayoutController.updateFooter(); } } @@ -2348,7 +2350,7 @@ public class NotificationPanelViewController extends PanelViewController { private int calculateBottomQsClippingBound(int top) { if (mShouldUseSplitNotificationShade) { return top + mNotificationStackScrollLayoutController.getHeight() - - mSplitShadeNotificationsScrimMarginBottom; + + mSplitShadeNotificationsScrimMarginBottom; } else { return getView().getBottom(); } @@ -2466,7 +2468,12 @@ public class NotificationPanelViewController extends PanelViewController { // be visible, otherwise you can see the bounds once swiping up to see bouncer mScrimController.setNotificationsBounds(0, 0, 0, 0); } else { - mScrimController.setNotificationsBounds(left, top, right, bottom); + // Increase the height of the notifications scrim when not in split shade + // (e.g. portrait tablet) so the rounded corners are not visible at the bottom, + // in this case they are rendered off-screen + final int notificationsScrimBottom = + mShouldUseSplitNotificationShade ? bottom : bottom + radius; + mScrimController.setNotificationsBounds(left, top, right, notificationsScrimBottom); } if (mShouldUseSplitNotificationShade) { @@ -2476,10 +2483,13 @@ public class NotificationPanelViewController extends PanelViewController { } mScrimController.setScrimCornerRadius(radius); + + // Convert global clipping coordinates to local ones, + // relative to NotificationStackScrollLayout int nsslLeft = left - mNotificationStackScrollLayoutController.getLeft(); int nsslRight = right - mNotificationStackScrollLayoutController.getLeft(); int nsslTop = top - mNotificationStackScrollLayoutController.getTop(); - int nsslBottom = bottom; + int nsslBottom = bottom - mNotificationStackScrollLayoutController.getTop(); int bottomRadius = mShouldUseSplitNotificationShade ? radius : 0; mNotificationStackScrollLayoutController.setRoundedClippingBounds( nsslLeft, nsslTop, nsslRight, nsslBottom, radius, bottomRadius);