diff options
| author | 2020-05-21 14:35:17 -0700 | |
|---|---|---|
| committer | 2020-05-26 13:14:07 -0700 | |
| commit | eef964c8555393e3d8385a48e4e3fc93394b107f (patch) | |
| tree | 0cfabf3565002f6dea705151b347fb9efafe7624 | |
| parent | b7f81189bd670eb09995af594b2cb8c0afca7323 (diff) | |
PIP: Ensure we move some slop before pilfering for touches for resize.
Bug: 157152862
Test: Tap "X" on the PIP window, no longer getting CANCEL event in
TouchHandler
Change-Id: Iaef431ed855f6943ee92d39e625cdcf7c00007bc
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java index cc3ab29daed3..4b23e678b15d 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java @@ -37,6 +37,7 @@ import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InputMonitor; import android.view.MotionEvent; +import android.view.ViewConfiguration; import com.android.internal.policy.TaskResizingAlgorithm; import com.android.systemui.R; @@ -77,10 +78,12 @@ public class PipResizeGestureHandler { private final Runnable mUpdateMovementBoundsRunnable; private int mDelta; + private float mTouchSlop; private boolean mAllowGesture; private boolean mIsAttached; private boolean mIsEnabled; private boolean mEnableUserResize; + private boolean mThresholdCrossed; private InputMonitor mInputMonitor; private InputEventReceiver mInputEventReceiver; @@ -100,6 +103,7 @@ public class PipResizeGestureHandler { mPipTaskOrganizer = pipTaskOrganizer; mMovementBoundsSupplier = movementBoundsSupplier; mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable; + context.getDisplay().getRealSize(mMaxSize); reloadResources(); @@ -126,6 +130,7 @@ public class PipResizeGestureHandler { private void reloadResources() { final Resources res = mContext.getResources(); mDelta = res.getDimensionPixelSize(R.dimen.pip_resize_edge_size); + mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); } private void resetDragCorners() { @@ -270,7 +275,12 @@ public class PipResizeGestureHandler { break; case MotionEvent.ACTION_MOVE: // Capture inputs - mInputMonitor.pilferPointers(); + float dx = Math.abs(ev.getX() - mDownPoint.x); + float dy = Math.abs(ev.getY() - mDownPoint.y); + if (!mThresholdCrossed && dx > mTouchSlop && dy > mTouchSlop) { + mThresholdCrossed = true; + mInputMonitor.pilferPointers(); + } final Rect currentPipBounds = mMotionHelper.getBounds(); mLastResizeBounds.set(TaskResizingAlgorithm.resizeDrag(ev.getX(), ev.getY(), mDownPoint.x, mDownPoint.y, currentPipBounds, mCtrlType, mMinSize.x, @@ -288,6 +298,7 @@ public class PipResizeGestureHandler { mUpdateMovementBoundsRunnable.run(); mCtrlType = CTRL_NONE; mAllowGesture = false; + mThresholdCrossed = false; }); }); break; |