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
This commit is contained in:
Andreas Agvard committed 2023-11-16 17:55:34 +01:00
1 parent da18b9e435
commit 0fc7d52863
2 files changed
+7 -1

No files matched your search

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