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

Commit e308c480 authored by Chris Li's avatar Chris Li
Browse files

Set window crop for TaskFragment open/close animation

We don't want to show the TaskFragment window outside of its bounds.

Bug: 201261613
Bug: 196173550
Test: test with settings app
Change-Id: Idc627970abec95b8c6087a993802b32955449406
parent f9e1f3b1
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ class TaskFragmentAnimationAdapter {

    final Transformation mTransformation = new Transformation();
    final float[] mMatrix = new float[9];
    final float[] mVecs = new float[4];
    final Rect mRect = new Rect();
    private boolean mIsFirstFrame = true;

    TaskFragmentAnimationAdapter(@NonNull Animation animation,
@@ -76,6 +78,22 @@ class TaskFragmentAnimationAdapter {
                mTarget.localBounds.left, mTarget.localBounds.top);
        t.setMatrix(mLeash, mTransformation.getMatrix(), mMatrix);
        t.setAlpha(mLeash, mTransformation.getAlpha());

        // Open/close animation may scale up the surface. Apply an inverse scale to the window crop
        // so that it will not be covering other windows.
        mVecs[1] = mVecs[2] = 0;
        mVecs[0] = mVecs[3] = 1;
        mTransformation.getMatrix().mapVectors(mVecs);
        mVecs[0] = 1.f / mVecs[0];
        mVecs[3] = 1.f / mVecs[3];
        final Rect clipRect = mTarget.localBounds;
        mRect.left = (int) (clipRect.left * mVecs[0] + 0.5f);
        mRect.right = (int) (clipRect.right * mVecs[0] + 0.5f);
        mRect.top = (int) (clipRect.top * mVecs[3] + 0.5f);
        mRect.bottom = (int) (clipRect.bottom * mVecs[3] + 0.5f);
        mRect.offsetTo(Math.round(mTarget.localBounds.width() * (1 - mVecs[0]) / 2.f),
                Math.round(mTarget.localBounds.height() * (1 - mVecs[3]) / 2.f));
        t.setWindowCrop(mLeash, mRect);
    }

    /** Called after animation finished. */
@@ -157,8 +175,6 @@ class TaskFragmentAnimationAdapter {
     * Should be used for the animation of the {@link RemoteAnimationTarget} that has size change.
     */
    static class BoundsChangeAdapter extends TaskFragmentAnimationAdapter {
        private final float[] mVecs = new float[4];
        private final Rect mRect = new Rect();

        BoundsChangeAdapter(@NonNull Animation animation, @NonNull RemoteAnimationTarget target) {
            super(animation, target);