From 6183d12926a189b08cc3be8d9c78470617e63db0 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 14 Jan 2016 18:48:41 -0800 Subject: [PATCH] Fixed that music notifications were not clickable on lockscreen On the lockscreen we were unintentionally disabling single clicks on the media buttons while we only wanted to disallow it for the notification header. This is now fixed by explicitly checking if we are clicking on the notification header. Bug: 26325096 Change-Id: I044f25ac3216b98c7769c31d09d19f801a437194 --- core/java/android/view/NotificationHeaderView.java | 7 ++++++ .../statusbar/ActivatableNotificationView.java | 25 +++++++++++++--------- .../statusbar/ExpandableNotificationRow.java | 13 +++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 6fd0e6711545..1c0ea0f9120b 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -335,4 +335,11 @@ public class NotificationHeaderView extends LinearLayout { public boolean hasOverlappingRendering() { return false; } + + public boolean isInTouchRect(float x, float y) { + if (mExpandClickListener == null) { + return false; + } + return mTouchListener.isInside(x, y); + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java index 9958b960b93f..38d24ced806f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java @@ -176,26 +176,31 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView }; @Override - public boolean dispatchTouchEvent(MotionEvent event) { - if (mDimmed && !mActivated) { - return handleTouchEventDimmed(event); - } else { - return super.dispatchTouchEvent(event); + public boolean onInterceptTouchEvent(MotionEvent ev) { + if (mDimmed && !mActivated + && ev.getActionMasked() == MotionEvent.ACTION_DOWN && disallowSingleClick(ev)) { + return true; } + return super.onInterceptTouchEvent(ev); + } + + protected boolean disallowSingleClick(MotionEvent ev) { + return false; } @Override public boolean onTouchEvent(MotionEvent event) { boolean result; - if (mDimmed && mActivated) { + if (mDimmed) { + boolean wasActivated = mActivated; result = handleTouchEventDimmed(event); + if (wasActivated && result && event.getAction() == MotionEvent.ACTION_UP) { + mFalsingManager.onNotificationDoubleTap(); + removeCallbacks(mTapTimeoutRunnable); + } } else { result = super.onTouchEvent(event); } - if (mActivated && result && event.getAction() == MotionEvent.ACTION_UP) { - mFalsingManager.onNotificationDoubleTap(); - removeCallbacks(mTapTimeoutRunnable); - } return result; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java index f80630b6317b..45c5cfb5c15a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java @@ -25,8 +25,10 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.service.notification.StatusBarNotification; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.NotificationHeaderView; import android.view.View; +import android.view.ViewGroup; import android.view.ViewStub; import android.view.accessibility.AccessibilityEvent; import android.widget.Chronometer; @@ -1113,6 +1115,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { mLoggingKey = key; } + @Override + protected boolean disallowSingleClick(MotionEvent event) { + float x = event.getX(); + float y = event.getY(); + NotificationHeaderView header = getNotificationHeader(); + if (header != null) { + return header.isInTouchRect(x, y); + } + return super.disallowSingleClick(event); + } + private void logExpansionEvent(boolean userAction, boolean wasExpanded) { final boolean nowExpanded = isExpanded(); if (wasExpanded != nowExpanded && mLogger != null) { -- 2.11.0