Adds fling gesture suppression to Launcher

Test: Tested locally
BUG: 150688842
Change-Id: Ifa96bd01363de47cf1d8cdce34d81d525c8c2c04
This commit is contained in:
Govinda Wasserman
2020-03-05 16:50:22 -05:00
parent f85fcc792f
commit fb4fe0e972
3 changed files with 26 additions and 6 deletions
@@ -466,8 +466,11 @@ public class TouchInteractionService extends Service implements PluginListener<O
// 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
// next gesture is also quick switch.
mUncheckedConsumer = new AssistantInputConsumer(this, newGestureState,
InputConsumer.NO_OP, mInputMonitorCompat);
mUncheckedConsumer = new AssistantInputConsumer(
this,
newGestureState,
InputConsumer.NO_OP, mInputMonitorCompat,
mOverviewComponentObserver.assistantGestureIsConstrained());
} else {
mUncheckedConsumer = InputConsumer.NO_OP;
}
@@ -507,7 +510,12 @@ public class TouchInteractionService extends Service implements PluginListener<O
}
if (mDeviceState.isFullyGesturalNavMode()) {
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()) {
@@ -90,12 +90,18 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
private final float mSquaredSlop;
private final Context mContext;
private final GestureDetector mGestureDetector;
private final boolean mIsAssistGestureConstrained;
public AssistantInputConsumer(Context context, GestureState gestureState,
InputConsumer delegate, InputMonitorCompat inputMonitor) {
public AssistantInputConsumer(
Context context,
GestureState gestureState,
InputConsumer delegate,
InputMonitorCompat inputMonitor,
boolean isAssistGestureConstrained) {
super(delegate, inputMonitor);
final Resources res = context.getResources();
mContext = context;
mIsAssistGestureConstrained = isAssistGestureConstrained;
mDragDistThreshold = res.getDimension(R.dimen.gestures_assistant_drag_threshold);
mFlingDistThreshold = res.getDimension(R.dimen.gestures_assistant_fling_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 {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (isValidAssistantGestureAngle(velocityX, -velocityY)
if (!mIsAssistGestureConstrained
&& isValidAssistantGestureAngle(velocityX, -velocityY)
&& mDistance >= mFlingDistThreshold
&& !mLaunchedAssistant
&& mState != STATE_DELEGATE_ACTIVE) {
@@ -22,6 +22,7 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED;
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.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -104,6 +105,10 @@ public final class OverviewComponentObserver {
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
* component.