From 7a5b2b6d382cd8f9a081989ceab7a63ce9eee4d0 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 14 Apr 2017 18:53:45 -0700 Subject: [PATCH] Fix issue where the notification could snap to the menu while its invisible 1) If the snap back animation is cancelled, the menu shouldn't be reset because it hasn't actually been snapped back -- this could happen when the menu was being shown and then the icon alpha would get set to 0 resulting in notification snapped to menu but no menu visible 2) Cancel the callback to fade the menu in on dismiss to match original behavior before refactor of NMR Test: manual - no clear repro steps for this, I could get it by violently moving a notification back and forth, with this patch I haven't been able to repro it. Bug: 37320279 Change-Id: I4eea37e3c454e7324d0e295b0ec2fe022d219253 --- .../src/com/android/systemui/SwipeHelper.java | 13 +++++++++++-- .../systemui/statusbar/NotificationMenuRow.java | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 5a04108df8078..8c4159abf0610 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -462,11 +462,20 @@ public class SwipeHelper implements Gefingerpoken { int duration = SNAP_ANIM_LEN; anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { + boolean wasCancelled = false; + + @Override + public void onAnimationCancel(Animator animator) { + wasCancelled = true; + } + @Override public void onAnimationEnd(Animator animator) { mSnappingChild = false; - updateSwipeProgressFromOffset(animView, canBeDismissed); - mCallback.onChildSnappedBack(animView, targetLeft); + if (!wasCancelled) { + updateSwipeProgressFromOffset(animView, canBeDismissed); + mCallback.onChildSnappedBack(animView, targetLeft); + } } }); prepareSnapBackAnimation(animView, anim); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java index fee24b7b76455..7faa866404fe1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationMenuRow.java @@ -316,6 +316,10 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } private void dismiss(View animView, float velocity) { + if (mFadeAnimator != null) { + mFadeAnimator.cancel(); + } + mHandler.removeCallbacks(mCheckForDrag); mMenuSnappedTo = false; mDismissing = true; mSwipeHelper.dismiss(animView, velocity);