NavHandleLongPressInputConsumer now cancels long press detection on intercept.
Before handling a touch event NavHandleLongPressInputConsumer now checks
mDelegate.allowInterceptByParent() to ensure a parent has not intercepted the
touch event.
Flag: LEGACY ENABLE_LONG_PRESS_NAV_HANDLE DISABLED
Bug: 305924072
Test: Manual
Change-Id: I0d7bcceba881a21ad00e56c3e18b4ebde878ee89
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index 32f7bd5..07c85bb 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -38,7 +38,6 @@
private final NavHandleLongPressHandler mNavHandleLongPressHandler;
private final float mNavHandleWidth;
private final float mScreenWidth;
- private final ViewConfiguration mViewConfiguration;
private final Runnable mTriggerLongPress = this::triggerLongPress;
private final float mTouchSlopSquared;
@@ -49,7 +48,6 @@
public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate,
InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState) {
super(delegate, inputMonitor);
- mViewConfiguration = ViewConfiguration.get(context);
mNavHandleWidth = context.getResources().getDimensionPixelSize(
R.dimen.navigation_home_handle_width);
mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
@@ -69,6 +67,18 @@
@Override
public void onMotionEvent(MotionEvent ev) {
+ if (mDelegate.allowInterceptByParent()) {
+ handleMotionEvent(ev);
+ } else if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress)) {
+ cancelLongPress();
+ }
+
+ if (mState != STATE_ACTIVE) {
+ mDelegate.onMotionEvent(ev);
+ }
+ }
+
+ private void handleMotionEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN -> {
if (mCurrentDownEvent != null) {
@@ -103,10 +113,6 @@
MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress);
MAIN_EXECUTOR.getHandler().post(mTriggerLongPress);
}
-
- if (mState != STATE_ACTIVE) {
- mDelegate.onMotionEvent(ev);
- }
}
private void triggerLongPress() {