Merge "Move PiP swiftly in response to IME with keep clear areas flag enabled." into tm-qpr-dev am: 56cf35b281 am: d0609b03c7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19954058 Change-Id: Ie5add78e0ed9486767ffedc2029a3cf789772383 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -324,6 +324,19 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
return mPipTransitionController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the PiP window is currently being animated.
|
||||
*/
|
||||
public boolean isAnimating() {
|
||||
// TODO(b/183746978) move this to PipAnimationController, and inject that in PipController
|
||||
PipAnimationController.PipTransitionAnimator animator =
|
||||
mPipAnimationController.getCurrentAnimator();
|
||||
if (animator != null && animator.isRunning()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Rect getCurrentOrAnimatingBounds() {
|
||||
PipAnimationController.PipTransitionAnimator animator =
|
||||
mPipAnimationController.getCurrentAnimator();
|
||||
|
||||
@@ -54,13 +54,8 @@ public class PhonePipKeepClearAlgorithm implements PipKeepClearAlgorithm {
|
||||
? pipBoundsAlgorithm.getEntryDestinationBoundsIgnoringKeepClearAreas()
|
||||
: pipBoundsState.getBounds();
|
||||
float snapFraction = pipBoundsAlgorithm.getSnapFraction(startingBounds);
|
||||
int verticalGravity;
|
||||
int verticalGravity = Gravity.BOTTOM;
|
||||
int horizontalGravity;
|
||||
if (snapFraction < 1.5f || snapFraction >= 3.5f) {
|
||||
verticalGravity = Gravity.NO_GRAVITY;
|
||||
} else {
|
||||
verticalGravity = Gravity.BOTTOM;
|
||||
}
|
||||
if (snapFraction >= 0.5f && snapFraction < 2.5f) {
|
||||
horizontalGravity = Gravity.RIGHT;
|
||||
} else {
|
||||
|
||||
@@ -149,7 +149,42 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
private final Rect mTmpInsetBounds = new Rect();
|
||||
private final int mEnterAnimationDuration;
|
||||
|
||||
private final Runnable mMovePipInResponseToKeepClearAreasChangeCallback;
|
||||
private final Runnable mMovePipInResponseToKeepClearAreasChangeCallback =
|
||||
this::onKeepClearAreasChangedCallback;
|
||||
|
||||
private void onKeepClearAreasChangedCallback() {
|
||||
if (!mEnablePipKeepClearAlgorithm) {
|
||||
// early bail out if the keep clear areas feature is disabled
|
||||
return;
|
||||
}
|
||||
// if there is another animation ongoing, wait for it to finish and try again
|
||||
if (mPipTaskOrganizer.isAnimating()) {
|
||||
mMainExecutor.removeCallbacks(
|
||||
mMovePipInResponseToKeepClearAreasChangeCallback);
|
||||
mMainExecutor.executeDelayed(
|
||||
mMovePipInResponseToKeepClearAreasChangeCallback,
|
||||
PIP_KEEP_CLEAR_AREAS_DELAY);
|
||||
return;
|
||||
}
|
||||
updatePipPositionForKeepClearAreas();
|
||||
}
|
||||
|
||||
private void updatePipPositionForKeepClearAreas() {
|
||||
if (!mEnablePipKeepClearAlgorithm) {
|
||||
// early bail out if the keep clear areas feature is disabled
|
||||
return;
|
||||
}
|
||||
// only move if already in pip, other transitions account for keep clear areas
|
||||
if (mPipTransitionState.hasEnteredPip()) {
|
||||
Rect destBounds = mPipKeepClearAlgorithm.adjust(mPipBoundsState,
|
||||
mPipBoundsAlgorithm);
|
||||
// only move if the bounds are actually different
|
||||
if (destBounds != mPipBoundsState.getBounds()) {
|
||||
mPipTaskOrganizer.scheduleAnimateResizePip(destBounds,
|
||||
mEnterAnimationDuration, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mIsInFixedRotation;
|
||||
private PipAnimationListener mPinnedStackAnimationRecentsCallback;
|
||||
@@ -302,6 +337,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
|
||||
mPipBoundsState.setImeVisibility(imeVisible, imeHeight);
|
||||
mTouchHandler.onImeVisibilityChanged(imeVisible, imeHeight);
|
||||
if (imeVisible) {
|
||||
updatePipPositionForKeepClearAreas();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -414,15 +452,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
|
||||
mEnterAnimationDuration = mContext.getResources()
|
||||
.getInteger(R.integer.config_pipEnterAnimationDuration);
|
||||
mMovePipInResponseToKeepClearAreasChangeCallback = () -> {
|
||||
// only move if already in pip, other transitions account for keep clear areas
|
||||
if (mPipTransitionState.hasEnteredPip()) {
|
||||
Rect destBounds = mPipKeepClearAlgorithm.adjust(mPipBoundsState,
|
||||
mPipBoundsAlgorithm);
|
||||
mPipTaskOrganizer.scheduleAnimateResizePip(destBounds,
|
||||
mEnterAnimationDuration, null);
|
||||
}
|
||||
};
|
||||
mPipParamsChangedForwarder = pipParamsChangedForwarder;
|
||||
mDisplayInsetsController = displayInsetsController;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.Size;
|
||||
import android.view.DisplayCutout;
|
||||
@@ -70,6 +71,9 @@ public class PipTouchHandler {
|
||||
private static final String TAG = "PipTouchHandler";
|
||||
private static final float DEFAULT_STASH_VELOCITY_THRESHOLD = 18000.f;
|
||||
|
||||
private static final boolean ENABLE_PIP_KEEP_CLEAR_ALGORITHM =
|
||||
SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", false);
|
||||
|
||||
// Allow PIP to resize to a slightly bigger state upon touch
|
||||
private boolean mEnableResize;
|
||||
private final Context mContext;
|
||||
@@ -426,6 +430,9 @@ public class PipTouchHandler {
|
||||
if (mTouchState.isUserInteracting()) {
|
||||
// Defer the update of the current movement bounds until after the user finishes
|
||||
// touching the screen
|
||||
} else if (ENABLE_PIP_KEEP_CLEAR_ALGORITHM) {
|
||||
// Ignore moving PiP if keep clear algorithm is enabled, since IME and shelf height
|
||||
// now are accounted for in the keep clear algorithm calculations
|
||||
} else {
|
||||
final boolean isExpanded = mMenuState == MENU_STATE_FULL && willResizeMenu();
|
||||
final Rect toMovementBounds = new Rect();
|
||||
|
||||
Reference in New Issue
Block a user