From 8a8b1f632ad8926bd23c85de75c86558b429cce7 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Thu, 10 Jun 2021 14:47:15 -0700 Subject: [PATCH] PiP: Divide up the magnetic percent by 2. At max size, doing a brute percentage calculation using width / minWidth ends up with a magnetic distance that's too big. Divide by 2 again to make it more natural. Bug: 190657668 Test: Pinch to max size, drag down - doesn't immediate snap to it anymore Change-Id: Ib5de742b753239a151686c1a85b27a6fe553a577 --- .../android/wm/shell/pip/phone/PipResizeGestureHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java index 32553f97c0206..841edef9172fa 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java @@ -536,8 +536,9 @@ public class PipResizeGestureHandler { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE, callback); } + final float magnetRadiusPercent = (float) mLastResizeBounds.width() / mMinSize.x / 2.f; mPipDismissTargetHandler - .setMagneticFieldRadiusPercent((float) mLastResizeBounds.width() / mMinSize.x); + .setMagneticFieldRadiusPercent(magnetRadiusPercent); mPipUiEventLogger.log( PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_RESIZE); } else {