From fa139757aa9cafa2c7e880b19defbbb4f17446be Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 27 Apr 2016 09:59:08 -0700 Subject: [PATCH] Prevent dismissal on RemoteInputView Prevents swiping out a notification when started on the RemoteInputView, as this can easily happen during text manipulation otherwise. Change-Id: I8f658eab88ca1daf8ffcb7a5d1fac4468f5f0845 Fixes: 28336831 --- .../systemui/statusbar/policy/RemoteInputView.java | 1 + .../stack/NotificationStackScrollLayout.java | 13 +++++++++++-- .../systemui/statusbar/stack/ScrollContainer.java | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index ecd1772890eff..cad4327c49de1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -250,6 +250,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene findScrollContainer(); if (mScrollContainer != null) { mScrollContainer.requestDisallowLongPress(); + mScrollContainer.requestDisallowDismiss(); } } return super.onInterceptTouchEvent(ev); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 3e0f930f60f29..07d486afe827d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -231,6 +231,7 @@ public class NotificationStackScrollLayout extends ViewGroup * animating. */ private boolean mOnlyScrollingInThisMotion; + private boolean mDisallowDismissInThisMotion; private boolean mInterceptDelegateEnabled; private boolean mDelegateToScrollView; private boolean mDisallowScrollingInThisMotion; @@ -1023,7 +1024,8 @@ public class NotificationStackScrollLayout extends ViewGroup if (!mIsBeingDragged && !mExpandingNotification && !mExpandedInThisMotion - && !mOnlyScrollingInThisMotion) { + && !mOnlyScrollingInThisMotion + && !mDisallowDismissInThisMotion) { horizontalSwipeWantsIt = mSwipeHelper.onTouchEvent(ev); } return horizontalSwipeWantsIt || scrollerWantsIt || expandWantsIt || super.onTouchEvent(ev); @@ -2003,7 +2005,8 @@ public class NotificationStackScrollLayout extends ViewGroup if (!mIsBeingDragged && !mExpandingNotification && !mExpandedInThisMotion - && !mOnlyScrollingInThisMotion) { + && !mOnlyScrollingInThisMotion + && !mDisallowDismissInThisMotion) { swipeWantsIt = mSwipeHelper.onInterceptTouchEvent(ev); } return swipeWantsIt || scrollWantsIt || expandWantsIt || super.onInterceptTouchEvent(ev); @@ -2031,6 +2034,7 @@ public class NotificationStackScrollLayout extends ViewGroup mExpandedInThisMotion = false; mOnlyScrollingInThisMotion = !mScroller.isFinished(); mDisallowScrollingInThisMotion = false; + mDisallowDismissInThisMotion = false; mTouchIsClick = true; mInitialTouchX = ev.getX(); mInitialTouchY = ev.getY(); @@ -2695,6 +2699,11 @@ public class NotificationStackScrollLayout extends ViewGroup removeLongPressCallback(); } + @Override + public void requestDisallowDismiss() { + mDisallowDismissInThisMotion = true; + } + public void removeLongPressCallback() { mSwipeHelper.removeLongPressCallback(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/ScrollContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/ScrollContainer.java index a35465e850752..64efa697de71c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/ScrollContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/ScrollContainer.java @@ -33,4 +33,9 @@ public interface ScrollContainer { * Request that the view is made visible by scrolling to it. */ void scrollTo(View v); + + /** + * Request that the view does not dismiss for the current touch. + */ + void requestDisallowDismiss(); }