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

Commit 233ab990 authored by Tony Wickham's avatar Tony Wickham
Browse files

Consistently multiply touch slop for InputConsumers

Fixes: 268651129
Test: TaplTestsQuickstep; manually swipe up from various InputConsumers
Change-Id: I0a3baf654092a1a0bdafbfc734ec394668ba60f6
parent 4d559a6c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.os.SystemProperties;
import android.os.UserManager;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.ViewConfiguration;

import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -87,6 +88,10 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {

    static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";

    // TODO: Move to quickstep contract
    private static final float QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON = 9;
    private static final float QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL = 2;

    private final Context mContext;
    private final DisplayController mDisplayController;
    private final int mDisplayId;
@@ -577,6 +582,19 @@ public class RecentsAnimationDeviceState implements DisplayInfoChangeListener {
                && ((mSystemUiStateFlags & SYSUI_STATE_IME_SHOWING) != 0);
    }

    /**
     * Returns the touch slop for {@link InputConsumer}s to compare against before pilfering
     * pointers. Note that this is squared because it expects to be compared against
     * {@link com.android.launcher3.Utilities#squaredHypot} (to avoid square root on each event).
     */
    public float getSquaredTouchSlop() {
        float slopMultiplier = isFullyGesturalNavMode()
                ? QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL
                : QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON;
        float touchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
        return slopMultiplier * touchSlop * touchSlop;
    }

    public String getSystemUiStateString() {
        return  QuickStepContract.getSystemUiStateString(mSystemUiStateFlags);
    }
+1 −2
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_UP;

import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.util.VelocityUtils.PX_PER_MS;
import static com.android.quickstep.AbsSwipeUpHandler.MIN_PROGRESS_FOR_OVERVIEW;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
@@ -115,7 +114,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
        mDeviceState = deviceState;
        mTaskAnimationManager = taskAnimationManager;
        mGestureState = gestureState;
        mTouchSlopSquared = squaredTouchSlop(context);
        mTouchSlopSquared = mDeviceState.getSquaredTouchSlop();
        mTransformParams = new TransformParams();
        mInputMonitorCompat = inputMonitorCompat;
        mMaxTranslationY = context.getResources().getDimensionPixelSize(
+2 −3
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;

import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE;

import android.content.Context;
import android.graphics.Point;
@@ -31,7 +31,6 @@ import android.view.MotionEvent;

import com.android.launcher3.R;
import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.InputConsumer;
import com.android.quickstep.RecentsAnimationDeviceState;
@@ -69,7 +68,7 @@ public class OneHandedModeInputConsumer extends DelegateInputConsumer {
        mDeviceState = deviceState;
        mDragDistThreshold = context.getResources().getDimensionPixelSize(
                R.dimen.gestures_onehanded_drag_threshold);
        mSquaredSlop = Utilities.squaredTouchSlop(context);
        mSquaredSlop = mDeviceState.getSquaredTouchSlop();
        mDisplaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
        mNavBarSize = ResourceUtils.getNavbarSize(NAVBAR_BOTTOM_GESTURE_SIZE,
                mContext.getResources());
+1 −8
Original line number Diff line number Diff line
@@ -80,10 +80,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
    public static final String DOWN_EVT = "OtherActivityInputConsumer.DOWN";
    private static final String UP_EVT = "OtherActivityInputConsumer.UP";

    // TODO: Move to quickstep contract
    public static final float QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON = 9;
    public static final float QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL = 2;

    // Minimum angle of a gesture's coordinate where a release goes to overview.
    public static final int OVERVIEW_MIN_DEGREES = 15;

@@ -157,11 +153,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
        boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning();
        mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget;

        float slopMultiplier = mDeviceState.isFullyGesturalNavMode()
                ? QUICKSTEP_TOUCH_SLOP_RATIO_GESTURAL
                : QUICKSTEP_TOUCH_SLOP_RATIO_TWO_BUTTON;
        mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
        mSquaredTouchSlop = slopMultiplier * mTouchSlop * mTouchSlop;
        mSquaredTouchSlop = mDeviceState.getSquaredTouchSlop();

        mPassedPilferInputSlop = mPassedWindowMoveSlop = continuingPreviousGesture;
        mDisableHorizontalSwipe = !mPassedPilferInputSlop && disableHorizontalSwipe;
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
            InputMonitorCompat inputMonitor, TaskbarActivityContext taskbarActivityContext) {
        super(delegate, inputMonitor);
        mTaskbarActivityContext = taskbarActivityContext;
        // TODO(b/270395798): remove this when cleaning up old Persistent Taskbar code.
        mSquaredTouchSlop = Utilities.squaredTouchSlop(context);
        mScreenWidth = taskbarActivityContext.getDeviceProfile().widthPx;