summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2020-06-29 13:41:55 -0700
committer Winson Chung <winsonc@google.com> 2020-06-30 03:25:32 +0000
commite773ee129c11e5a6f6845b3609940ccc86e7d7ac (patch)
treee40455228683fb63f6e557fb1651ecda164500dc
parent8da7870ba5b38a7b69d0e52dab15d9dd6f452218 (diff)
Only handle resize touches if starting gesture within resize area
- Only dispatch touch events to the resize gesture handler if started within the touch area (and reset the touch state to prevent normal handling) - Fix an issue with being able to drag on the pip edge touching the edge of the screen due to the movement bounds not taking the resized pip into account Bug: 160160987 Test: Repeatedly swipe on the drag handle on the edge of the screen Change-Id: Id616c7ee2ee102f26de83e827589058ff24987ef
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java20
2 files changed, 33 insertions, 10 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 a4edacecfd91..1ca53f907994 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
@@ -55,7 +55,9 @@ import com.android.systemui.pip.PipBoundsHandler;
import com.android.systemui.pip.PipTaskOrganizer;
import com.android.systemui.util.DeviceConfigProxy;
+import java.io.PrintWriter;
import java.util.concurrent.Executor;
+import java.util.function.Function;
import java.util.function.Supplier;
/**
@@ -94,7 +96,7 @@ public class PipResizeGestureHandler {
private final Rect mTmpBottomLeftCorner = new Rect();
private final Rect mTmpBottomRightCorner = new Rect();
private final Rect mDisplayBounds = new Rect();
- private final Supplier<Rect> mMovementBoundsSupplier;
+ private final Function<Rect, Rect> mMovementBoundsSupplier;
private final Runnable mUpdateMovementBoundsRunnable;
private int mDelta;
@@ -113,7 +115,7 @@ public class PipResizeGestureHandler {
public PipResizeGestureHandler(Context context, PipBoundsHandler pipBoundsHandler,
PipMotionHelper motionHelper, DeviceConfigProxy deviceConfig,
- PipTaskOrganizer pipTaskOrganizer, Supplier<Rect> movementBoundsSupplier,
+ PipTaskOrganizer pipTaskOrganizer, Function<Rect, Rect> movementBoundsSupplier,
Runnable updateMovementBoundsRunnable, SysUiState sysUiState) {
mContext = context;
mDisplayId = context.getDisplayId();
@@ -244,10 +246,15 @@ public class PipResizeGestureHandler {
return mTmpRegion.contains(x, y);
}
+ public boolean willStartResizeGesture(MotionEvent ev) {
+ return mEnableUserResize && isInValidSysUiState()
+ && isWithinTouchRegion((int) ev.getRawX(), (int) ev.getRawY());
+ }
+
private void setCtrlType(int x, int y) {
final Rect currentPipBounds = mMotionHelper.getBounds();
- Rect movementBounds = mMovementBoundsSupplier.get();
+ Rect movementBounds = mMovementBoundsSupplier.apply(currentPipBounds);
mDisplayBounds.set(movementBounds.left,
movementBounds.top,
movementBounds.right + currentPipBounds.width(),
@@ -353,6 +360,16 @@ public class PipResizeGestureHandler {
mMinSize.set(minX, minY);
}
+ public void dump(PrintWriter pw, String prefix) {
+ final String innerPrefix = prefix + " ";
+ pw.println(prefix + TAG);
+ pw.println(innerPrefix + "mAllowGesture=" + mAllowGesture);
+ pw.println(innerPrefix + "mIsAttached=" + mIsAttached);
+ pw.println(innerPrefix + "mIsEnabled=" + mIsEnabled);
+ pw.println(innerPrefix + "mEnableUserResize=" + mEnableUserResize);
+ pw.println(innerPrefix + "mThresholdCrossed=" + mThresholdCrossed);
+ }
+
class SysUiInputEventReceiver extends BatchedInputEventReceiver {
SysUiInputEventReceiver(InputChannel channel, Looper looper) {
super(channel, looper, Choreographer.getSfInstance());
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 3e06c1eb1ca3..b6e4e1628c20 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -644,12 +644,12 @@ public class PipTouchHandler {
}
MotionEvent ev = (MotionEvent) inputEvent;
- if (!mTouchState.isDragging()
- && !mMagnetizedPip.getObjectStuckToTarget()
- && !mMotionHelper.isAnimating()
- && mPipResizeGestureHandler.isWithinTouchRegion(
- (int) ev.getRawX(), (int) ev.getRawY())) {
+ if (ev.getActionMasked() == MotionEvent.ACTION_DOWN
+ && mPipResizeGestureHandler.willStartResizeGesture(ev)) {
+ // Initialize the touch state for the gesture, but immediately reset to invalidate the
+ // gesture
mTouchState.onTouchEvent(ev);
+ mTouchState.reset();
return true;
}
@@ -1032,8 +1032,11 @@ public class PipTouchHandler {
isMenuExpanded && willResizeMenu() ? mExpandedShortestEdgeSize : 0);
}
- private Rect getMovementBounds() {
- return mMovementBounds;
+ private Rect getMovementBounds(Rect curBounds) {
+ Rect movementBounds = new Rect();
+ mSnapAlgorithm.getMovementBounds(curBounds, mInsetBounds,
+ movementBounds, mIsImeShowing ? mImeHeight : 0);
+ return movementBounds;
}
/**
@@ -1065,6 +1068,9 @@ public class PipTouchHandler {
pw.println(innerPrefix + "mMovementBoundsExtraOffsets=" + mMovementBoundsExtraOffsets);
mTouchState.dump(pw, innerPrefix);
mMotionHelper.dump(pw, innerPrefix);
+ if (mPipResizeGestureHandler != null) {
+ mPipResizeGestureHandler.dump(pw, innerPrefix);
+ }
}
}