Merge "Disabling fling gesture for assistant over deferred region"
This commit is contained in:
commit
c2d0989c82
|
@ -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.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY;
|
||||||
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;
|
||||||
|
@ -119,10 +118,6 @@ 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.
|
||||||
|
|
|
@ -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.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_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_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_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_GLOBAL_ACTIONS_SHOWING;
|
||||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
|
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.
|
* @return the system ui state flags.
|
||||||
*/
|
*/
|
||||||
// TODO(141886704): See if we can remove this
|
// TODO(141886704): See if we can remove this
|
||||||
public @SystemUiStateFlags int getSystemUiStateFlags() {
|
public int getSystemUiStateFlags() {
|
||||||
return mSystemUiStateFlags;
|
return mSystemUiStateFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,6 +406,13 @@ public class RecentsAnimationDeviceState implements
|
||||||
return (mSystemUiStateFlags & SYSUI_STATE_SCREEN_PINNING) != 0;
|
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
|
* @return whether the bubble stack is expanded
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -466,7 +466,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||||
this,
|
this,
|
||||||
mGestureState,
|
mGestureState,
|
||||||
InputConsumer.NO_OP, mInputMonitorCompat,
|
InputConsumer.NO_OP, mInputMonitorCompat,
|
||||||
mOverviewComponentObserver.assistantGestureIsConstrained());
|
mDeviceState,
|
||||||
|
event);
|
||||||
} else if (mDeviceState.canTriggerOneHandedAction(event)
|
} else if (mDeviceState.canTriggerOneHandedAction(event)
|
||||||
&& !mDeviceState.isOneHandedModeActive()) {
|
&& !mDeviceState.isOneHandedModeActive()) {
|
||||||
// Consume gesture event for triggering one handed feature.
|
// 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.isFullyGesturalNavMode()) {
|
||||||
if (mDeviceState.canTriggerAssistantAction(event, newGestureState.getRunningTask())) {
|
if (mDeviceState.canTriggerAssistantAction(event, newGestureState.getRunningTask())) {
|
||||||
base = new AssistantInputConsumer(
|
base = new AssistantInputConsumer(this, newGestureState, base, mInputMonitorCompat,
|
||||||
this,
|
mDeviceState, event);
|
||||||
newGestureState,
|
|
||||||
base,
|
|
||||||
mInputMonitorCompat,
|
|
||||||
mOverviewComponentObserver.assistantGestureIsConstrained());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
|
if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) {
|
||||||
|
|
|
@ -44,9 +44,12 @@ import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.quickstep.BaseActivityInterface;
|
import com.android.quickstep.BaseActivityInterface;
|
||||||
import com.android.quickstep.GestureState;
|
import com.android.quickstep.GestureState;
|
||||||
import com.android.quickstep.InputConsumer;
|
import com.android.quickstep.InputConsumer;
|
||||||
|
import com.android.quickstep.RecentsAnimationDeviceState;
|
||||||
import com.android.quickstep.SystemUiProxy;
|
import com.android.quickstep.SystemUiProxy;
|
||||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Touch consumer for handling events to launch assistant from launcher
|
* 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 int mAngleThreshold;
|
||||||
private final float mSquaredSlop;
|
private final float mSquaredSlop;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final GestureDetector mGestureDetector;
|
private final Consumer<MotionEvent> mGestureDetector;
|
||||||
private final boolean mIsAssistGestureConstrained;
|
|
||||||
|
|
||||||
public AssistantInputConsumer(
|
public AssistantInputConsumer(
|
||||||
Context context,
|
Context context,
|
||||||
GestureState gestureState,
|
GestureState gestureState,
|
||||||
InputConsumer delegate,
|
InputConsumer delegate,
|
||||||
InputMonitorCompat inputMonitor,
|
InputMonitorCompat inputMonitor,
|
||||||
boolean isAssistGestureConstrained) {
|
RecentsAnimationDeviceState deviceState,
|
||||||
|
MotionEvent startEvent) {
|
||||||
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);
|
||||||
|
@ -104,7 +106,11 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
|
||||||
mSquaredSlop = slop * slop;
|
mSquaredSlop = slop * slop;
|
||||||
mActivityInterface = gestureState.getActivityInterface();
|
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
|
@Override
|
||||||
|
@ -201,7 +207,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGestureDetector.onTouchEvent(ev);
|
mGestureDetector.accept(ev);
|
||||||
|
|
||||||
if (mState != STATE_ACTIVE) {
|
if (mState != STATE_ACTIVE) {
|
||||||
mDelegate.onMotionEvent(ev);
|
mDelegate.onMotionEvent(ev);
|
||||||
|
@ -214,12 +220,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
|
||||||
if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) {
|
if (mDistance >= mDragDistThreshold && mTimeFraction >= 1) {
|
||||||
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0);
|
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(0);
|
||||||
startAssistantInternal();
|
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 {
|
} else {
|
||||||
SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress);
|
SystemUiProxy.INSTANCE.get(mContext).onAssistantProgress(mLastProgress);
|
||||||
}
|
}
|
||||||
|
@ -233,6 +233,12 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
|
||||||
13, // HapticFeedbackConstants.GESTURE_END
|
13, // HapticFeedbackConstants.GESTURE_END
|
||||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
|
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 {
|
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 (!mIsAssistGestureConstrained
|
if (isValidAssistantGestureAngle(velocityX, -velocityY)
|
||||||
&& isValidAssistantGestureAngle(velocityX, -velocityY)
|
|
||||||
&& mDistance >= mFlingDistThreshold
|
&& mDistance >= mFlingDistThreshold
|
||||||
&& !mLaunchedAssistant
|
&& !mLaunchedAssistant
|
||||||
&& mState != STATE_DELEGATE_ACTIVE) {
|
&& mState != STATE_DELEGATE_ACTIVE) {
|
||||||
|
@ -259,11 +264,6 @@ public class AssistantInputConsumer extends DelegateInputConsumer {
|
||||||
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(
|
SystemUiProxy.INSTANCE.get(mContext).onAssistantGestureCompletion(
|
||||||
(float) Math.sqrt(velocityX * velocityX + velocityY * velocityY));
|
(float) Math.sqrt(velocityX * velocityX + velocityY * velocityY));
|
||||||
startAssistantInternal();
|
startAssistantInternal();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
|
|
||||||
SystemUiProxy.INSTANCE.get(mContext).startAssistant(args);
|
|
||||||
mLaunchedAssistant = true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue