Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e92f25d7 authored by Andy Wickham's avatar Andy Wickham
Browse files

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
parent 7e0703ec
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.view.View.VISIBLE;

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 @@ public class DeveloperOptionsUI {
                    "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));
        }
+12 −0
Original line number Diff line number Diff line
@@ -22,9 +22,11 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
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 @@ import com.android.systemui.shared.system.InputMonitorCompat;
 */
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 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {

    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;
+9 −2
Original line number Diff line number Diff line
@@ -309,6 +309,13 @@ class LauncherPrefs(private val encryptedContext: Context) {
        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 @@ class LauncherPrefs(private val encryptedContext: Context) {
        @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)
+7 −0
Original line number Diff line number Diff line
@@ -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 @@ public final class FeatureFlags {
                    "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(),