Revert "Use movement on the trackpad instead of on screen for trackpad gestures used for gesture nav"
This reverts commit aef9d75f78.
Reason for revert: The movement on the screen is proportional to the movement on the trackpad for gestures since finger ballistics only applies to cursor movement
Change-Id: Idd7f948545c35988183cfac0b74c730cf699d5f9
This commit is contained in:
1 parent
daf057472c
commit
68ca43f7ad
3 files changed
+38
-175
No files matched your search
+38
-24
@@ -26,8 +26,6 @@ import static android.view.MotionEvent.INVALID_POINTER_ID;
|
||||
import static com.android.launcher3.PagedView.ACTION_MOVE_ALLOW_EASY_FLING;
|
||||
import static com.android.launcher3.PagedView.DEBUG_FAILED_QUICKSWITCH;
|
||||
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
|
||||
import static com.android.launcher3.Utilities.getXVelocity;
|
||||
import static com.android.launcher3.Utilities.getYVelocity;
|
||||
import static com.android.launcher3.Utilities.squaredHypot;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.TraceHelper.FLAG_CHECK_FOR_RACE_CONDITIONS;
|
||||
@@ -112,8 +110,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
private final FinishImmediatelyHandler mCleanupHandler = new FinishImmediatelyHandler();
|
||||
|
||||
private final boolean mIsDeferredDownTarget;
|
||||
|
||||
private final MotionEventsHandler mMotionEventsHandler;
|
||||
private final PointF mDownPos = new PointF();
|
||||
private final PointF mLastPos = new PointF();
|
||||
private int mActivePointerId = INVALID_POINTER_ID;
|
||||
|
||||
// Distance after which we start dragging the window.
|
||||
private final float mTouchSlop;
|
||||
@@ -154,7 +153,6 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
mVelocityTracker = VelocityTracker.obtain();
|
||||
mInputMonitorCompat = inputMonitorCompat;
|
||||
mInputEventReceiver = inputEventReceiver;
|
||||
mMotionEventsHandler = new MotionEventsHandler(base);
|
||||
|
||||
boolean continuingPreviousGesture = mTaskAnimationManager.isRecentsAnimationRunning();
|
||||
mIsDeferredDownTarget = !continuingPreviousGesture && isDeferredDownTarget;
|
||||
@@ -224,7 +222,9 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
|
||||
Object traceToken = TraceHelper.INSTANCE.beginSection(DOWN_EVT,
|
||||
FLAG_CHECK_FOR_RACE_CONDITIONS);
|
||||
mMotionEventsHandler.onActionDown(ev);
|
||||
mActivePointerId = ev.getPointerId(0);
|
||||
mDownPos.set(ev.getX(), ev.getY());
|
||||
mLastPos.set(mDownPos);
|
||||
|
||||
// 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
|
||||
@@ -247,20 +247,27 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
break;
|
||||
}
|
||||
case ACTION_POINTER_UP: {
|
||||
mMotionEventsHandler.onActionPointerUp(ev);
|
||||
int ptrIdx = ev.getActionIndex();
|
||||
int ptrId = ev.getPointerId(ptrIdx);
|
||||
if (ptrId == mActivePointerId) {
|
||||
final int newPointerIdx = ptrIdx == 0 ? 1 : 0;
|
||||
mDownPos.set(
|
||||
ev.getX(newPointerIdx) - (mLastPos.x - mDownPos.x),
|
||||
ev.getY(newPointerIdx) - (mLastPos.y - mDownPos.y));
|
||||
mLastPos.set(ev.getX(newPointerIdx), ev.getY(newPointerIdx));
|
||||
mActivePointerId = ev.getPointerId(newPointerIdx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ACTION_MOVE: {
|
||||
int pointerIndex = ev.findPointerIndex(mMotionEventsHandler.getActivePointerId());
|
||||
int pointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||
if (pointerIndex == INVALID_POINTER_ID) {
|
||||
break;
|
||||
}
|
||||
|
||||
mMotionEventsHandler.onActionMove(ev);
|
||||
final float displacement = mMotionEventsHandler.getDisplacement(ev,
|
||||
mNavBarPosition);
|
||||
final float displacementX = mMotionEventsHandler.getDisplacementX(ev);
|
||||
final float displacementY= mMotionEventsHandler.getDisplacementY(ev);
|
||||
mLastPos.set(ev.getX(pointerIndex), ev.getY(pointerIndex));
|
||||
float displacement = getDisplacement(ev);
|
||||
float displacementX = mLastPos.x - mDownPos.x;
|
||||
float displacementY = mLastPos.y - mDownPos.y;
|
||||
|
||||
if (!mPassedWindowMoveSlop) {
|
||||
if (!mIsDeferredDownTarget) {
|
||||
@@ -342,8 +349,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
case ACTION_CANCEL:
|
||||
case ACTION_UP: {
|
||||
if (DEBUG_FAILED_QUICKSWITCH && !mPassedWindowMoveSlop) {
|
||||
final float displacementX = mMotionEventsHandler.getDisplacementX(ev);
|
||||
final float displacementY = mMotionEventsHandler.getDisplacementY(ev);
|
||||
float displacementX = mLastPos.x - mDownPos.x;
|
||||
float displacementY = mLastPos.y - mDownPos.y;
|
||||
Log.d("Quickswitch", "mPassedWindowMoveSlop=false"
|
||||
+ " disp=" + squaredHypot(displacementX, displacementY)
|
||||
+ " slop=" + mSquaredTouchSlop);
|
||||
@@ -400,19 +407,16 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
mInteractionHandler.onGestureCancelled();
|
||||
} else {
|
||||
mVelocityTracker.computeCurrentVelocity(PX_PER_MS);
|
||||
int activePointerId = mMotionEventsHandler.getActivePointerId();
|
||||
float velocityXPxPerMs = getXVelocity(mVelocityTracker, ev, activePointerId);
|
||||
float velocityYPxPerMs = getYVelocity(mVelocityTracker, ev, activePointerId);
|
||||
float velocityXPxPerMs = mVelocityTracker.getXVelocity(mActivePointerId);
|
||||
float velocityYPxPerMs = mVelocityTracker.getYVelocity(mActivePointerId);
|
||||
float velocityPxPerMs = mNavBarPosition.isRightEdge()
|
||||
? velocityXPxPerMs
|
||||
: mNavBarPosition.isLeftEdge()
|
||||
? -velocityXPxPerMs
|
||||
: velocityYPxPerMs;
|
||||
mInteractionHandler.updateDisplacement(
|
||||
mMotionEventsHandler.getDisplacement(ev, mNavBarPosition)
|
||||
- mStartDisplacement);
|
||||
mInteractionHandler.onGestureEnded(
|
||||
velocityPxPerMs, new PointF(velocityXPxPerMs, velocityYPxPerMs));
|
||||
mInteractionHandler.updateDisplacement(getDisplacement(ev) - mStartDisplacement);
|
||||
mInteractionHandler.onGestureEnded(velocityPxPerMs,
|
||||
new PointF(velocityXPxPerMs, velocityYPxPerMs));
|
||||
}
|
||||
} else {
|
||||
// Since we start touch tracking on DOWN, we may reach this state without actually
|
||||
@@ -475,6 +479,16 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
|
||||
}
|
||||
}
|
||||
|
||||
private float getDisplacement(MotionEvent ev) {
|
||||
if (mNavBarPosition.isRightEdge()) {
|
||||
return ev.getX() - mDownPos.x;
|
||||
} else if (mNavBarPosition.isLeftEdge()) {
|
||||
return mDownPos.x - ev.getX();
|
||||
} else {
|
||||
return ev.getY() - mDownPos.y;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInterceptByParent() {
|
||||
return !mPassedPilferInputSlop;
|
||||
|
||||
Reference in new issue
Block a user