Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97f2e74c authored by Philip Quinn's avatar Philip Quinn
Browse files

Do not expand a notification if its guts are exposed.

A notification may be expanded by both ExpandHelper and SwipeHelper if
both the touch slop and long-press thresholds are crossed at the same
time. This is quite difficult to trigger with conventional touches, but
is quite easy to trigger with a deep press.

To prevent this, the SwipeHelper should not receive touches if the
ExpandHelper has expanded a notification (mExpandingNotification), and,
conversely, the ExpandHelper should not receive touches if the
SwipeHelper has exposed a notification (guts != null).

Bug: 148172385
Test: deep press on notifications; guts are exposed without
      visual/haptic glitches
Change-Id: Id81c9034bfa9c29b35d43a6125537ca5f9a2e9c4
parent 4716913d
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3756,12 +3756,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    @Override
    @ShadeViewRefactor(RefactorComponent.INPUT)
    public boolean onTouchEvent(MotionEvent ev) {
        NotificationGuts guts = mNotificationGutsManager.getExposedGuts();
        boolean isCancelOrUp = ev.getActionMasked() == MotionEvent.ACTION_CANCEL
                || ev.getActionMasked() == MotionEvent.ACTION_UP;
        handleEmptySpaceClick(ev);
        boolean expandWantsIt = false;
        boolean swipingInProgress = mSwipingInProgress;
        if (mIsExpanded && !swipingInProgress && !mOnlyScrollingInThisMotion) {
        if (mIsExpanded && !swipingInProgress && !mOnlyScrollingInThisMotion && guts == null) {
            if (isCancelOrUp) {
                mExpandHelper.onlyObserveMovements(false);
            }
@@ -3787,7 +3788,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        }

        // Check if we need to clear any snooze leavebehinds
        NotificationGuts guts = mNotificationGutsManager.getExposedGuts();
        if (guts != null && !NotificationSwipeHelper.isTouchInView(ev, guts)
                && guts.getGutsContent() instanceof NotificationSnooze) {
            NotificationSnooze ns = (NotificationSnooze) guts.getGutsContent();
@@ -4056,9 +4056,11 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        initDownStates(ev);
        handleEmptySpaceClick(ev);

        NotificationGuts guts = mNotificationGutsManager.getExposedGuts();
        boolean expandWantsIt = false;
        boolean swipingInProgress = mSwipingInProgress;
        if (!swipingInProgress && !mOnlyScrollingInThisMotion) {
        if (!swipingInProgress && !mOnlyScrollingInThisMotion && guts == null) {
            expandWantsIt = mExpandHelper.onInterceptTouchEvent(ev);
        }
        boolean scrollWantsIt = false;
@@ -4075,7 +4077,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        }
        // Check if we need to clear any snooze leavebehinds
        boolean isUp = ev.getActionMasked() == MotionEvent.ACTION_UP;
        NotificationGuts guts = mNotificationGutsManager.getExposedGuts();
        if (!NotificationSwipeHelper.isTouchInView(ev, guts) && isUp && !swipeWantsIt &&
                !expandWantsIt && !scrollWantsIt) {
            mCheckForLeavebehind = false;