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

Commit b9c8428d authored by Matthew Ng's avatar Matthew Ng
Browse files

Added edge swipe support for along nav bar direction

Added edge swipe from right to left and left to right on nav bar in
portrait. Also added quick switch action to apply a global setting to
switch between quick scrub and quick switch.

Test: atest QuickStepControllerTest
Bug: 112934365
Change-Id: I0d00608635bda63b3f77f12ec0b67b85f24a633c
parent 3c359caa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@
    <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_height</dimen>
    <!-- Minimum swipe distance to catch the swipe gestures to invoke assist or switch tasks. -->
    <dimen name="navigation_bar_min_swipe_distance">48dp</dimen>
    <!-- The distance from a side of device of the navigation bar to start an edge swipe -->
    <dimen name="navigation_bar_edge_swipe_threshold">60dp</dimen>

    <!-- thickness (height) of the dead zone at the top of the navigation bar,
         reducing false presses on navbar buttons; approx 2mm -->
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,11 @@ public class NavigationBackAction extends NavigationGestureAction {
        super(navigationBarView, service);
    }

    @Override
    public boolean allowHitTargetToMoveOverDrag() {
        return true;
    }

    @Override
    public boolean canPerformAction() {
        return mProxySender.getBackButtonAlpha() > 0;
+8 −2
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
    private QuickScrubAction mQuickScrubAction;
    private QuickStepAction mQuickStepAction;
    private NavigationBackAction mBackAction;
    private QuickSwitchAction mQuickSwitchAction;

    /**
     * Helper that is responsible for showing the right toast when a disallowed activity operation
@@ -326,9 +327,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        mQuickScrubAction = new QuickScrubAction(this, mOverviewProxyService);
        mQuickStepAction = new QuickStepAction(this, mOverviewProxyService);
        mBackAction = new NavigationBackAction(this, mOverviewProxyService);
        mQuickSwitchAction = new QuickSwitchAction(this, mOverviewProxyService);
        mDefaultGestureMap = new NavigationGestureAction[] {
                mQuickStepAction, null /* swipeDownAction*/, null /* swipeLeftAction */,
                mQuickScrubAction
                mQuickScrubAction, null /* swipeLeftEdgeAction */, null /* swipeRightEdgeAction */
        };

        mPrototypeController = new NavigationPrototypeController(mHandler, mContext);
@@ -359,7 +361,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                    getNavigationActionFromType(assignedMap[0], mDefaultGestureMap[0]),
                    getNavigationActionFromType(assignedMap[1], mDefaultGestureMap[1]),
                    getNavigationActionFromType(assignedMap[2], mDefaultGestureMap[2]),
                    getNavigationActionFromType(assignedMap[3], mDefaultGestureMap[3]));
                    getNavigationActionFromType(assignedMap[3], mDefaultGestureMap[3]),
                    getNavigationActionFromType(assignedMap[4], mDefaultGestureMap[4]),
                    getNavigationActionFromType(assignedMap[5], mDefaultGestureMap[5]));
        }
    }

@@ -372,6 +376,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                return mQuickScrubAction;
            case NavigationPrototypeController.ACTION_BACK:
                return mBackAction;
            case NavigationPrototypeController.ACTION_QUICKSWITCH:
                return mQuickSwitchAction;
            default:
                return defaultAction;
        }
+4 −4
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public abstract class NavigationGestureAction {
    /**
     * @return whether or not to move the button that started gesture over with user input drag
     */
    public boolean requiresDragWithHitTarget() {
    public boolean allowHitTargetToMoveOverDrag() {
        return false;
    }

@@ -139,9 +139,9 @@ public abstract class NavigationGestureAction {
     * Tell if action is enabled. Compared to {@link #canPerformAction()} this is based on settings
     * if the action is disabled for a particular gesture. For example a back action can be enabled
     * however if there is nothing to back to then {@link #canPerformAction()} should return false.
     * In this way if the action requires {@link #requiresDragWithHitTarget()} then if enabled, the
     * button can be dragged with a large dampening factor during the gesture but will not activate
     * the action.
     * In this way if the action requires {@link #allowHitTargetToMoveOverDrag()} then if enabled,
     * the button can be dragged with a large dampening factor during the gesture but will not
     * activate the action.
     * @return true if this action is enabled and can run
     */
    public abstract boolean isEnabled();
+2 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.os.Handler;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;

import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -46,6 +45,7 @@ public class NavigationPrototypeController extends ContentObserver {
    static final int ACTION_QUICKSTEP = 1;
    static final int ACTION_QUICKSCRUB = 2;
    static final int ACTION_BACK = 3;
    static final int ACTION_QUICKSWITCH = 4;

    private OnPrototypeChangedListener mListener;

@@ -53,7 +53,7 @@ public class NavigationPrototypeController extends ContentObserver {
     * Each index corresponds to a different action set in QuickStepController
     * {@see updateSwipeLTRBackSetting}
     */
    private int[] mActionMap = new int[4];
    private int[] mActionMap = new int[6];

    private final Context mContext;

Loading