From e42ee92f3ff42c2adccfddc973e408021be4a28f Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Wed, 28 Apr 2021 23:29:41 -0500 Subject: [PATCH] Scroll notifications fullscreen NSSL lets NPVC know if mOwnScrollY changed Then NPVC updates background scrim position Bug: 172289889 Test: manual Change-Id: I0e2599849df5d44021e401a4d62b378f66d1c713 --- .../stack/NotificationStackScrollLayout.java | 15 +++++++++-- ...tificationStackScrollLayoutController.java | 4 +++ .../stack/StackScrollAlgorithm.java | 3 ++- .../NotificationPanelViewController.java | 26 ++++++++++++++----- 4 files changed, 38 insertions(+), 10 deletions(-) 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 751573ac2cca5..b81619317b95c 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 @@ -431,6 +431,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private DismissAllAnimationListener mDismissAllAnimationListener; private NotificationRemoteInputManager mRemoteInputManager; private ShadeController mShadeController; + private Runnable mOnStackYChanged; private final DisplayMetrics mDisplayMetrics = Dependency.get(DisplayMetrics.class); private final LockscreenGestureLogger mLockscreenGestureLogger = @@ -1142,14 +1143,22 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ private void updateStackPosition() { // Consider interpolating from an mExpansionStartY for use on lockscreen and AOD - mAmbientState.setStackY( - MathUtils.lerp(0, mTopPadding, mAmbientState.getExpansionFraction())); + final float stackY = MathUtils.lerp(0, mTopPadding, mAmbientState.getExpansionFraction()); + mAmbientState.setStackY(stackY); + if (mOnStackYChanged != null) { + mOnStackYChanged.run(); + } + final float shadeBottom = getHeight() - getEmptyBottomMargin(); mAmbientState.setStackEndHeight(shadeBottom - mTopPadding); mAmbientState.setStackHeight( MathUtils.lerp(0, shadeBottom - mTopPadding, mAmbientState.getExpansionFraction())); } + void setOnStackYChanged(Runnable onStackYChanged) { + mOnStackYChanged = onStackYChanged; + } + /** * Update the height of the panel. * @@ -4533,7 +4542,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable // We still want to call the normal scrolled changed for accessibility reasons onScrollChanged(mScrollX, ownScrollY, mScrollX, mOwnScrollY); mOwnScrollY = ownScrollY; + updateChildren(); updateOnScrollChange(); + updateStackPosition(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 527443eff1687..ae9467eb651b5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -971,6 +971,10 @@ public class NotificationStackScrollLayoutController { mView.setQsExpansionFraction(expansionFraction); } + public void setOnStackYChanged(Runnable onStackYChanged) { + mView.setOnStackYChanged(onStackYChanged); + } + public float calculateAppearFractionBypass() { return mView.calculateAppearFractionBypass(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 27ee13ab4eafc..7d586ba3cbcef 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -151,7 +151,8 @@ public class StackScrollAlgorithm { private void updateClipping(StackScrollAlgorithmState algorithmState, AmbientState ambientState) { - float drawStart = !ambientState.isOnKeyguard() ? ambientState.getStackY() : 0; + float drawStart = !ambientState.isOnKeyguard() + ? ambientState.getStackY() - ambientState.getScrollY() : 0; float clipStart = 0; int childCount = algorithmState.visibleChildren.size(); boolean firstHeadsUp = true; 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 83a64f1a53a8a..3e5b402a287a0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -525,6 +525,7 @@ public class NotificationPanelViewController extends PanelViewController { private NotificationShelfController mNotificationShelfController; private int mScrimCornerRadius; private int mScreenCornerRadius; + private int mNotificationScrimPadding; private final QuickAccessWalletClient mQuickAccessWalletClient; private final Executor mUiExecutor; @@ -812,6 +813,8 @@ public class NotificationPanelViewController extends PanelViewController { R.dimen.notification_scrim_corner_radius); mScreenCornerRadius = mResources.getDimensionPixelSize( com.android.internal.R.dimen.rounded_corner_radius); + mNotificationScrimPadding = mResources.getDimensionPixelSize( + R.dimen.notification_side_paddings); } private void updateViewControllers(KeyguardStatusView keyguardStatusView, @@ -2043,29 +2046,37 @@ public class NotificationPanelViewController extends PanelViewController { mMediaHierarchyManager.setQsExpansion(qsExpansionFraction); int qsPanelBottomY = calculateQsBottomPosition(qsExpansionFraction); mScrimController.setQsPosition(qsExpansionFraction, qsPanelBottomY); - setNotificationBounds(qsExpansionFraction, qsPanelBottomY); mNotificationStackScrollLayoutController.setQsExpansionFraction(qsExpansionFraction); mDepthController.setQsPanelExpansion(qsExpansionFraction); } + private Runnable mOnStackYChanged = () -> { + if (mQs != null) { + setNotificationBounds(); + } + }; + /** * Updates scrim bounds, QS clipping, and KSV clipping as well based on the bounds of the shade * and QS state. - * - * @param qsFraction QS expansion fraction, from getQsExpansionFraction(). - * @param qsPanelBottomY Absolute y position of the bottom of QS as it's being pulled. */ - private void setNotificationBounds(float qsFraction, int qsPanelBottomY) { + private void setNotificationBounds() { int top = 0; int bottom = 0; int left = 0; int right = 0; - boolean visible = (qsFraction > 0 || qsPanelBottomY > 0) + + final int qsPanelBottomY = calculateQsBottomPosition(getQsExpansionFraction()); + final boolean visible = (getQsExpansionFraction() > 0 || qsPanelBottomY > 0) && !mShouldUseSplitNotificationShade; + final float notificationTop = mAmbientState.getStackY() + - mNotificationScrimPadding + - mAmbientState.getScrollY(); + setQsExpansionEnabled(mAmbientState.getScrollY() == 0); + int radius = mScrimCornerRadius; if (visible || !mShouldUseSplitNotificationShade) { if (!mShouldUseSplitNotificationShade) { - float notificationTop = mAmbientState.getStackY() - mQsNotificationTopPadding; top = (int) Math.min(qsPanelBottomY, notificationTop); bottom = getView().getBottom(); left = getView().getLeft(); @@ -3060,6 +3071,7 @@ public class NotificationPanelViewController extends PanelViewController { // The expandedHeight is always the full panel Height when bypassing expandedHeight = getMaxPanelHeightNonBypass(); } + mNotificationStackScrollLayoutController.setOnStackYChanged(mOnStackYChanged); mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight); updateKeyguardBottomAreaAlpha(); updateBigClockAlpha();