Merge "Increasing assistant touch region based on the corner radius" into ub-launcher3-qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0348bc21ab
+39
-6
@@ -267,6 +267,9 @@ public class TouchInteractionService extends Service implements
|
||||
private Mode mMode = Mode.THREE_BUTTONS;
|
||||
private int mDefaultDisplayId;
|
||||
private final RectF mSwipeTouchRegion = new RectF();
|
||||
private final RectF mAssistantLeftRegion = new RectF();
|
||||
private final RectF mAssistantRightRegion = new RectF();
|
||||
|
||||
private ComponentName mGestureBlockingActivity;
|
||||
|
||||
private Region mExclusionRegion;
|
||||
@@ -349,9 +352,25 @@ public class TouchInteractionService extends Service implements
|
||||
defaultDisplay.getRealSize(realSize);
|
||||
mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
|
||||
if (mMode == Mode.NO_BUTTON) {
|
||||
mSwipeTouchRegion.top = mSwipeTouchRegion.bottom -
|
||||
getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
|
||||
int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
|
||||
mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - touchHeight;
|
||||
|
||||
final int assistantWidth = getResources()
|
||||
.getDimensionPixelSize(R.dimen.gestures_assistant_width);
|
||||
final float assistantHeight = Math.max(touchHeight,
|
||||
QuickStepContract.getWindowCornerRadius(getResources()));
|
||||
mAssistantLeftRegion.bottom = mAssistantRightRegion.bottom = mSwipeTouchRegion.bottom;
|
||||
mAssistantLeftRegion.top = mAssistantRightRegion.top =
|
||||
mSwipeTouchRegion.bottom - assistantHeight;
|
||||
|
||||
mAssistantLeftRegion.left = 0;
|
||||
mAssistantLeftRegion.right = assistantWidth;
|
||||
|
||||
mAssistantRightRegion.right = mSwipeTouchRegion.right;
|
||||
mAssistantRightRegion.left = mSwipeTouchRegion.right - assistantWidth;
|
||||
} else {
|
||||
mAssistantLeftRegion.setEmpty();
|
||||
mAssistantRightRegion.setEmpty();
|
||||
switch (defaultDisplay.getRotation()) {
|
||||
case Surface.ROTATION_90:
|
||||
mSwipeTouchRegion.left = mSwipeTouchRegion.right
|
||||
@@ -491,6 +510,15 @@ public class TouchInteractionService extends Service implements
|
||||
mConsumer = newConsumer(useSharedState, event);
|
||||
TOUCH_INTERACTION_LOG.addLog("setInputConsumer", mConsumer.getType());
|
||||
mUncheckedConsumer = mConsumer;
|
||||
} else if (mIsUserUnlocked && mMode == Mode.NO_BUTTON
|
||||
&& canTriggerAssistantAction(event)) {
|
||||
// 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 AssistantTouchConsumer(this, mISystemUiProxy,
|
||||
mOverviewComponentObserver.getActivityControlHelper(),
|
||||
InputConsumer.NO_OP, mInputMonitorCompat);
|
||||
} else {
|
||||
mUncheckedConsumer = InputConsumer.NO_OP;
|
||||
}
|
||||
@@ -505,6 +533,14 @@ public class TouchInteractionService extends Service implements
|
||||
|| (mSystemUiStateFlags & SYSUI_STATE_OVERVIEW_DISABLED) == 0);
|
||||
}
|
||||
|
||||
private boolean canTriggerAssistantAction(MotionEvent ev) {
|
||||
return mAssistantAvailable
|
||||
&& !QuickStepContract.isAssistantGestureDisabled(mSystemUiStateFlags)
|
||||
&& (mAssistantLeftRegion.contains(ev.getX(), ev.getY()) ||
|
||||
mAssistantRightRegion.contains(ev.getX(), ev.getY()))
|
||||
&& !ActivityManagerWrapper.getInstance().isLockToAppActive();
|
||||
}
|
||||
|
||||
private InputConsumer newConsumer(boolean useSharedState, MotionEvent event) {
|
||||
boolean isInValidSystemUiState = validSystemUiFlags();
|
||||
|
||||
@@ -525,10 +561,7 @@ public class TouchInteractionService extends Service implements
|
||||
if (mMode == Mode.NO_BUTTON) {
|
||||
final ActivityControlHelper activityControl =
|
||||
mOverviewComponentObserver.getActivityControlHelper();
|
||||
if (mAssistantAvailable
|
||||
&& !QuickStepContract.isAssistantGestureDisabled(mSystemUiStateFlags)
|
||||
&& AssistantTouchConsumer.withinTouchRegion(this, event)
|
||||
&& !ActivityManagerWrapper.getInstance().isLockToAppActive()) {
|
||||
if (canTriggerAssistantAction(event)) {
|
||||
base = new AssistantTouchConsumer(this, mISystemUiProxy, activityControl, base,
|
||||
mInputMonitorCompat);
|
||||
}
|
||||
|
||||
-11
@@ -34,7 +34,6 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerTyp
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.gesture.Gesture;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
@@ -50,11 +49,9 @@ import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.touch.SwipeDetector;
|
||||
import com.android.quickstep.ActivityControlHelper;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
/**
|
||||
* Touch consumer for handling events to launch assistant from launcher
|
||||
@@ -270,14 +267,6 @@ public class AssistantTouchConsumer extends DelegateInputConsumer {
|
||||
return (angle > mAngleThreshold && angle < 90);
|
||||
}
|
||||
|
||||
public static boolean withinTouchRegion(Context context, MotionEvent ev) {
|
||||
final Resources res = context.getResources();
|
||||
final int width = res.getDisplayMetrics().widthPixels;
|
||||
final int height = res.getDisplayMetrics().heightPixels;
|
||||
final int size = res.getDimensionPixelSize(R.dimen.gestures_assistant_size);
|
||||
return (ev.getX() > width - size || ev.getX() < size) && ev.getY() > height - size;
|
||||
}
|
||||
|
||||
private class AssistantGestureListener extends SimpleOnGestureListener {
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
|
||||
@@ -66,7 +66,8 @@
|
||||
<dimen name="shelf_surface_offset">24dp</dimen>
|
||||
|
||||
<!-- Assistant Gestures -->
|
||||
<dimen name="gestures_assistant_size">48dp</dimen>
|
||||
<!-- Distance from the vertical edges of the screen in which assist gestures are recognized -->
|
||||
<dimen name="gestures_assistant_width">48dp</dimen>
|
||||
<dimen name="gestures_assistant_drag_threshold">55dp</dimen>
|
||||
|
||||
<!-- Distance to move elements when swiping up to go home from launcher -->
|
||||
|
||||
Reference in New Issue
Block a user