Merge "Disabling fling gesture for assistant over deferred region"

This commit is contained in:
TreeHugger Robot 2021-01-11 21:36:52 +00:00 committed by Android (Google) Code Review
commit c2d0989c82
4 changed files with 32 additions and 32 deletions

View File

@ -23,7 +23,6 @@ import static android.content.Intent.ACTION_PACKAGE_REMOVED;
import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
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;
@ -119,10 +118,6 @@ 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.

View File

@ -23,6 +23,7 @@ import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.SysUINavigationMode.Mode.THREE_BUTTONS;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BUBBLES_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
@ -373,7 +374,7 @@ public class RecentsAnimationDeviceState implements
* @return the system ui state flags.
*/
// TODO(141886704): See if we can remove this
public @SystemUiStateFlags int getSystemUiStateFlags() {
public int getSystemUiStateFlags() {
return mSystemUiStateFlags;
}
@ -405,6 +406,13 @@ public class RecentsAnimationDeviceState implements
return (mSystemUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0;
}
/**
* @return whether assistant gesture is constraint
*/
public boolean isAssistantGestureIsConstrained() {
return (mSystemUiStateFlags & SYSUI_STATE_ASSIST_GESTURE_CONSTRAINED) != 0;
}
/**
* @return whether the bubble stack is expanded
*/

View File

@ -466,7 +466,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
this,
mGestureState,
InputConsumer.NO_OP, mInputMonitorCompat,
mOverviewComponentObserver.assistantGestureIsConstrained());
mDeviceState,
event);
} else if (mDeviceState.canTriggerOneHandedAction(event)
&& !mDeviceState.isOneHandedModeActive()) {
// Consume gesture event for triggering one handed feature.
@ -563,12 +564,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
}
if (mDeviceState.isFullyGesturalNavMode()) {
if (mDeviceState.canTriggerAssistantAction(event, newGestureState.getRunningTask())) {
base = new AssistantInputConsumer(
this,
newGestureState,
base,
mInputMonitorCompat,
mOverviewComponentObserver.assistantGestureIsConstrained());
base = new AssistantInputConsumer(this, newGestureState, base, mInputMonitorCompat,
mDeviceState, event);
}
if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {

View File

@ -44,9 +44,12 @@ import com.android.launcher3.anim.Interpolators;
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.InputConsumer;
import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.SystemUiProxy;
import com.android.systemui.shared.system.InputMonitorCompat;
import java.util.function.Consumer;
/**
* Touch consumer for handling events to launch assistant from launcher
*/
@ -81,19 +84,18 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
private final int mAngleThreshold;
private final float mSquaredSlop;
private final Context mContext;
private final GestureDetector mGestureDetector;
private final boolean mIsAssistGestureConstrained;
private final Consumer<MotionEvent> mGestureDetector;
public AssistantInputConsumer(
Context context,
GestureState gestureState,
InputConsumer delegate,
InputMonitorCompat inputMonitor,
boolean isAssistGestureConstrained) {
RecentsAnimationDeviceState deviceState,
MotionEvent startEvent) {
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);
@ -104,7 +106,11 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
mSquaredSlop = slop * slop;
mActivityInterface = gestureState.getActivityInterface();
mGestureDetector = new GestureDetector(context, new AssistantGestureListener());
boolean flingDisabled = deviceState.isAssistantGestureIsConstrained()
|| deviceState.isInDeferredGestureRegion(startEvent);
mGestureDetector = flingDisabled
? ev -> { }
: new GestureDetector(context, new AssistantGestureListener())::onTouchEvent;
}
@Override
@ -201,7 +207,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
break;
}
mGestureDetector.onTouchEvent(ev);
mGestureDetector.accept(ev);
if (mState != STATE_ACTIVE) {
mDelegate.onMotionEvent(ev);
@ -214,12 +220,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) {
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0);
startAssistantInternal();
Bundle args = new Bundle();
args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
mLaunchedAssistant = true;
} else {
SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress);
}
@ -233,6 +233,12 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
13, // HapticFeedbackConstants.GESTURE_END
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
Bundle args = new Bundle();
args.putInt(OPA_BUNDLE_TRIGGER, OPA_BUNDLE_TRIGGER_DIAG_SWIPE_GESTURE);
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
mLaunchedAssistant = true;
}
/**
@ -250,8 +256,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
private class AssistantGestureListener extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (!mIsAssistGestureConstrained
&& isValidAssistantGestureAngle(velocityX, -velocityY)
if (isValidAssistantGestureAngle(velocityX, -velocityY)
&& mDistance >= mFlingDistThreshold
&& !mLaunchedAssistant
&& mState != STATE_DELEGATE_ACTIVE) {
@ -259,11 +264,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(
(float) Math.sqrt(velocityX * velocityX + velocityY * velocityY));
startAssistantInternal();
Bundle args = new Bundle();
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
mLaunchedAssistant = true;
}
return true;
}