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

Commit fd968a79 authored by Kevin's avatar Kevin
Browse files

Scale down thumbnail with app surface

The recents Go app to overview transition has app scale down to a
thumbnail but normally covers the thumbnail.  However, apps with
transparency will be semi-visible and will allow the user to see
the thumbnail in the back at its final size. Instead, we should fit
the thumbnail to the surface so that they both scale down at the same
time.

Bug: 132458092
Test: Go to app with transparency, scale down
Change-Id: Iaebeaaf2ddcfc86fd4f55ef9d8c3f19583947c48
parent 763a7bff
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,8 @@
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="@dimen/task_item_height"
    android:layout_height="@dimen/task_item_height"
    android:orientation="horizontal">
    android:orientation="horizontal"
    android:clipChildren="false">
    <com.android.quickstep.views.TaskThumbnailIconView
    <com.android.quickstep.views.TaskThumbnailIconView
        android:id="@+id/task_icon_and_thumbnail"
        android:id="@+id/task_icon_and_thumbnail"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
+39 −3
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.ArraySet;
import android.util.ArraySet;
import android.util.AttributeSet;
import android.util.AttributeSet;
@@ -723,6 +724,7 @@ public final class IconRecentsView extends FrameLayout implements Insettable {
        Rect endRect = new Rect();
        Rect endRect = new Rect();
        thumbnailView.getGlobalVisibleRect(endRect);
        thumbnailView.getGlobalVisibleRect(endRect);
        Rect appBounds = appTarget.sourceContainerBounds;
        Rect appBounds = appTarget.sourceContainerBounds;
        RectF currentAppRect = new RectF();


        SyncRtSurfaceTransactionApplierCompat surfaceApplier =
        SyncRtSurfaceTransactionApplierCompat surfaceApplier =
                new SyncRtSurfaceTransactionApplierCompat(this);
                new SyncRtSurfaceTransactionApplierCompat(this);
@@ -765,17 +767,30 @@ public final class IconRecentsView extends FrameLayout implements Insettable {


            @Override
            @Override
            public void onUpdate(float percent) {
            public void onUpdate(float percent) {
                appMatrix.preScale(mScaleX.value, mScaleY.value,
                Matrix m = new Matrix();
                m.preScale(mScaleX.value, mScaleY.value,
                        appBounds.width() / 2.0f, appBounds.height() / 2.0f);
                        appBounds.width() / 2.0f, appBounds.height() / 2.0f);
                appMatrix.postTranslate(mTranslationX.value, mTranslationY.value);
                m.postTranslate(mTranslationX.value, mTranslationY.value);

                appMatrix.preConcat(m);
                params[1] = new SurfaceParams(appTarget.leash, mAlpha.value, appMatrix,
                params[1] = new SurfaceParams(appTarget.leash, mAlpha.value, appMatrix,
                        null /* windowCrop */, getLayer(appTarget, boostedMode),
                        null /* windowCrop */, getLayer(appTarget, boostedMode),
                        0 /* cornerRadius */);
                        0 /* cornerRadius */);
                surfaceApplier.scheduleApply(params);
                surfaceApplier.scheduleApply(params);

                m.mapRect(currentAppRect, new RectF(appBounds));
                setViewToRect(thumbnailView, new RectF(endRect), currentAppRect);
                appMatrix.reset();
                appMatrix.reset();
            }
            }
        });
        });
        remoteAppAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                thumbnailView.setTranslationY(0);
                thumbnailView.setTranslationX(0);
                thumbnailView.setScaleX(1);
                thumbnailView.setScaleY(1);
            }
        });
        anim.play(remoteAppAnim);
        anim.play(remoteAppAnim);
    }
    }


@@ -841,6 +856,27 @@ public final class IconRecentsView extends FrameLayout implements Insettable {
        }
        }
    }
    }


    /**
     * Set view properties so that the view fits to the target rect.
     *
     * @param view view to set
     * @param origRect original rect that view was located
     * @param targetRect rect to set to
     */
    private void setViewToRect(View view, RectF origRect, RectF targetRect) {
        float dX = targetRect.left - origRect.left;
        float dY = targetRect.top - origRect.top;
        view.setTranslationX(dX);
        view.setTranslationY(dY);

        float scaleX = targetRect.width() / origRect.width();
        float scaleY = targetRect.height() / origRect.height();
        view.setPivotX(0);
        view.setPivotY(0);
        view.setScaleX(scaleX);
        view.setScaleY(scaleY);
    }

    @Override
    @Override
    public void setInsets(Rect insets) {
    public void setInsets(Rect insets) {
        mInsets = insets;
        mInsets = insets;