From b117707d3159e41419357287c2bcb13eebc5977a Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 18 Apr 2019 09:32:49 -0700 Subject: [PATCH] Tune Assistant Gesture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit => bumping detectable region to 48 dp horizontal + vertical within corner => centering detectable angle; total 70 degrees (ie. btw 10 off the vertical and 10 off the horizontal) => pilfering touch events when slop is passed and assistant gesture is engaged => Fixing issue where we were incorrectly using “sharedState” causing incorrect handling of gestures subsequent to AssistantTouchConsumer being invoked (it was forgetting to clear it’s input state and hence reporting “active” when it wasn’t). The symptom was that gestures after the AssistantTouchConsumer would never actually move the active window even though state was being updated; you’d feel the Overview haptic. => Devices with large corner radii are still somewhat problematic as the initial touch down often lands high on the display (ie. above the 48 dp region). Change-Id: I3d5761112f4cb8b7b1eee987de5afe9aee260304 --- .../android/quickstep/AssistantTouchConsumer.java | 15 +++++++++++++-- .../quickstep/OtherActivityInputConsumer.java | 1 + .../quickstep/TouchInteractionService.java | 2 +- quickstep/res/values/config.xml | 2 +- quickstep/res/values/dimens.xml | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java index 7c0791e801..e8651377fa 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java @@ -41,6 +41,7 @@ import com.android.launcher3.logging.UserEventDispatcher; import com.android.quickstep.util.MotionPauseDetector; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.launcher3.R; +import com.android.systemui.shared.system.InputMonitorCompat; import com.android.systemui.shared.system.NavigationBarCompat; /** @@ -83,8 +84,11 @@ public class AssistantTouchConsumer implements InputConsumer { private final InputConsumer mConsumerDelegate; private final Context mContext; + private final InputMonitorCompat mInputMonitorCompat; + + public AssistantTouchConsumer(Context context, ISystemUiProxy systemUiProxy, - InputConsumer delegate) { + InputConsumer delegate, InputMonitorCompat inputMonitorCompat) { final Resources res = context.getResources(); mContext = context; mSysUiProxy = systemUiProxy; @@ -94,6 +98,7 @@ public class AssistantTouchConsumer implements InputConsumer { mTimeThreshold = res.getInteger(R.integer.assistant_gesture_min_time_threshold); mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold); mSlop = NavigationBarCompat.getQuickScrubTouchSlopPx(); + mInputMonitorCompat = inputMonitorCompat; mState = STATE_INACTIVE; } @@ -153,6 +158,10 @@ public class AssistantTouchConsumer implements InputConsumer { if (!mPassedSlop) { // Normal gesture, ensure we pass the slop before we start tracking the gesture if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) > mSlop) { + + // Cancel touches to other windows (intercept) + mInputMonitorCompat.pilferPointers(); + mPassedSlop = true; mStartDragPos.set(mLastPos.x, mLastPos.y); mDragTime = SystemClock.uptimeMillis(); @@ -162,7 +171,8 @@ public class AssistantTouchConsumer implements InputConsumer { Math.atan2(mDownPos.y - mLastPos.y, mDownPos.x - mLastPos.x)); mDirection = angle > 90 ? UPLEFT : UPRIGHT; angle = angle > 90 ? 180 - angle : angle; - if (angle > mAngleThreshold) { + + if (angle > mAngleThreshold && angle < 90 - mAngleThreshold) { mState = STATE_ASSISTANT_ACTIVE; if (mConsumerDelegate != null) { @@ -209,6 +219,7 @@ public class AssistantTouchConsumer implements InputConsumer { animator.setInterpolator(Interpolators.DEACCEL_2); animator.start(); } + mState = STATE_INACTIVE; mMotionPauseDetector.clear(); break; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java index 990bcff51e..9c8e80e5c3 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java @@ -149,6 +149,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mDragSlop = NavigationBarCompat.getQuickStepDragSlopPx(); mTouchSlop = NavigationBarCompat.getQuickStepTouchSlopPx(); + mPassedTouchSlop = mPassedDragSlop = continuingPreviousGesture; } 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 6044b61e1a..95dea5044f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -461,7 +461,7 @@ public class TouchInteractionService extends Service implements && SysUINavigationMode.INSTANCE.get(this).getMode() == Mode.NO_BUTTON && AssistantTouchConsumer.withinTouchRegion(this, event)) { return new AssistantTouchConsumer(this, mISystemUiProxy, !activityControl.isResumed() - ? createOtherActivityInputConsumer(event, runningTaskInfo) : null); + ? createOtherActivityInputConsumer(event, runningTaskInfo) : null, mInputMonitorCompat); } else if (mSwipeSharedState.goingToLauncher || activityControl.isResumed()) { return OverviewInputConsumer.newInstance(activityControl, false); } else if (ENABLE_QUICKSTEP_LIVE_TILE.get() && diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml index a96669832c..e29d3df273 100644 --- a/quickstep/res/values/config.xml +++ b/quickstep/res/values/config.xml @@ -29,5 +29,5 @@ 200 - 30 + 10 diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index c5a1aca5f0..75959d1060 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -65,7 +65,7 @@ 24dp - 28dp + 48dp 70dp