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
This commit is contained in:
Selim Cinek
2017-02-28 17:22:49 -08:00
parent fc9fb15c22
commit 1b5543939a
2 changed files with 12 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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;
}
}