From bbea105be05649a00b4cc227d08a4da1ed87bb89 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 22 Apr 2019 20:26:12 -0700 Subject: Move logic that overrides MotionPauseDetector to callers There are 2 conditions that we force the MotionPauseDetector to treat the motion as not paused: 1. If we haven't passed a small displacement (48dp before, 36dp now) 2. If we have moved mostly orthogonally These existed soley for the OtherActivityInputConsumer case, because 1. We only need the displacement requirement to make room for the peeking shelf, which doesn't exist in other cases (it's already there on home for example) 2. We can only move orthogonally for quick switch, which again doesn't exist for other users of MotionPauseDetector. So now instead of checking min displacement and orthogonal distance inside MotionPauseDetector, we let callers setDisallowPause() before adding positions to their MotionPauseDetector. The only user visible change is that you no longer have to swipe up 48dp before we allow pause to overview from home. This also paves the way to using the same logic that determines to disallowPause to also detach recents from the window while swiping up from an app. Bug: 129985827 Change-Id: Ie690aa314da3260aff2209341a29638604f9501c --- .../quickstep/OtherActivityInputConsumer.java | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java') 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 03af92dc3..78cc166f9 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java @@ -21,9 +21,9 @@ import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.INVALID_POINTER_ID; +import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.util.RaceConditionTracker.ENTER; import static com.android.launcher3.util.RaceConditionTracker.EXIT; -import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; @@ -45,6 +45,9 @@ import android.view.VelocityTracker; import android.view.ViewConfiguration; import android.view.WindowManager; +import androidx.annotation.UiThread; + +import com.android.launcher3.R; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.RaceConditionTracker; import com.android.launcher3.util.TraceHelper; @@ -62,8 +65,6 @@ import com.android.systemui.shared.system.WindowManagerWrapper; import java.util.function.Consumer; -import androidx.annotation.UiThread; - /** * Input consumer for handling events originating from an activity other than Launcher */ @@ -90,6 +91,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private final Consumer mOnCompleteCallback; private final MotionPauseDetector mMotionPauseDetector; + private final float mMotionPauseMinDisplacement; private VelocityTracker mVelocityTracker; private WindowTransformSwipeHandler mInteractionHandler; @@ -107,8 +109,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC // Slop used to determine when we say that the gesture has started. private boolean mPassedTouchSlop; - // TODO: Start displacement should have both x and y + // Might be displacement in X or Y, depending on the direction we are swiping from the nav bar. private float mStartDisplacement; + private float mStartDisplacementX; private Handler mMainThreadHandler; private Runnable mCancelRecentsAnimationRunnable = () -> { @@ -131,6 +134,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mMode = SysUINavigationMode.getMode(base); mMotionPauseDetector = new MotionPauseDetector(base); + mMotionPauseMinDisplacement = base.getResources().getDimension( + R.dimen.motion_pause_detector_min_displacement_from_app); mOnCompleteCallback = onCompleteCallback; mVelocityTracker = VelocityTracker.obtain(); mInputMonitorCompat = inputMonitorCompat; @@ -219,6 +224,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex)); float displacement = getDisplacement(ev); + float displacementX = mLastPos.x - mDownPos.x; if (!mPassedDragSlop) { if (!mIsDeferredDownTarget) { @@ -227,13 +233,13 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC if (Math.abs(displacement) > mDragSlop) { mPassedDragSlop = true; mStartDisplacement = displacement; + mStartDisplacementX = displacementX; } } } if (!mPassedTouchSlop) { - if (Math.hypot(mLastPos.x - mDownPos.x, mLastPos.y - mDownPos.y) >= - mTouchSlop) { + if (Math.hypot(displacementX, mLastPos.y - mDownPos.y) >= mTouchSlop) { mPassedTouchSlop = true; if (mIsDeferredDownTarget) { @@ -244,6 +250,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC if (!mPassedDragSlop) { mPassedDragSlop = true; mStartDisplacement = displacement; + mStartDisplacementX = displacementX; } notifyGestureStarted(); } @@ -254,12 +261,12 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC mInteractionHandler.updateDisplacement(displacement - mStartDisplacement); if (mMode == Mode.NO_BUTTON) { - boolean isLandscape = isNavBarOnLeft() || isNavBarOnRight(); - float orthogonalDisplacement = !isLandscape - ? ev.getX() - mDownPos.x - : ev.getY() - mDownPos.y; - mMotionPauseDetector.addPosition(displacement, orthogonalDisplacement, - ev.getEventTime()); + float horizontalDist = Math.abs(displacementX - mStartDisplacementX); + float upDist = -(displacement - mStartDisplacement); + boolean isLikelyToStartNewTask = horizontalDist > upDist; + mMotionPauseDetector.setDisallowPause(upDist < mMotionPauseMinDisplacement + || isLikelyToStartNewTask); + mMotionPauseDetector.addPosition(displacement, ev.getEventTime()); } } break; -- cgit v1.2.3