From 3a950c371648ef20600a951cac11507fb7a1f190 Mon Sep 17 00:00:00 2001 From: shawnlin Date: Wed, 15 May 2019 20:06:10 +0800 Subject: [PATCH] Not showing menu buttons for any headsup notification Since swipe to remove notification behavior was rolled back to P which allows user to remove a notification in both direction. We should not showing menu buttons for any heads up notification either as in P. Now it depends on the mIsUsingBidirectionalSwipe flag of NotificationMenuRow to show menu buttons & the background. Bug: 132668574 Test: send headsup notifications and swipe left/right case and swipe left/right to check the background. Change-Id: I5b96faed05d6184e02a8ede08f5e7c04ba5c456a --- .../stack/NotificationStackScrollLayout.java | 4 +++- .../notification/stack/NotificationSwipeHelper.java | 9 ++++++++- 2 files changed, 11 insertions(+), 2 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 de187f1de1cc1..7ee0fbc16fbc0 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 @@ -913,7 +913,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd if (child.getVisibility() != View.GONE && child instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) child; - if ((row.isPinned() || row.isHeadsUpAnimatingAway()) && row.getTranslation() < 0) { + if ((row.isPinned() || row.isHeadsUpAnimatingAway()) && row.getTranslation() < 0 + && row.getProvider().shouldShowGutsOnSnapOpen()) { top = Math.min(top, row.getTranslationY()); bottom = Math.max(bottom, row.getTranslationY() + row.getActualHeight()); } @@ -4378,6 +4379,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mStackScrollAlgorithm.setIsExpanded(isExpanded); mAmbientState.setShadeExpanded(isExpanded); mStateAnimator.setShadeExpanded(isExpanded); + mSwipeHelper.setIsExpanded(isExpanded); if (changed) { if (!mIsExpanded) { mGroupManager.collapseAllGroups(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java index 4569b66d65f79..0f71192277df1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java @@ -48,6 +48,7 @@ class NotificationSwipeHelper extends SwipeHelper private static final long SWIPE_MENU_TIMING = 200; private NotificationMenuRowPlugin mCurrMenuRow; + private boolean mIsExpanded; public NotificationSwipeHelper(int swipeDirection, NotificationCallback callback, Context context, NotificationMenuRowPlugin.OnMenuEventListener menuListener) { @@ -97,6 +98,10 @@ class NotificationSwipeHelper extends SwipeHelper return mFalsingCheck; } + public void setIsExpanded(boolean isExpanded) { + mIsExpanded = isExpanded; + } + @Override protected void onChildSnappedBack(View animView, float targetLeft) { if (mCurrMenuRow != null && targetLeft == 0) { @@ -200,7 +205,9 @@ class NotificationSwipeHelper extends SwipeHelper boolean slowSwipedFarEnough = swipedEnoughToShowMenu(menuRow) && isSlowSwipe; boolean isFastNonDismissGesture = gestureFastEnough && !gestureTowardsMenu && !isDismissGesture; - boolean isMenuRevealingGestureAwayFromMenu = slowSwipedFarEnough || isFastNonDismissGesture; + boolean isAbleToShowMenu = menuRow.shouldShowGutsOnSnapOpen() || mIsExpanded; + boolean isMenuRevealingGestureAwayFromMenu = slowSwipedFarEnough + || (isFastNonDismissGesture && isAbleToShowMenu); int menuSnapTarget = menuRow.getMenuSnapTarget(); boolean isNonFalseMenuRevealingGesture = !isFalseGesture(ev) && isMenuRevealingGestureAwayFromMenu;