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

Commit 21bb53ff authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Tuning gesture nav params for trackpad 3-finger gestures

It's harder to slow down in trackpad swipes than finger swipes on the screen, so the deceleration required to be considered pause for swiping from app should be less strict (set the number for trackpad to 0.85f instead of 0.6f for on-screen). Also added a speed_trackpad_somewhat_fast for the case of swiping up to overview, so that we can be a little bit more lenient to the users for the end speed.

Bug: 375688524
Test: play with 3-finger swipe to home / overview. Make it easier to go to overview, but fast swipe from app still takes user to home
Flag: EXEMPT bugfix
Change-Id: I196a92163fd36e9b7013f4893876b79c9c2c9de0
parent 972531f5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@
    <dimen name="motion_pause_detector_speed_very_slow">0.0285dp</dimen>
    <dimen name="motion_pause_detector_speed_slow">0.15dp</dimen>
    <dimen name="motion_pause_detector_speed_somewhat_fast">0.285dp</dimen>
    <dimen name="motion_pause_detector_speed_trackpad_somewhat_fast">0.7dp</dimen>
    <dimen name="motion_pause_detector_speed_fast">1.4dp</dimen>
    <dimen name="motion_pause_detector_min_displacement_from_app">36dp</dimen>
    <dimen name="quickstep_fling_threshold_speed">0.5dp</dimen>
+9 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public class MotionPauseDetector {
    // The percentage of the previous speed that determines whether this is a rapid deceleration.
    // The bigger this number, the easier it is to trigger the first pause.
    private static final float RAPID_DECELERATION_FACTOR = 0.6f;
    private static final float RAPID_DECELERATION_FACTOR_TRACKPAD = 0.85f;

    /** If no motion is added for this amount of time, assume the motion has paused. */
    private static final long FORCE_PAUSE_TIMEOUT = 300;
@@ -57,6 +58,7 @@ public class MotionPauseDetector {
    private final float mSpeedVerySlow;
    private final float mSpeedSlow;
    private final float mSpeedSomewhatFast;
    private final float mSpeedTrackpadSomewhatFast;
    private final float mSpeedFast;
    private final Alarm mForcePauseTimeout;
    private final boolean mMakePauseHarderToTrigger;
@@ -95,6 +97,8 @@ public class MotionPauseDetector {
        mSpeedVerySlow = res.getDimension(R.dimen.motion_pause_detector_speed_very_slow);
        mSpeedSlow = res.getDimension(R.dimen.motion_pause_detector_speed_slow);
        mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
        mSpeedTrackpadSomewhatFast = res.getDimension(
                R.dimen.motion_pause_detector_speed_trackpad_somewhat_fast);
        mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
        mForcePauseTimeout = new Alarm();
        mForcePauseTimeout.setOnAlarmListener(alarm -> {
@@ -183,7 +187,9 @@ public class MotionPauseDetector {
                    // takes too long, so also check for a rapid deceleration.
                    boolean isRapidDeceleration =
                            speed < previousSpeed * getRapidDecelerationFactor();
                    isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
                    boolean notSuperFast = speed < mSpeedSomewhatFast
                            || (mIsTrackpadGesture && speed < mSpeedTrackpadSomewhatFast);
                    isPaused = isRapidDeceleration && notSuperFast;
                    isPausedReason = new ActiveGestureLog.CompoundString(
                            "Didn't have back to back slow speeds, checking for rapid "
                                    + " deceleration on first pause only");
@@ -265,7 +271,8 @@ public class MotionPauseDetector {
    private float getRapidDecelerationFactor() {
        return mIsTrackpadGesture ? Float.parseFloat(
                Utilities.getSystemProperty("trackpad_in_app_swipe_up_deceleration_factor",
                        String.valueOf(RAPID_DECELERATION_FACTOR))) : RAPID_DECELERATION_FACTOR;
                        String.valueOf(RAPID_DECELERATION_FACTOR_TRACKPAD)))
                : RAPID_DECELERATION_FACTOR;
    }

    public interface OnMotionPauseListener {