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

Commit d0269cd0 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Match the live tile cut out to the correct task view position in landscape mode"

parents fee1b25f 51d9ab7a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1738,6 +1738,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<?>, Q extends
            LiveTileOverlay.INSTANCE.update(
                    mTaskViewSimulator.getCurrentRect(),
                    mTaskViewSimulator.getCurrentCornerRadius());
            LiveTileOverlay.INSTANCE.setRotation(
                    mRecentsView.getPagedViewOrientedState().getDisplayRotation());
        }
        ProtoTracer.INSTANCE.get(mContext).scheduleFrameUpdate();
    }
+23 −0
Original line number Diff line number Diff line
@@ -519,6 +519,29 @@ public final class RecentsOrientedState implements SharedPreferences.OnSharedPre
        }
    }

    /**
     * Contrary to {@link #postDisplayRotation}.
     */
    public static void preDisplayRotation(@SurfaceRotation int displayRotation,
            float screenWidth, float screenHeight, Matrix out) {
        switch (displayRotation) {
            case ROTATION_0:
                return;
            case ROTATION_90:
                out.postRotate(90);
                out.postTranslate(screenWidth, 0);
                break;
            case ROTATION_180:
                out.postRotate(180);
                out.postTranslate(screenHeight, screenWidth);
                break;
            case ROTATION_270:
                out.postRotate(270);
                out.postTranslate(0, screenHeight);
                break;
        }
    }

    @NonNull
    @Override
    public String toString() {
+6 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI
import static com.android.launcher3.states.RotationHelper.deltaRotation;
import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE;
import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation;
import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation;
import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN;

import android.animation.TimeInterpolator;
@@ -80,6 +81,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
    private DeviceProfile mDp;

    private final Matrix mMatrix = new Matrix();
    private final Matrix mMatrixTmp = new Matrix();
    private final Point mRunningTargetWindowPosition = new Point();

    // Thumbnail view properties
@@ -211,7 +213,10 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
     */
    public RectF getCurrentRect() {
        RectF result = getCurrentCropRect();
        mMatrix.mapRect(result);
        mMatrixTmp.set(mMatrix);
        preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.widthPx, mDp.heightPx,
                mMatrixTmp);
        mMatrixTmp.mapRect(result);
        return result;
    }

+41 −2
Original line number Diff line number Diff line
package com.android.quickstep.views;

import static android.view.Surface.ROTATION_0;
import static android.view.Surface.ROTATION_180;
import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;

import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;

@@ -19,6 +24,7 @@ import android.util.FloatProperty;
import android.view.ViewOverlay;

import com.android.launcher3.anim.Interpolators;
import com.android.quickstep.util.RecentsOrientedState.SurfaceRotation;

public class LiveTileOverlay extends Drawable {

@@ -43,6 +49,8 @@ public class LiveTileOverlay extends Drawable {
    private final RectF mCurrentRect = new RectF();
    private final Rect mBoundsRect = new Rect();

    private @SurfaceRotation int mRotation = ROTATION_0;

    private float mCornerRadius;
    private Drawable mIcon;
    private Animator mIconAnimator;
@@ -69,6 +77,10 @@ public class LiveTileOverlay extends Drawable {
        mCurrentRect.set(left, top, right, bottom);
    }

    public void setRotation(@SurfaceRotation int rotation) {
        mRotation = rotation;
    }

    public void setIcon(Drawable icon) {
        mIcon = icon;
    }
@@ -103,8 +115,35 @@ public class LiveTileOverlay extends Drawable {
            canvas.save();
            float scale = Interpolators.clampToProgress(FAST_OUT_SLOW_IN, 0f,
                    1f).getInterpolation(mIconAnimationProgress);
            canvas.translate(mCurrentRect.centerX() - mIcon.getBounds().width() / 2 * scale,
                    mCurrentRect.top - mIcon.getBounds().height() / 2 * scale);

            int iconRadius = mIcon.getBounds().width() / 2;
            float dx = 0;
            float dy = 0;

            switch (mRotation) {
                case ROTATION_0:
                    dx = mCurrentRect.centerX() - iconRadius * scale;
                    dy = mCurrentRect.top - iconRadius * scale;
                    break;
                case ROTATION_90:
                    dx = mCurrentRect.right - iconRadius * scale;
                    dy = mCurrentRect.centerY() - iconRadius * scale;
                    break;
                case ROTATION_270:
                    dx = mCurrentRect.left - iconRadius * scale;
                    dy = mCurrentRect.centerY() - iconRadius * scale;
                    break;
                case ROTATION_180:
                    dx = mCurrentRect.centerX() - iconRadius * scale;
                    dy = mCurrentRect.bottom - iconRadius * scale;
                    break;
            }

            int rotationDegrees = mRotation * 90;
            if (mRotation == ROTATION_90 || mRotation == ROTATION_270) {
                canvas.rotate(rotationDegrees, dx + iconRadius, dy + iconRadius);
            }
            canvas.translate(dx, dy);
            canvas.scale(scale, scale);
            mIcon.draw(canvas);
            canvas.restore();