summaryrefslogtreecommitdiffstats
path: root/quickstep/recents_ui_overrides
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2019-06-20 15:17:13 -0700
committerSunny Goyal <sunnygoyal@google.com>2019-06-21 15:08:49 -0700
commite9f1f093c71b112608d8b7ade5be00ba94c07923 (patch)
tree31d8b12eb8f9d335669f9ef9adca662177f4ed48 /quickstep/recents_ui_overrides
parent37dc5b193673f7b8b4e381f87730b219eb143c95 (diff)
downloadandroid_packages_apps_Trebuchet-e9f1f093c71b112608d8b7ade5be00ba94c07923.tar.gz
android_packages_apps_Trebuchet-e9f1f093c71b112608d8b7ade5be00ba94c07923.tar.bz2
android_packages_apps_Trebuchet-e9f1f093c71b112608d8b7ade5be00ba94c07923.zip
Increasing assistant touch region based on the corner radius
Bug: 135687556 Change-Id: I86f0cf3b0e6f3cd6608eab55be6ebf56bfdddf1c
Diffstat (limited to 'quickstep/recents_ui_overrides')
-rw-r--r--quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java45
-rw-r--r--quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java11
2 files changed, 39 insertions, 17 deletions
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 769d207ab..22ebe6140 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -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);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
index 8f92772e8..38b5a137c 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
@@ -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) {