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

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

Adjust the auto-pip app bounds for TaskBar

When on tablet / large-screen devices where TaskBar is present, the
bounds of the recents animation leash would be cut by TaskBar height,
therefore we need to adjust the app bounds for auto-pip accordingly.

Video: http://recall/-/aaaaaabFQoRHlzixHdtY/fmMql9z3gYIu98ntQYklQU
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/hvoqi4bBWyPMgwzEXXrnnC
Bug: 201824622
Test: Enter PiP from GMM on tablet and unfolded foldables, both \
      landscape and portrait, with TaskBar stashed and unstashed.
Change-Id: Id91190b8f0045db4af0f2a3f1993149dc34457ab
parent 6501379f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.Intent;
import android.graphics.Matrix;
@@ -1421,6 +1422,16 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
                        runningTaskTarget.taskInfo.pictureInPictureParams,
                        homeRotation,
                        mDp.hotseatBarSizePx);
        final Rect appBounds = new Rect();
        final WindowConfiguration winConfig = taskInfo.configuration.windowConfiguration;
        // Adjust the appBounds for TaskBar by using the calculated window crop Rect
        // from TaskViewSimulator and fallback to the bounds in TaskInfo when it's originated
        // from windowing modes other than full-screen.
        if (winConfig.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FULLSCREEN) {
            mRemoteTargetHandles[0].getTaskViewSimulator().getCurrentCropRect().round(appBounds);
        } else {
            appBounds.set(winConfig.getBounds());
        }
        final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder()
                .setContext(mContext)
                .setTaskId(runningTaskTarget.taskId)
@@ -1428,7 +1439,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
                .setLeash(runningTaskTarget.leash)
                .setSourceRectHint(
                        runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint())
                .setAppBounds(taskInfo.configuration.windowConfiguration.getBounds())
                .setAppBounds(appBounds)
                .setHomeToWindowPositionMap(homeToWindowPositionMap)
                .setStartBounds(startRect)
                .setDestinationBounds(destinationBounds)