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

Commit 5a4d91e5 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Pass the transform from Launcher to SysUI

Video: http://rcll/aaaaaabFQoRHlzixHdtY/hT5SXvaCy28P4UtfuoKiDw
Bug: 181342797
Test: see video
Change-Id: Id70d89b6dc82c7b9a33bd998b9ebdeb31703c37d
parent e76e1e56
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1469,7 +1469,9 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
                    mSwipePipToHomeAnimator.getDestinationBounds());
            mRecentsAnimationController.setFinishTaskBounds(
                    mSwipePipToHomeAnimator.getTaskId(),
                    mSwipePipToHomeAnimator.getDestinationBounds());
                    mSwipePipToHomeAnimator.getDestinationBounds(),
                    mSwipePipToHomeAnimator.getFinishWindowCrop(),
                    mSwipePipToHomeAnimator.getFinishTransform());
            mIsSwipingPipToHome = false;
        }
    }
+6 −2
Original line number Diff line number Diff line
@@ -149,10 +149,14 @@ public class RecentsAnimationController {
     * accordingly. This should be called before `finish`
     * @param taskId for which the leash should be updated
     * @param destinationBounds bounds of the final PiP window
     * @param windowCrop bounds to crop as part of final transform.
     * @param float9 An array of 9 floats to be used as matrix transform.
     */
    public void setFinishTaskBounds(int taskId, Rect destinationBounds) {
    public void setFinishTaskBounds(int taskId, Rect destinationBounds, Rect windowCrop,
            float[] float9) {
        UI_HELPER_EXECUTOR.execute(
                () -> mController.setFinishTaskBounds(taskId, destinationBounds));
                () -> mController.setFinishTaskBounds(taskId, destinationBounds, windowCrop,
                        float9));
    }

    /**
+30 −9
Original line number Diff line number Diff line
@@ -134,8 +134,9 @@ public class SwipePipToHomeAnimator extends ValueAnimator implements

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mHasAnimationEnded) super.onAnimationEnd(animation);
                SwipePipToHomeAnimator.this.onAnimationEnd();
                if (mHasAnimationEnded) return;
                super.onAnimationEnd(animation);
                mHasAnimationEnded = true;
            }
        });
        addUpdateListener(this);
@@ -223,14 +224,34 @@ public class SwipePipToHomeAnimator extends ValueAnimator implements
        return mDestinationBounds;
    }

    private void onAnimationEnd() {
        if (mHasAnimationEnded) return;
    /**
     * @return {@link Rect} of the final window crop in destination orientation.
     */
    public Rect getFinishWindowCrop() {
        final Rect windowCrop = new Rect(mAppBounds);
        if (mSourceHintRectInsets != null) {
            windowCrop.inset(mSourceHintRectInsets);
        }
        return windowCrop;
    }

        final SurfaceControl.Transaction tx =
                PipSurfaceTransactionHelper.newSurfaceControlTransaction();
        mSurfaceTransactionHelper.reset(tx, mLeash, mDestinationBoundsTransformed, mFromRotation);
        tx.apply();
        mHasAnimationEnded = true;
    /**
     * @return Array of 9 floats represents the final transform in destination orientation.
     */
    public float[] getFinishTransform() {
        final Matrix transform = new Matrix();
        final float[] float9 = new float[9];
        if (mSourceHintRectInsets == null) {
            transform.setRectToRect(new RectF(mAppBounds), new RectF(mDestinationBounds),
                    Matrix.ScaleToFit.FILL);
        } else {
            final float scale = mAppBounds.width() <= mAppBounds.height()
                    ? (float) mDestinationBounds.width() / mAppBounds.width()
                    : (float) mDestinationBounds.height() / mAppBounds.height();
            transform.setScale(scale, scale);
        }
        transform.getValues(float9);
        return float9;
    }

    private RotatedPosition getRotatedPosition(float fraction) {