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

Commit 839a5d12 authored by Mateusz Cicheński's avatar Mateusz Cicheński Committed by Android (Google) Code Review
Browse files

Merge "Delay PiP movement in response to keep clear areas changed." into tm-qpr-dev

parents 2de34a74 12199ddb
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -114,6 +114,9 @@ public class PipController implements PipTransitionController.PipTransitionCallb
        UserChangeListener {
    private static final String TAG = "PipController";

    private static final long PIP_KEEP_CLEAR_AREAS_DELAY =
            SystemProperties.getLong("persist.wm.debug.pip_keep_clear_areas_delay", 200);

    private boolean mEnablePipKeepClearAlgorithm =
            SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", false);

@@ -146,6 +149,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
    private final Rect mTmpInsetBounds = new Rect();
    private final int mEnterAnimationDuration;

    private final Runnable mMovePipInResponseToKeepClearAreasChangeCallback;

    private boolean mIsInFixedRotation;
    private PipAnimationListener mPinnedStackAnimationRecentsCallback;

@@ -277,14 +282,12 @@ public class PipController implements PipTransitionController.PipTransitionCallb
                    if (mPipBoundsState.getDisplayId() == displayId) {
                        if (mEnablePipKeepClearAlgorithm) {
                            mPipBoundsState.setKeepClearAreas(restricted, unrestricted);
                            // 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);
                            }

                            mMainExecutor.removeCallbacks(
                                    mMovePipInResponseToKeepClearAreasChangeCallback);
                            mMainExecutor.executeDelayed(
                                    mMovePipInResponseToKeepClearAreasChangeCallback,
                                    PIP_KEEP_CLEAR_AREAS_DELAY);
                        }
                    }
                }
@@ -411,6 +414,15 @@ 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;