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

Commit 62c4711b authored by Zak Cohen's avatar Zak Cohen
Browse files

Overview Actions - use scaled insets for screenshot transition.

The actual task insets aren't used for display, so to make the
transition line up, use scaled ones.

Bug: 154524544
Test: local

Change-Id: I0f484e6dbf13a558c042f84aa68f1d6e9c23b328
parent 4994b333
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -18,12 +18,16 @@ package com.android.quickstep;

import static com.android.launcher3.util.MainThreadInitializedObject.forOverride;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.widget.Toast;

import androidx.annotation.RequiresApi;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
@@ -122,6 +126,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
                    }
                }

                @SuppressLint("NewApi")
                @Override
                public void onScreenshot() {
                    if (isAllowedByPolicy) {
@@ -159,9 +164,9 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
         *
         * @return the insets in screen coordinates.
         */
        @RequiresApi(api = Build.VERSION_CODES.Q)
        public Insets getTaskSnapshotInsets() {
            // TODO: return the real insets
            return Insets.of(0, 0, 0, 0);
            return mThumbnailView.getScaledInsets();
        }

        private void showBlockedByPolicyMessage() {
+36 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Insets;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
@@ -34,12 +35,15 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.os.Build;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
import android.view.Surface;
import android.view.View;

import androidx.annotation.RequiresApi;

import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
@@ -211,6 +215,38 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        return fallback;
    }

    /**
     * Get the scaled insets that are being used to draw the task view. This is a subsection of
     * the full snapshot.
     * @return the insets in snapshot bitmap coordinates.
     */
    @RequiresApi(api = Build.VERSION_CODES.Q)
    public Insets getScaledInsets() {
        if (mThumbnailData == null) {
            return Insets.NONE;
        }

        RectF bitmapRect = new RectF(
                0, 0,
                mThumbnailData.thumbnail.getWidth(), mThumbnailData.thumbnail.getHeight());
        RectF viewRect = new RectF(0, 0, getMeasuredWidth(), getMeasuredHeight());

        // The position helper matrix tells us how to transform the bitmap to fit the view, the
        // inverse tells us where the view would be in the bitmaps coordinates. The insets are the
        // difference between the bitmap bounds and the projected view bounds.
        Matrix boundsToBitmapSpace = new Matrix();
        mPreviewPositionHelper.getMatrix().invert(boundsToBitmapSpace);
        RectF boundsInBitmapSpace = new RectF();
        boundsToBitmapSpace.mapRect(boundsInBitmapSpace, viewRect);

        return Insets.of(
            Math.round(boundsInBitmapSpace.left),
            Math.round(boundsInBitmapSpace.top),
            Math.round(bitmapRect.right - boundsInBitmapSpace.right),
            Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom));
    }


    public int getSysUiStatusNavFlags() {
        if (mThumbnailData != null) {
            int flags = 0;