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

Commit 5c042b35 authored by Govinda Wasserman's avatar Govinda Wasserman Committed by Android (Google) Code Review
Browse files

Merge "Adds fling gesture suppression to Launcher" into ub-launcher3-master

parents aefcb47f fb4fe0e9
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -453,8 +453,11 @@ public class TouchInteractionService extends Service implements PluginListener<O
                // Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we should
                // Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we should
                // not interrupt it. QuickSwitch assumes that interruption can only happen if the
                // not interrupt it. QuickSwitch assumes that interruption can only happen if the
                // next gesture is also quick switch.
                // next gesture is also quick switch.
                mUncheckedConsumer = new AssistantInputConsumer(this, newGestureState,
                mUncheckedConsumer = new AssistantInputConsumer(
                        InputConsumer.NO_OP, mInputMonitorCompat);
                    this,
                    newGestureState,
                    InputConsumer.NO_OP, mInputMonitorCompat,
                    mOverviewComponentObserver.assistantGestureIsConstrained());
            } else {
            } else {
                mUncheckedConsumer = InputConsumer.NO_OP;
                mUncheckedConsumer = InputConsumer.NO_OP;
            }
            }
@@ -494,7 +497,12 @@ public class TouchInteractionService extends Service implements PluginListener<O
        }
        }
        if (mDeviceState.isFullyGesturalNavMode()) {
        if (mDeviceState.isFullyGesturalNavMode()) {
            if (mDeviceState.canTriggerAssistantAction(event)) {
            if (mDeviceState.canTriggerAssistantAction(event)) {
                base = new AssistantInputConsumer(this, newGestureState, base, mInputMonitorCompat);
                base = new AssistantInputConsumer(
                    this,
                    newGestureState,
                    base,
                    mInputMonitorCompat,
                    mOverviewComponentObserver.assistantGestureIsConstrained());
            }
            }


            if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
            if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
+10 −3
Original line number Original line Diff line number Diff line
@@ -90,12 +90,18 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
    private final float mSquaredSlop;
    private final float mSquaredSlop;
    private final Context mContext;
    private final Context mContext;
    private final GestureDetector mGestureDetector;
    private final GestureDetector mGestureDetector;
    private final boolean mIsAssistGestureConstrained;


    public AssistantInputConsumer(Context context, GestureState gestureState,
    public AssistantInputConsumer(
            InputConsumer delegate, InputMonitorCompat inputMonitor) {
            Context context,
            GestureState gestureState,
            InputConsumer delegate,
            InputMonitorCompat inputMonitor,
            boolean isAssistGestureConstrained) {
        super(delegate, inputMonitor);
        super(delegate, inputMonitor);
        final Resources res = context.getResources();
        final Resources res = context.getResources();
        mContext = context;
        mContext = context;
        mIsAssistGestureConstrained = isAssistGestureConstrained;
        mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
        mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
        mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_threshold);
        mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_threshold);
        mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
        mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold);
@@ -258,7 +264,8 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
    private class AssistantGestureListener extends SimpleOnGestureListener {
    private class AssistantGestureListener extends SimpleOnGestureListener {
        @Override
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (isValidAssistantGestureAngle(velocityX, -velocityY)
            if (!mIsAssistGestureConstrained
                && isValidAssistantGestureAngle(velocityX, -velocityY)
                    && mDistance >= mFlingDistThreshold
                    && mDistance >= mFlingDistThreshold
                    && !mLaunchedAssistant
                    && !mLaunchedAssistant
                    && mState != STATE_DELEGATE_ACTIVE) {
                    && mState != STATE_DELEGATE_ACTIVE) {
+5 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED;


import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;
import static com.android.systemui.shared.system.PackageManagerWrapper.ACTION_PREFERRED_ACTIVITY_CHANGED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED;


import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ComponentName;
@@ -104,6 +105,10 @@ public final class OverviewComponentObserver {
        updateOverviewTargets();
        updateOverviewTargets();
    }
    }


    public boolean assistantGestureIsConstrained() {
        return (mDeviceState.getSystemUiStateFlags() & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
    }

    /**
    /**
     * Update overview intent and {@link BaseActivityInterface} based off the current launcher home
     * Update overview intent and {@link BaseActivityInterface} based off the current launcher home
     * component.
     * component.