Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipDismissTargetHandler.java +15 −7 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.TransitionDrawable; import android.os.Handler; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; Loading @@ -41,8 +40,6 @@ import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.magnetictarget.MagnetizedObject; import com.android.wm.shell.pip.PipUiEventLogger; import java.util.concurrent.TimeUnit; import kotlin.Unit; /** Loading Loading @@ -89,7 +86,9 @@ public class PipDismissTargetHandler { // Allow dragging the PIP to a location to close it private boolean mEnableDismissDragToEdge; private int mTargetSize; private int mDismissAreaHeight; private float mMagneticFieldRadiusPercent = 1f; private final Context mContext; private final PipMotionHelper mMotionHelper; Loading Loading @@ -183,18 +182,27 @@ public class PipDismissTargetHandler { } final Resources res = mContext.getResources(); final int targetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size); mTargetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size); mDismissAreaHeight = res.getDimensionPixelSize(R.dimen.floating_dismiss_gradient_height); final FrameLayout.LayoutParams newParams = new FrameLayout.LayoutParams(targetSize, targetSize); new FrameLayout.LayoutParams(mTargetSize, mTargetSize); newParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; newParams.bottomMargin = mContext.getResources().getDimensionPixelSize( R.dimen.floating_dismiss_bottom_margin); mTargetView.setLayoutParams(newParams); // Set the magnetic field radius equal to the target size from the center of the target mMagneticTarget.setMagneticFieldRadiusPx( (int) (targetSize * MAGNETIC_FIELD_RADIUS_MULTIPLIER)); setMagneticFieldRadiusPercent(mMagneticFieldRadiusPercent); } /** * Increase or decrease the field radius of the magnet object, e.g. with larger percent, * PiP will magnetize to the field sooner. */ public void setMagneticFieldRadiusPercent(float percent) { mMagneticFieldRadiusPercent = percent; mMagneticTarget.setMagneticFieldRadiusPx((int) (mMagneticFieldRadiusPercent * mTargetSize * MAGNETIC_FIELD_RADIUS_MULTIPLIER)); } /** Adds the magnetic target view to the WindowManager so it's ready to be animated in. */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +8 −3 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class PipResizeGestureHandler { private final PipBoundsState mPipBoundsState; private final PipTaskOrganizer mPipTaskOrganizer; private final PhonePipMenuController mPhonePipMenuController; private final PipDismissTargetHandler mPipDismissTargetHandler; private final PipUiEventLogger mPipUiEventLogger; private final PipPinchResizingAlgorithm mPinchResizingAlgorithm; private final int mDisplayId; Loading Loading @@ -117,9 +118,10 @@ public class PipResizeGestureHandler { public PipResizeGestureHandler(Context context, PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsState pipBoundsState, PipMotionHelper motionHelper, PipTaskOrganizer pipTaskOrganizer, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { mContext = context; mDisplayId = context.getDisplayId(); mMainExecutor = mainExecutor; Loading @@ -127,6 +129,7 @@ public class PipResizeGestureHandler { mPipBoundsState = pipBoundsState; mMotionHelper = motionHelper; mPipTaskOrganizer = pipTaskOrganizer; mPipDismissTargetHandler = pipDismissTargetHandler; mMovementBoundsSupplier = movementBoundsSupplier; mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable; mPhonePipMenuController = menuActivityController; Loading Loading @@ -510,6 +513,8 @@ public class PipResizeGestureHandler { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE, callback); } mPipDismissTargetHandler .setMagneticFieldRadiusPercent((float) mLastResizeBounds.width() / mMinSize.x); mPipUiEventLogger.log( PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_RESIZE); } else { Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +5 −5 Original line number Diff line number Diff line Loading @@ -176,13 +176,13 @@ public class PipTouchHandler { mMotionHelper = new PipMotionHelper(mContext, pipBoundsState, pipTaskOrganizer, mMenuController, mPipBoundsAlgorithm.getSnapAlgorithm(), pipTransitionController, floatingContentCoordinator); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger, mMotionHelper, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mTouchState = new PipTouchState(ViewConfiguration.get(context), () -> { if (mPipBoundsState.isStashed()) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipDismissTargetHandler.java +15 −7 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.TransitionDrawable; import android.os.Handler; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; Loading @@ -41,8 +40,6 @@ import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.magnetictarget.MagnetizedObject; import com.android.wm.shell.pip.PipUiEventLogger; import java.util.concurrent.TimeUnit; import kotlin.Unit; /** Loading Loading @@ -89,7 +86,9 @@ public class PipDismissTargetHandler { // Allow dragging the PIP to a location to close it private boolean mEnableDismissDragToEdge; private int mTargetSize; private int mDismissAreaHeight; private float mMagneticFieldRadiusPercent = 1f; private final Context mContext; private final PipMotionHelper mMotionHelper; Loading Loading @@ -183,18 +182,27 @@ public class PipDismissTargetHandler { } final Resources res = mContext.getResources(); final int targetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size); mTargetSize = res.getDimensionPixelSize(R.dimen.dismiss_circle_size); mDismissAreaHeight = res.getDimensionPixelSize(R.dimen.floating_dismiss_gradient_height); final FrameLayout.LayoutParams newParams = new FrameLayout.LayoutParams(targetSize, targetSize); new FrameLayout.LayoutParams(mTargetSize, mTargetSize); newParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; newParams.bottomMargin = mContext.getResources().getDimensionPixelSize( R.dimen.floating_dismiss_bottom_margin); mTargetView.setLayoutParams(newParams); // Set the magnetic field radius equal to the target size from the center of the target mMagneticTarget.setMagneticFieldRadiusPx( (int) (targetSize * MAGNETIC_FIELD_RADIUS_MULTIPLIER)); setMagneticFieldRadiusPercent(mMagneticFieldRadiusPercent); } /** * Increase or decrease the field radius of the magnet object, e.g. with larger percent, * PiP will magnetize to the field sooner. */ public void setMagneticFieldRadiusPercent(float percent) { mMagneticFieldRadiusPercent = percent; mMagneticTarget.setMagneticFieldRadiusPx((int) (mMagneticFieldRadiusPercent * mTargetSize * MAGNETIC_FIELD_RADIUS_MULTIPLIER)); } /** Adds the magnetic target view to the WindowManager so it's ready to be animated in. */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java +8 −3 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public class PipResizeGestureHandler { private final PipBoundsState mPipBoundsState; private final PipTaskOrganizer mPipTaskOrganizer; private final PhonePipMenuController mPhonePipMenuController; private final PipDismissTargetHandler mPipDismissTargetHandler; private final PipUiEventLogger mPipUiEventLogger; private final PipPinchResizingAlgorithm mPinchResizingAlgorithm; private final int mDisplayId; Loading Loading @@ -117,9 +118,10 @@ public class PipResizeGestureHandler { public PipResizeGestureHandler(Context context, PipBoundsAlgorithm pipBoundsAlgorithm, PipBoundsState pipBoundsState, PipMotionHelper motionHelper, PipTaskOrganizer pipTaskOrganizer, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { PipTaskOrganizer pipTaskOrganizer, PipDismissTargetHandler pipDismissTargetHandler, Function<Rect, Rect> movementBoundsSupplier, Runnable updateMovementBoundsRunnable, PipUiEventLogger pipUiEventLogger, PhonePipMenuController menuActivityController, ShellExecutor mainExecutor) { mContext = context; mDisplayId = context.getDisplayId(); mMainExecutor = mainExecutor; Loading @@ -127,6 +129,7 @@ public class PipResizeGestureHandler { mPipBoundsState = pipBoundsState; mMotionHelper = motionHelper; mPipTaskOrganizer = pipTaskOrganizer; mPipDismissTargetHandler = pipDismissTargetHandler; mMovementBoundsSupplier = movementBoundsSupplier; mUpdateMovementBoundsRunnable = updateMovementBoundsRunnable; mPhonePipMenuController = menuActivityController; Loading Loading @@ -510,6 +513,8 @@ public class PipResizeGestureHandler { mPipTaskOrganizer.scheduleFinishResizePip(mLastResizeBounds, PipAnimationController.TRANSITION_DIRECTION_USER_RESIZE, callback); } mPipDismissTargetHandler .setMagneticFieldRadiusPercent((float) mLastResizeBounds.width() / mMinSize.x); mPipUiEventLogger.log( PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_RESIZE); } else { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java +5 −5 Original line number Diff line number Diff line Loading @@ -176,13 +176,13 @@ public class PipTouchHandler { mMotionHelper = new PipMotionHelper(mContext, pipBoundsState, pipTaskOrganizer, mMenuController, mPipBoundsAlgorithm.getSnapAlgorithm(), pipTransitionController, floatingContentCoordinator); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mPipDismissTargetHandler = new PipDismissTargetHandler(context, pipUiEventLogger, mMotionHelper, mainExecutor); mPipResizeGestureHandler = new PipResizeGestureHandler(context, pipBoundsAlgorithm, pipBoundsState, mMotionHelper, pipTaskOrganizer, mPipDismissTargetHandler, this::getMovementBounds, this::updateMovementBounds, pipUiEventLogger, menuController, mainExecutor); mTouchState = new PipTouchState(ViewConfiguration.get(context), () -> { if (mPipBoundsState.isStashed()) { Loading