diff options
author | Matthew Ng <ngmatthew@google.com> | 2018-03-30 17:09:06 -0700 |
---|---|---|
committer | Matthew Ng <ngmatthew@google.com> | 2018-04-02 10:59:00 -0700 |
commit | e1a9c7ed3f08ad0cc93016928260e7690dcdc32d (patch) | |
tree | d16c9d7aa2c2cff847d1ce4117500d12df06a2e1 | |
parent | 415a1402d5894f6b9455267c88bdcbc0f0ab8174 (diff) | |
download | android_packages_apps_Trebuchet-e1a9c7ed3f08ad0cc93016928260e7690dcdc32d.tar.gz android_packages_apps_Trebuchet-e1a9c7ed3f08ad0cc93016928260e7690dcdc32d.tar.bz2 android_packages_apps_Trebuchet-e1a9c7ed3f08ad0cc93016928260e7690dcdc32d.zip |
Added two touch slops for easier home press (3/3)
The first slop starts the drag either for quick step or scrub. At this
point either launcher can animate swipe up or the home button moves for
scrub, however the home button is still active and can be pressed or
long pressed. The second slop is for activating quick step or scrub.
Similar to before when an operation has activated, the home button
cannot be pressed or long pressed. This allows the home button to have a
larger area to be clicked.
Change-Id: Ie792845a09ecf5d8bdbeae9e8ef7210e2299c69d
Fixes: 76430825
Test: scrub or swipe up
-rw-r--r-- | quickstep/libs/sysui_shared.jar | bin | 118578 -> 119143 bytes | |||
-rw-r--r-- | quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java | 46 |
2 files changed, 25 insertions, 21 deletions
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar Binary files differindex e414fa033..2b9db35bc 100644 --- a/quickstep/libs/sysui_shared.jar +++ b/quickstep/libs/sysui_shared.jar diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java index bcc986d5e..4bd4a11b2 100644 --- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java @@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.INVALID_POINTER_ID; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_OVERVIEW; +import static com.android.systemui.shared.system.NavigationBarCompat.QUICK_STEP_DRAG_SLOP_PX; import android.annotation.TargetApi; import android.app.ActivityManager.RunningTaskInfo; @@ -79,8 +80,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC private final PointF mDownPos = new PointF(); private final PointF mLastPos = new PointF(); private int mActivePointerId = INVALID_POINTER_ID; - private boolean mGestureStarted; - private int mTouchSlop; + private boolean mPassedInitialSlop; private float mStartDisplacement; private WindowTransformSwipeHandler mInteractionHandler; private int mDisplayRotation; @@ -121,8 +121,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC mActivePointerId = ev.getPointerId(0); mDownPos.set(ev.getX(), ev.getY()); mLastPos.set(mDownPos); - mTouchSlop = ViewConfiguration.get(this).getScaledPagingTouchSlop(); - mGestureStarted = false; + mPassedInitialSlop = false; // Start the window animation on down to give more time for launcher to draw if the // user didn't start the gesture over the back button @@ -154,11 +153,20 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC break; } mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex)); + float displacement = getDisplacement(ev); + if (!mPassedInitialSlop && Math.abs(displacement) > QUICK_STEP_DRAG_SLOP_PX) { + mPassedInitialSlop = true; + mStartDisplacement = displacement; + + // If we deferred starting the window animation on touch down, then + // start tracking now + if (mIsDeferredDownTarget) { + startTouchTrackingForWindowAnimation(ev.getEventTime()); + } + } - if (mGestureStarted && mInteractionHandler != null) { + if (mPassedInitialSlop && mInteractionHandler != null) { // Move - float displacement = getDisplacement(ev.getX(pointerIndex), - ev.getY(pointerIndex)); mInteractionHandler.updateDisplacement(displacement - mStartDisplacement); } break; @@ -179,7 +187,6 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC return; } // Notify the handler that the gesture has actually started - mGestureStarted = true; mInteractionHandler.onGestureStarted(); } @@ -244,10 +251,12 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC if (Looper.myLooper() != Looper.getMainLooper()) { startActivity.run(); - try { - drawWaitLock.await(LAUNCHER_DRAW_TIMEOUT_MS, TimeUnit.MILLISECONDS); - } catch (Exception e) { - // We have waited long enough for launcher to draw + if (!mIsDeferredDownTarget) { + try { + drawWaitLock.await(LAUNCHER_DRAW_TIMEOUT_MS, TimeUnit.MILLISECONDS); + } catch (Exception e) { + // We have waited long enough for launcher to draw + } } } else { // We should almost always get touch-town on background thread. This is an edge case @@ -261,7 +270,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC * the animation can still be running. */ private void finishTouchTracking() { - if (mGestureStarted && mInteractionHandler != null) { + if (mPassedInitialSlop && mInteractionHandler != null) { mVelocityTracker.computeCurrentVelocity(1000, ViewConfiguration.get(this).getScaledMaximumFlingVelocity()); @@ -323,17 +332,12 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC @Override public void onQuickStep(float eventX, float eventY, long eventTime) { - float displacement = getDisplacement(eventX, eventY); - mStartDisplacement = Math.signum(displacement) * mTouchSlop; - if (mIsDeferredDownTarget) { - // If we deferred starting the window animation on touch down, then - // start tracking now - startTouchTrackingForWindowAnimation(eventTime); - } notifyGestureStarted(); } - private float getDisplacement(float eventX, float eventY) { + private float getDisplacement(MotionEvent ev) { + float eventX = ev.getX(); + float eventY = ev.getY(); float displacement = eventY - mDownPos.y; if (isNavBarOnRight()) { displacement = eventX - mDownPos.x; |