Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5333e99 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Retain current position and expand state on `next video`

- When tap `next video` and SysUI receives onTaskInfoChanged callback,
  it should keep the current expanded state, otherwise the PiP window
  would immediately resized to its unexpanded size. Fixed this by using
  current min edge when getDestinationBounds within onTaskInfoChanged
- When tap `next video`, we should also pass the current bounds to get
  the new destination bounds, otherwise we would move PiP window to its
  default position regardless of its current position

Video: http://go/recall/-/aaaaaabFQoRHlzixHdtY/hpXJhKI3CfDQ54a1sDmWyo
Bug: 157773582
Test: see video
Change-Id: I7515e88a2686015d0073181caa87df9426ff2f5b
parent c5401ef0
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -250,10 +250,19 @@ public class PipBoundsHandler {
    }

    /**
     * @return {@link Rect} of the destination PiP window bounds.
     * See {@link #getDestinationBounds(ComponentName, float, Rect, Size, boolean)}
     */
    Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
            Size minimalSize) {
        return getDestinationBounds(componentName, aspectRatio, bounds, minimalSize,
                false /* useCurrentMinEdgeSize */);
    }

    /**
     * @return {@link Rect} of the destination PiP window bounds.
     */
    Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
            Size minimalSize, boolean useCurrentMinEdgeSize) {
        if (!componentName.equals(mLastPipComponentName)) {
            onResetReentryBoundsUnchecked();
            mLastPipComponentName = componentName;
@@ -269,8 +278,7 @@ public class PipBoundsHandler {
            destinationBounds = new Rect(bounds);
        }
        if (isValidPictureInPictureAspectRatio(aspectRatio)) {
            transformBoundsToAspectRatio(destinationBounds, aspectRatio,
                    false /* useCurrentMinEdgeSize */);
            transformBoundsToAspectRatio(destinationBounds, aspectRatio, useCurrentMinEdgeSize);
        }
        mAspectRatio = aspectRatio;
        return destinationBounds;
+2 −1
Original line number Diff line number Diff line
@@ -453,7 +453,8 @@ public class PipTaskOrganizer extends TaskOrganizer implements
        }
        final Rect destinationBounds = mPipBoundsHandler.getDestinationBounds(
                info.topActivity, getAspectRatioOrDefault(newParams),
                null /* bounds */, getMinimalSize(info.topActivityInfo));
                mLastReportedBounds, getMinimalSize(info.topActivityInfo),
                true /* userCurrentMinEdgeSize */);
        Objects.requireNonNull(destinationBounds, "Missing destination bounds");
        scheduleAnimateResizePip(destinationBounds, mEnterExitAnimationDuration,
                null /* updateBoundsCallback */);