Merge "Update the PIP exclusion bounds when PIP is offset by shelf/ime" into sc-dev
This commit is contained in:
@@ -35,6 +35,7 @@ import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Singleton source of truth for the current state of PIP bounds.
|
||||
@@ -84,6 +85,7 @@ public final class PipBoundsState {
|
||||
|
||||
private @Nullable Runnable mOnMinimalSizeChangeCallback;
|
||||
private @Nullable TriConsumer<Boolean, Integer, Boolean> mOnShelfVisibilityChangeCallback;
|
||||
private @Nullable Consumer<Rect> mOnPipExclusionBoundsChangeCallback;
|
||||
|
||||
public PipBoundsState(@NonNull Context context) {
|
||||
mContext = context;
|
||||
@@ -102,6 +104,9 @@ public final class PipBoundsState {
|
||||
/** Set the current PIP bounds. */
|
||||
public void setBounds(@NonNull Rect bounds) {
|
||||
mBounds.set(bounds);
|
||||
if (mOnPipExclusionBoundsChangeCallback != null) {
|
||||
mOnPipExclusionBoundsChangeCallback.accept(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the current PIP bounds. */
|
||||
@@ -386,6 +391,18 @@ public final class PipBoundsState {
|
||||
mOnShelfVisibilityChangeCallback = onShelfVisibilityChangeCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback to watch out for PiP bounds. This is mostly used by SystemUI's
|
||||
* Back-gesture handler, to avoid conflicting with PiP when it's stashed.
|
||||
*/
|
||||
public void setPipExclusionBoundsChangeCallback(
|
||||
@Nullable Consumer<Rect> onPipExclusionBoundsChangeCallback) {
|
||||
mOnPipExclusionBoundsChangeCallback = onPipExclusionBoundsChangeCallback;
|
||||
if (mOnPipExclusionBoundsChangeCallback != null) {
|
||||
mOnPipExclusionBoundsChangeCallback.accept(getBounds());
|
||||
}
|
||||
}
|
||||
|
||||
/** Source of truth for the current bounds of PIP that may be in motion. */
|
||||
public static class MotionBoundsState {
|
||||
/** The bounds used when PIP is in motion (e.g. during a drag or animation) */
|
||||
|
||||
@@ -566,6 +566,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
|
||||
mInSwipePipToHomeTransition = false;
|
||||
mPictureInPictureParams = null;
|
||||
mState = State.UNDEFINED;
|
||||
// Re-set the PIP bounds to none.
|
||||
mPipBoundsState.setBounds(new Rect());
|
||||
mPipUiEventLoggerLogger.setTaskInfo(null);
|
||||
mPipMenuController.detach();
|
||||
|
||||
|
||||
@@ -494,15 +494,6 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
mPipTaskOrganizer.stopSwipePipToHome(componentName, destinationBounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a listener to watch out for PiP bounds. This is mostly used by SystemUI's
|
||||
* Back-gesture handler, to avoid conflicting with PiP when it's stashed.
|
||||
*/
|
||||
private void setPipExclusionBoundsChangeListener(
|
||||
Consumer<Rect> pipExclusionBoundsChangeListener) {
|
||||
mTouchHandler.setPipExclusionBoundsChangeListener(pipExclusionBoundsChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPipTransitionStarted(int direction, Rect pipBounds) {
|
||||
if (isOutPipDirection(direction)) {
|
||||
@@ -712,7 +703,7 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
@Override
|
||||
public void setPipExclusionBoundsChangeListener(Consumer<Rect> listener) {
|
||||
mMainExecutor.execute(() -> {
|
||||
PipController.this.setPipExclusionBoundsChangeListener(listener);
|
||||
mPipBoundsState.setPipExclusionBoundsChangeCallback(listener);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.dynamicanimation.animation.AnimationHandler;
|
||||
import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler;
|
||||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
@@ -489,8 +488,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
||||
/**
|
||||
* Animates the PiP to offset it from the IME or shelf.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void animateToOffset(Rect originalBounds, int offset) {
|
||||
void animateToOffset(Rect originalBounds, int offset) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "animateToOffset: originalBounds=" + originalBounds + " offset=" + offset
|
||||
+ " callers=\n" + Debug.getCallers(5, " "));
|
||||
|
||||
@@ -57,8 +57,6 @@ import com.android.wm.shell.pip.PipTransitionController;
|
||||
import com.android.wm.shell.pip.PipUiEventLogger;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Manages all the touch handling for PIP on the Phone, including moving, dismissing and expanding
|
||||
@@ -73,7 +71,6 @@ public class PipTouchHandler {
|
||||
// Allow PIP to resize to a slightly bigger state upon touch
|
||||
private boolean mEnableResize;
|
||||
private final Context mContext;
|
||||
private final PipTaskOrganizer mPipTaskOrganizer;
|
||||
private final PipBoundsAlgorithm mPipBoundsAlgorithm;
|
||||
private final @NonNull PipBoundsState mPipBoundsState;
|
||||
private final PipUiEventLogger mPipUiEventLogger;
|
||||
@@ -81,7 +78,6 @@ public class PipTouchHandler {
|
||||
private final ShellExecutor mMainExecutor;
|
||||
|
||||
private PipResizeGestureHandler mPipResizeGestureHandler;
|
||||
private WeakReference<Consumer<Rect>> mPipExclusionBoundsChangeListener;
|
||||
|
||||
private final PhonePipMenuController mMenuController;
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
@@ -170,7 +166,6 @@ public class PipTouchHandler {
|
||||
mContext = context;
|
||||
mMainExecutor = mainExecutor;
|
||||
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
|
||||
mPipTaskOrganizer = pipTaskOrganizer;
|
||||
mPipBoundsAlgorithm = pipBoundsAlgorithm;
|
||||
mPipBoundsState = pipBoundsState;
|
||||
mMenuController = menuController;
|
||||
@@ -290,11 +285,6 @@ public class PipTouchHandler {
|
||||
|
||||
mFloatingContentCoordinator.onContentRemoved(mMotionHelper);
|
||||
}
|
||||
// Reset exclusion to none.
|
||||
if (mPipExclusionBoundsChangeListener != null
|
||||
&& mPipExclusionBoundsChangeListener.get() != null) {
|
||||
mPipExclusionBoundsChangeListener.get().accept(new Rect());
|
||||
}
|
||||
mPipResizeGestureHandler.onActivityUnpinned();
|
||||
}
|
||||
|
||||
@@ -931,10 +921,6 @@ public class PipTouchHandler {
|
||||
}
|
||||
|
||||
private void stashEndAction() {
|
||||
if (mPipExclusionBoundsChangeListener != null
|
||||
&& mPipExclusionBoundsChangeListener.get() != null) {
|
||||
mPipExclusionBoundsChangeListener.get().accept(mPipBoundsState.getBounds());
|
||||
}
|
||||
if (mPipBoundsState.getBounds().left < 0
|
||||
&& mPipBoundsState.getStashedState() != STASH_TYPE_LEFT) {
|
||||
mPipUiEventLogger.log(
|
||||
@@ -954,11 +940,6 @@ public class PipTouchHandler {
|
||||
// dismiss overlay, so just finish it after the animation completes
|
||||
mMenuController.hideMenu();
|
||||
}
|
||||
// Reset exclusion to none.
|
||||
if (mPipExclusionBoundsChangeListener != null
|
||||
&& mPipExclusionBoundsChangeListener.get() != null) {
|
||||
mPipExclusionBoundsChangeListener.get().accept(new Rect());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldStash(PointF vel, Rect motionBounds) {
|
||||
@@ -982,13 +963,6 @@ public class PipTouchHandler {
|
||||
}
|
||||
}
|
||||
|
||||
void setPipExclusionBoundsChangeListener(Consumer<Rect> pipExclusionBoundsChangeListener) {
|
||||
mPipExclusionBoundsChangeListener = new WeakReference<>(pipExclusionBoundsChangeListener);
|
||||
pipExclusionBoundsChangeListener.accept(mPipTaskOrganizer.isInPip()
|
||||
? mPipBoundsState.getBounds() : new Rect());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current movement bounds based on whether the menu is currently visible and
|
||||
* resized.
|
||||
|
||||
Reference in New Issue
Block a user