summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2017-07-07 14:49:49 -0700
committer Winson Chung <winsonc@google.com> 2017-07-07 17:05:16 -0700
commit8ec0e16dbed3ea132ffc09a395eb6f617ccb663c (patch)
tree7f9405ea01af4f020bc0fbe6825a5da711509e17
parente7e2f36a479538c821a94646803e867733ad00c6 (diff)
Fix issue with PiP touch drift.
- Fix issue with cumulative truncation of positions causing a large x/y error causing drift. Instead of using the rounded stack position, keep track of the cumulative delta and apply that on each move. Bug: 62541932 Test: Pip activity, move around with finger and ensure no drift Change-Id: Ic7737a6b19672ee8a1d98fd57f84a1d89f4a17e9
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java2
2 files changed, 19 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 9588b03b53bd..278fdc3a6ded 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -30,6 +30,7 @@ import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Log;
@@ -401,7 +402,7 @@ public class PipTouchHandler {
/**
* Updates the appearance of the menu and scrim on top of the PiP while dismissing.
*/
- void updateDismissFraction() {
+ private void updateDismissFraction() {
if (mMenuController != null) {
Rect bounds = mMotionHelper.getBounds();
final float target = mMovementBounds.bottom + bounds.height();
@@ -427,7 +428,7 @@ public class PipTouchHandler {
/**
* Sets the minimized state.
*/
- void setMinimizedStateInternal(boolean isMinimized) {
+ private void setMinimizedStateInternal(boolean isMinimized) {
if (!ENABLE_MINIMIZE) {
return;
}
@@ -466,7 +467,7 @@ public class PipTouchHandler {
/**
* Sets the menu visibility.
*/
- void setMenuState(int menuState, boolean resize) {
+ private void setMenuState(int menuState, boolean resize) {
if (menuState == MENU_STATE_FULL) {
// Save the current snap fraction and if we do not drag or move the PiP, then
// we store back to this snap fraction. Otherwise, we'll reset the snap
@@ -534,7 +535,8 @@ public class PipTouchHandler {
private PipTouchGesture mDefaultMovementGesture = new PipTouchGesture() {
// Whether the PiP was on the left side of the screen at the start of the gesture
private boolean mStartedOnLeft;
- private Point mStartPosition;
+ private final Point mStartPosition = new Point();
+ private final PointF mDelta = new PointF();
@Override
public void onDown(PipTouchState touchState) {
@@ -543,7 +545,8 @@ public class PipTouchHandler {
}
Rect bounds = mMotionHelper.getBounds();
- mStartPosition = new Point(bounds.left, bounds.top);
+ mDelta.set(0f, 0f);
+ mStartPosition.set(bounds.left, bounds.top);
mStartedOnLeft = bounds.left < mMovementBounds.centerX();
mMovementWithinMinimize = true;
mMovementWithinDismiss = touchState.getDownTouchPosition().y >= mMovementBounds.bottom;
@@ -577,10 +580,11 @@ public class PipTouchHandler {
if (touchState.isDragging()) {
// Move the pinned stack freely
- mTmpBounds.set(mMotionHelper.getBounds());
final PointF lastDelta = touchState.getLastTouchDelta();
- float left = mTmpBounds.left + lastDelta.x;
- float top = mTmpBounds.top + lastDelta.y;
+ float lastX = mStartPosition.x + mDelta.x;
+ float lastY = mStartPosition.y + mDelta.y;
+ float left = lastX + lastDelta.x;
+ float top = lastY + lastDelta.y;
if (!touchState.allowDraggingOffscreen() || !ENABLE_MINIMIZE) {
left = Math.max(mMovementBounds.left, Math.min(mMovementBounds.right, left));
}
@@ -590,6 +594,12 @@ public class PipTouchHandler {
} else {
top = Math.max(mMovementBounds.top, Math.min(mMovementBounds.bottom, top));
}
+
+ // Add to the cumulative delta after bounding the position
+ mDelta.x += left - lastX;
+ mDelta.y += top - lastY;
+
+ mTmpBounds.set(mMotionHelper.getBounds());
mTmpBounds.offsetTo((int) left, (int) top);
mMotionHelper.movePip(mTmpBounds);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
index b2b5b02d7847..dd3361ba899a 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
@@ -61,7 +61,7 @@ public class PipTouchState {
}
/**
- * Processess a given touch event and updates the state.
+ * Processes a given touch event and updates the state.
*/
public void onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {