Set PiP stashing to a set 32dp away from the edge of the screen.

Bug: 165793553
Test: Stash PIP
Change-Id: Ib6e0058a9e0c6b60605c6143e9407ce809abebf3
This commit is contained in:
Ben Lin
2020-10-30 18:14:48 -07:00
parent 6e59ac63ff
commit beefdec180
3 changed files with 19 additions and 6 deletions

View File

@@ -57,6 +57,9 @@
<dimen name="pip_resize_handle_margin">4dp</dimen>
<dimen name="pip_resize_handle_padding">0dp</dimen>
<!-- PIP stash offset size, which is the width of visible PIP region when stashed. -->
<dimen name="pip_stash_offset">32dp</dimen>
<dimen name="dismiss_target_x_size">24dp</dimen>
<dimen name="floating_dismiss_bottom_margin">50dp</dimen>

View File

@@ -33,6 +33,7 @@ import androidx.dynamicanimation.animation.AnimationHandler;
import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler;
import androidx.dynamicanimation.animation.SpringForce;
import com.android.wm.shell.R;
import com.android.wm.shell.animation.FloatProperties;
import com.android.wm.shell.animation.PhysicsAnimator;
import com.android.wm.shell.common.FloatingContentCoordinator;
@@ -60,7 +61,6 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
private static final int EXPAND_STACK_TO_MENU_DURATION = 250;
private static final int LEAVE_PIP_DURATION = 300;
private static final int SHIFT_DURATION = 300;
private static final float STASH_RATIO = 0.25f;
/** Friction to use for PIP when it moves via physics fling animations. */
private static final float DEFAULT_FRICTION = 2f;
@@ -94,6 +94,8 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
/** The destination bounds to which PIP is animating. */
private final Rect mAnimatingToBounds = new Rect();
private int mStashOffset = 0;
/** Coordinator instance for resolving conflicts with other floating content. */
private FloatingContentCoordinator mFloatingContentCoordinator;
@@ -189,6 +191,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
mPipTaskOrganizer.registerPipTransitionCallback(mPipTransitionCallback);
mTemporaryBoundsPhysicsAnimator.setCustomAnimationHandler(
mSfAnimationHandlerThreadLocal.get());
reloadResources();
mResizePipUpdateListener = (target, values) -> {
if (!mTemporaryBounds.isEmpty()) {
@@ -198,6 +201,11 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
};
}
void reloadResources() {
mStashOffset = mContext.getResources()
.getDimensionPixelSize(R.dimen.pip_stash_offset);
}
@NonNull
@Override
public Rect getFloatingBoundsOnScreen() {
@@ -414,9 +422,10 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
FloatProperties.RECT_Y, velocityY, mFlingConfigY, mSpringConfig)
.withEndActions(endAction);
final float offset = ((float) getBounds().width()) * (1.0f - STASH_RATIO);
final float leftEdge = isStash ? mMovementBounds.left - offset : mMovementBounds.left;
final float rightEdge = isStash ? mMovementBounds.right + offset : mMovementBounds.right;
final float leftEdge = isStash ? mStashOffset - mPipBoundsState.getBounds().width()
: mMovementBounds.left;
final float rightEdge = isStash ? mPipBoundsState.getDisplayBounds().right - mStashOffset
: mMovementBounds.right;
final float xEndValue = velocityX < 0 ? leftEdge : rightEdge;
final float estimatedFlingYEndValue =
@@ -524,9 +533,9 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
DEFAULT_FRICTION, mMovementBounds.left, mMovementBounds.right);
mFlingConfigY = new PhysicsAnimator.FlingConfig(
DEFAULT_FRICTION, mMovementBounds.top, mMovementBounds.bottom);
final float offset = ((float) getBounds().width()) * (1.0f - STASH_RATIO);
mStashConfigX = new PhysicsAnimator.FlingConfig(
DEFAULT_FRICTION, mMovementBounds.left - offset, mMovementBounds.right + offset);
DEFAULT_FRICTION, mStashOffset - mPipBoundsState.getBounds().width(),
mPipBoundsState.getDisplayBounds().right - mStashOffset);
}
/**

View File

@@ -221,6 +221,7 @@ public class PipTouchHandler {
R.dimen.pip_expanded_shortest_edge_size);
mImeOffset = res.getDimensionPixelSize(R.dimen.pip_ime_offset);
mPipDismissTargetHandler.updateMagneticTargetSize();
mMotionHelper.reloadResources();
}
private boolean shouldShowResizeHandle() {