From 0fc7d528639fc678f73f0f2a922d606b85aaab34 Mon Sep 17 00:00:00 2001 From: Andreas Agvard Date: Thu, 16 Nov 2023 17:51:00 +0100 Subject: [PATCH] Makes deep press for LPNH toggelable By default when deep press is detected (https://developer.android.com/reference/android/view/MotionEvent#CLASSIFICATION_DEEP_PRESS) during LPNH triggers the long press action immediately. This change makes this toggelable. Flag is set to enabled by default, which leads to the default behavior. Fix: 310952290 Test: Manual Flag: LEGACY ENABLE_LPNH_DEEP_PRESS ENABLED Change-Id: I970fed697979ee528e54b8be0139d842f3a64c43 --- .../inputconsumers/NavHandleLongPressInputConsumer.java | 4 +++- src/com/android/launcher3/config/FeatureFlags.java | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java index d38376cace..8051e68f2f 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java @@ -42,6 +42,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { private final Runnable mTriggerLongPress = this::triggerLongPress; private final float mTouchSlopSquared; private final int mLongPressTimeout; + private final boolean mDeepPressEnabled; private MotionEvent mCurrentDownEvent; @@ -51,6 +52,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { mNavHandleWidth = context.getResources().getDimensionPixelSize( R.dimen.navigation_home_handle_width); mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x; + mDeepPressEnabled = FeatureFlags.ENABLE_LPNH_DEEP_PRESS.get(); if (FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) { mLongPressTimeout = LauncherPrefs.get(context).get(LONG_PRESS_NAV_HANDLE_TIMEOUT_MS); } else { @@ -108,7 +110,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { } // If the gesture is deep press then trigger long press asap - if (MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress) + if (mDeepPressEnabled && MAIN_EXECUTOR.getHandler().hasCallbacks(mTriggerLongPress) && ev.getClassification() == MotionEvent.CLASSIFICATION_DEEP_PRESS) { MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress); MAIN_EXECUTOR.getHandler().post(mTriggerLongPress); diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 7d9f70980b..26751eedc1 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -302,6 +302,10 @@ public final class FeatureFlags { getIntFlag(309972570, "FLAG_LPNH_HAPTIC_HINT_ITERATIONS", 50, "Haptic hint number of iterations."); + public static final BooleanFlag ENABLE_LPNH_DEEP_PRESS = + getReleaseFlag(310952290, "ENABLE_LPNH_DEEP_PRESS", ENABLED, + "Long press of nav handle is instantly triggered if deep press is detected."); + // TODO(Block 17): Clean up flags // Aconfig migration complete for ENABLE_TASKBAR_PINNING. private static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(270396583,