From 1b5543939a7e07f5a1238c8d880b87586c4a06cd Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 28 Feb 2017 17:22:49 -0800 Subject: [PATCH] All touches to low priority headers should be accepted Since there is no conflicting touch target, we now accept all touches there. Test: add low-pririty notification, click below text Fixes: 35851799 Change-Id: Iae36fc6b950a0dbb569bfae43a5505588d9e0ace --- core/java/android/app/Notification.java | 2 +- core/java/android/view/NotificationHeaderView.java | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index e8ddc41ee68c3..96d44a5215b02 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4177,7 +4177,7 @@ public class Notification implements Parcelable } RemoteViews header = makeNotificationHeader(); - + header.setBoolean(R.id.notification_header, "setAcceptAllTouches", true); if (summary != null) { mN.extras.putCharSequence(EXTRA_SUB_TEXT, summary); } else { diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index c3d3f3918ccf4..16d46666732de 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -94,6 +94,7 @@ public class NotificationHeaderView extends ViewGroup { } } }; + private boolean mAcceptAllTouches; public NotificationHeaderView(Context context) { this(context, null); @@ -374,6 +375,8 @@ public class NotificationHeaderView extends ViewGroup { case MotionEvent.ACTION_DOWN: mTrackGesture = false; if (isInside(x, y)) { + mDownX = x; + mDownY = y; mTrackGesture = true; return true; } @@ -396,11 +399,12 @@ public class NotificationHeaderView extends ViewGroup { } private boolean isInside(float x, float y) { + if (mAcceptAllTouches) { + return true; + } for (int i = 0; i < mTouchRects.size(); i++) { Rect r = mTouchRects.get(i); if (r.contains((int) x, (int) y)) { - mDownX = x; - mDownY = y; return true; } } @@ -433,4 +437,9 @@ public class NotificationHeaderView extends ViewGroup { } return mTouchListener.isInside(x, y); } + + @RemotableViewMethod + public void setAcceptAllTouches(boolean acceptAllTouches) { + mAcceptAllTouches = acceptAllTouches; + } }