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
This commit is contained in:
Selim Cinek
2016-01-14 18:48:41 -08:00
parent 3bdbf28b49
commit 6183d12926
3 changed files with 35 additions and 10 deletions

View File

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

View File

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

View File

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