Add custom extra width to trigger LPNH
This is defined in dp from the edge of the nav handle. So if you
set it to 48, you can invoke 48dp from the left or right of the
handle (which is roughly the size of an average fingertip).
You can also set it to a negative value to make the invocation
region smaller. This applies to both navbar and stashed taskbar,
and the minimum touch target is always 48dp.
For reference, the navbar width is 108dp and taskbar is 220dp.
Defaults to 0, i.e. you can only invoke within the visible navbar.
Bug: 325118077
Flag: LEGACY CUSTOM_LPNH_THRESHOLDS DISABLED
Test: Manual
Change-Id: I904a484a99ac4af05de13573fac610b84fd7f0f1
diff --git a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
index 369ff14..6713964 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java
@@ -22,6 +22,7 @@
import static com.android.launcher3.LauncherPrefs.ALL_APPS_OVERVIEW_THRESHOLD;
import static com.android.launcher3.LauncherPrefs.PRIVATE_SPACE_APPS;
+import static com.android.launcher3.config.FeatureFlags.LPNH_EXTRA_TOUCH_WIDTH_DP;
import static com.android.launcher3.config.FeatureFlags.LPNH_HAPTIC_HINT_DELAY;
import static com.android.launcher3.config.FeatureFlags.LPNH_HAPTIC_HINT_END_SCALE_PERCENT;
import static com.android.launcher3.config.FeatureFlags.LPNH_HAPTIC_HINT_ITERATIONS;
@@ -359,6 +360,10 @@
"Slop multiplier (applied to edge slop, "
+ "which is generally already 50% higher than touch slop)",
25, 200, 100, LPNH_SLOP_PERCENTAGE));
+ category.addPreference(createSeekBarPreference(
+ "Extra width DP (how far outside the sides of the nav bar to trigger)",
+ // Stashed taskbar is currently 220dp; -86 (x2) would result in 48dp touch area.
+ -86, 100, 1, LPNH_EXTRA_TOUCH_WIDTH_DP));
category.addPreference(createSeekBarPreference("LPNH timeout",
100, 500, 1, LPNH_TIMEOUT_MS));
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index cf8750f..e4a8619 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -22,9 +22,11 @@
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import android.content.Context;
+import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
+import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.util.DisplayController;
@@ -39,6 +41,8 @@
*/
public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
+ private static final String TAG = "NavHandleLongPressIC";
+
private final NavHandleLongPressHandler mNavHandleLongPressHandler;
private final float mNavHandleWidth;
private final float mScreenWidth;
@@ -175,6 +179,14 @@
private boolean isInNavBarHorizontalArea(float x) {
float areaFromMiddle = mNavHandleWidth / 2.0f;
+ if (FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) {
+ areaFromMiddle += Utilities.dpToPx(FeatureFlags.LPNH_EXTRA_TOUCH_WIDTH_DP.get());
+ }
+ int minAccessibleSize = Utilities.dpToPx(24); // Half of 48dp because this is per side.
+ if (areaFromMiddle < minAccessibleSize) {
+ Log.w(TAG, "Custom nav handle region is too small - resetting to 48dp");
+ areaFromMiddle = minAccessibleSize;
+ }
float distFromMiddle = Math.abs(mScreenWidth / 2.0f - x);
return distFromMiddle < areaFromMiddle;
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index b0a644b..27e084c 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -309,6 +309,13 @@
val LONG_PRESS_NAV_HANDLE_SLOP_PERCENTAGE =
nonRestorableItem("LPNH_SLOP_PERCENTAGE", 100, EncryptionType.MOVE_TO_DEVICE_PROTECTED)
@JvmField
+ val LONG_PRESS_NAV_HANDLE_EXTRA_TOUCH_WIDTH_DP =
+ nonRestorableItem(
+ "LPNH_EXTRA_TOUCH_WIDTH_DP",
+ 0,
+ EncryptionType.MOVE_TO_DEVICE_PROTECTED
+ )
+ @JvmField
val LONG_PRESS_NAV_HANDLE_TIMEOUT_MS =
nonRestorableItem(
"LPNH_TIMEOUT_MS",
@@ -349,8 +356,8 @@
@JvmField
val PRIVATE_SPACE_APPS =
nonRestorableItem("pref_private_space_apps", 0, EncryptionType.MOVE_TO_DEVICE_PROTECTED)
- @JvmField val ENABLE_TWOLINE_ALLAPPS_TOGGLE =
- backedUpItem("pref_enable_two_line_toggle", false)
+ @JvmField
+ val ENABLE_TWOLINE_ALLAPPS_TOGGLE = backedUpItem("pref_enable_two_line_toggle", false)
@JvmField
val THEMED_ICONS =
backedUpItem(Themes.KEY_THEMED_ICONS, false, EncryptionType.MOVE_TO_DEVICE_PROTECTED)
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 072a96c..e25e033 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -17,6 +17,7 @@
package com.android.launcher3.config;
import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN;
+import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_EXTRA_TOUCH_WIDTH_DP;
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_HAPTIC_HINT_DELAY;
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_HAPTIC_HINT_END_SCALE_PERCENT;
import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_HAPTIC_HINT_ITERATIONS;
@@ -147,6 +148,12 @@
"Controls touch slop percentage for lpnh",
LONG_PRESS_NAV_HANDLE_SLOP_PERCENTAGE);
+ public static final IntFlag LPNH_EXTRA_TOUCH_WIDTH_DP =
+ FlagsFactory.getIntFlag(301680992, "LPNH_EXTRA_TOUCH_WIDTH_DP", 0,
+ "Controls extra dp on the nav bar sides to trigger LPNH."
+ + " Can be negative for a smaller touch region.",
+ LONG_PRESS_NAV_HANDLE_EXTRA_TOUCH_WIDTH_DP);
+
public static final IntFlag LPNH_TIMEOUT_MS =
FlagsFactory.getIntFlag(301680992, "LPNH_TIMEOUT_MS",
ViewConfiguration.getLongPressTimeout(),