Merge "Don't send lock icon touches to NotifShade" into sc-v2-dev

This commit is contained in:
Beverly Tai
2021-12-01 18:58:17 +00:00
committed by Android (Google) Code Review
2 changed files with 30 additions and 13 deletions

View File

@@ -661,26 +661,38 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
* @return whether to intercept the touch event * @return whether to intercept the touch event
*/ */
public boolean onTouchEvent(MotionEvent event, Runnable onGestureDetectedRunnable) { public boolean onTouchEvent(MotionEvent event, Runnable onGestureDetectedRunnable) {
if (mSensorTouchLocation.contains((int) event.getX(), (int) event.getY()) if (onInterceptTouchEvent(event)) {
&& (mView.getVisibility() == View.VISIBLE
|| (mAodFp != null && mAodFp.getVisibility() == View.VISIBLE))) {
mOnGestureDetectedRunnable = onGestureDetectedRunnable; mOnGestureDetectedRunnable = onGestureDetectedRunnable;
mGestureDetector.onTouchEvent(event); mGestureDetector.onTouchEvent(event);
}
// we continue to intercept all following touches until we see MotionEvent.ACTION_CANCEL UP
// or MotionEvent.ACTION_UP. this is to avoid passing the touch to NPV
// after the lock icon disappears on device entry
if (mDownDetected) {
if (event.getAction() == MotionEvent.ACTION_CANCEL
|| event.getAction() == MotionEvent.ACTION_UP) {
mDownDetected = false;
}
return true; return true;
} }
mDownDetected = false;
return false; return false;
} }
/**
* Intercepts the touch if the onDown event and current event are within this lock icon view's
* bounds.
*/
public boolean onInterceptTouchEvent(MotionEvent event) {
if (!inLockIconArea(event) || !isClickable()) {
return false;
}
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
return true;
}
return mDownDetected;
}
private boolean inLockIconArea(MotionEvent event) {
return mSensorTouchLocation.contains((int) event.getX(), (int) event.getY())
&& (mView.getVisibility() == View.VISIBLE
|| (mAodFp != null && mAodFp.getVisibility() == View.VISIBLE));
}
private boolean isClickable() { private boolean isClickable() {
return mUdfpsSupported || mShowUnlockIcon; return mUdfpsSupported || mShowUnlockIcon;
} }

View File

@@ -338,6 +338,11 @@ public class NotificationShadeWindowViewController {
return true; return true;
} }
if (mLockIconViewController.onInterceptTouchEvent(ev)) {
// immediately return true; don't send the touch to the drag down helper
return true;
}
boolean intercept = false; boolean intercept = false;
if (mNotificationPanelViewController.isFullyExpanded() if (mNotificationPanelViewController.isFullyExpanded()
&& mDragDownHelper.isDragDownEnabled() && mDragDownHelper.isDragDownEnabled()