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

Commit 778f495f authored by Winson's avatar Winson Committed by Winson Chung
Browse files

Removing code to animate thumbnail scale now that we animate bounds.

- This CL reverts the code to the previous state where we can just 
  calculate the thumbnail scale from the view bounds.

Change-Id: I156ae915af76055b5177a6bdf0f929bdf6acea01
parent 2c8eb3e0
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -147,27 +147,11 @@ public class FreeformWorkspaceLayoutAlgorithm {
    public TaskViewTransform getTransform(Task task, TaskViewTransform transformOut,
            TaskStackLayoutAlgorithm stackLayout) {
        if (mTaskRectMap.containsKey(task.key)) {
            final Rect taskRect = stackLayout.mTaskRect;
            final RectF ffRect = mTaskRectMap.get(task.key);

            transformOut.scale = 1f;
            transformOut.alpha = 1f;
            transformOut.translationZ = stackLayout.mMaxTranslationZ;
            if (task.thumbnail != null) {
                if (task.bounds == null) {
                    // This is a stack task that has no freeform thumbnail, so keep the same bitmap
                    // scale as it had in the stack
                    transformOut.thumbnailScale = (float) taskRect.width() /
                            task.thumbnail.getWidth();
                } else {
                    // This is a freeform rect so fit the bitmap to the task bounds
                    transformOut.thumbnailScale = Math.min(
                            ffRect.width() / task.thumbnail.getWidth(),
                            ffRect.height() / task.thumbnail.getHeight());
                }
            } else {
                transformOut.thumbnailScale = 1f;
            }
            transformOut.rect.set(ffRect);
            transformOut.rect.offset(stackLayout.mFreeformRect.left, stackLayout.mFreeformRect.top);
            transformOut.visible = true;
+1 −6
Original line number Diff line number Diff line
@@ -592,12 +592,8 @@ public class TaskStackLayoutAlgorithm {
                transformOut.reset();
                return transformOut;
            }
            getStackTransform(mTaskIndexMap.get(task.key), stackScroll, transformOut,
            return getStackTransform(mTaskIndexMap.get(task.key), stackScroll, transformOut,
                    frontTransform);
            if (task.thumbnail != null) {
                transformOut.thumbnailScale = (float) mTaskRect.width() / task.thumbnail.getWidth();
            }
            return transformOut;
        }
    }

@@ -661,7 +657,6 @@ public class TaskStackLayoutAlgorithm {
        Utilities.scaleRectAboutCenter(transformOut.rect, transformOut.scale);
        transformOut.visible = (transformOut.rect.top < mStackRect.bottom) &&
                (frontTransform == null || transformOut.rect.top != frontTransform.rect.top);
        transformOut.thumbnailScale = 1f;
        transformOut.p = relP;
        return transformOut;
    }
+0 −6
Original line number Diff line number Diff line
@@ -251,17 +251,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
        boolean requiresHwLayers = toTransform.applyToTaskView(this, mTmpAnimators, toAnimation,
                !config.fakeShadows);
        if (toAnimation.isImmediate()) {
            mThumbnailView.setBitmapScale(toTransform.thumbnailScale);
            setTaskProgress(toTransform.p);
            if (toAnimation.listener != null) {
                toAnimation.listener.onAnimationEnd(null);
            }
        } else {
            if (Float.compare(mThumbnailView.getBitmapScale(), toTransform.thumbnailScale) != 0) {
                mTmpAnimators.add(ObjectAnimator.ofFloat(mThumbnailView,
                        TaskViewThumbnail.BITMAP_SCALE, mThumbnailView.getBitmapScale(),
                        toTransform.thumbnailScale));
            }
            if (Float.compare(getTaskProgress(), toTransform.p) != 0) {
                mTmpAnimators.add(ObjectAnimator.ofFloat(this, TASK_PROGRESS, getTaskProgress(),
                        toTransform.p));
+23 −21
Original line number Diff line number Diff line
@@ -42,26 +42,15 @@ import com.android.systemui.recents.model.Task;
 */
public class TaskViewThumbnail extends View {

    public static final Property<TaskViewThumbnail, Float> BITMAP_SCALE =
            new FloatProperty<TaskViewThumbnail>("bitmapScale") {
                @Override
                public void setValue(TaskViewThumbnail object, float scale) {
                    object.setBitmapScale(scale);
                }

                @Override
                public Float get(TaskViewThumbnail object) {
                    return object.getBitmapScale();
                }
            };
    private Task mTask;

    // Drawing
    Rect mThumbnailRect = new Rect();
    Rect mTaskViewRect = new Rect();
    int mCornerRadius;
    float mDimAlpha;
    Matrix mScaleMatrix = new Matrix();
    Paint mDrawPaint = new Paint();
    float mBitmapScale = 1f;
    BitmapShader mBitmapShader;
    LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0);

@@ -105,6 +94,7 @@ public class TaskViewThumbnail extends View {
     */
    public void onTaskViewSizeChanged(int width, int height) {
        mTaskViewRect.set(0, 0, width, height);
        updateThumbnailScale();
        invalidate();
    }

@@ -125,9 +115,12 @@ public class TaskViewThumbnail extends View {
            mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP,
                    Shader.TileMode.CLAMP);
            mDrawPaint.setShader(mBitmapShader);
            mThumbnailRect.set(0, 0, bm.getWidth(), bm.getHeight());
            updateThumbnailScale();
        } else {
            mBitmapShader = null;
            mDrawPaint.setShader(null);
            mThumbnailRect.setEmpty();
        }
        invalidate();
    }
@@ -151,12 +144,23 @@ public class TaskViewThumbnail extends View {
    }

    /**
     * Sets the scale of the bitmap relative to this view.
     * Updates the scale of the bitmap relative to this view.
     */
    public void setBitmapScale(float scale) {
    public void updateThumbnailScale() {
        if (mBitmapShader != null) {
            mBitmapScale = scale;
            mScaleMatrix.setScale(mBitmapScale, mBitmapScale);
            float thumbnailScale;
            if (!mTask.isFreeformTask() || mTask.bounds == null) {
                // If this is a stack task, or a stack task moved into the freeform workspace, then
                // just scale this thumbnail to fit the width of the view
                thumbnailScale = (float) mTaskViewRect.width() / mThumbnailRect.width();
            } else {
                // Otherwise, if this is a freeform task with task bounds, then scale the thumbnail
                // to fit the entire bitmap into the task bounds
                thumbnailScale = Math.min(
                        (float) mTaskViewRect.width() / mThumbnailRect.width(),
                        (float) mTaskViewRect.height() / mThumbnailRect.height());
            }
            mScaleMatrix.setScale(thumbnailScale, thumbnailScale);
            mBitmapShader.setLocalMatrix(mScaleMatrix);
        }
        if (!mInvisible) {
@@ -164,10 +168,6 @@ public class TaskViewThumbnail extends View {
        }
    }

    public float getBitmapScale() {
        return mBitmapScale;
    }

    /** Updates the clip rect based on the given task bar. */
    void updateClipToTaskBar(View taskBar) {
        mTaskBar = taskBar;
@@ -200,6 +200,7 @@ public class TaskViewThumbnail extends View {

    /** Binds the thumbnail view to the task */
    void rebindToTask(Task t) {
        mTask = t;
        if (t.thumbnail != null) {
            setThumbnail(t.thumbnail);
        } else {
@@ -209,6 +210,7 @@ public class TaskViewThumbnail extends View {

    /** Unbinds the thumbnail view from the task */
    void unbindFromTask() {
        mTask = null;
        setThumbnail(null);
    }
}
+0 −3
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ public class TaskViewTransform {
    public float translationZ = 0;
    public float scale = 1f;
    public float alpha = 1f;
    public float thumbnailScale = 1f;

    public boolean visible = false;
    float p = 0f;
@@ -101,7 +100,6 @@ public class TaskViewTransform {
        translationZ = 0;
        scale = 1f;
        alpha = 1f;
        thumbnailScale = 1f;
        visible = false;
        rect.setEmpty();
        p = 0f;
@@ -188,6 +186,5 @@ public class TaskViewTransform {
        v.setAlpha(1f);
        v.getViewBounds().setClipBottom(0);
        v.setLeftTopRightBottom(0, 0, 0, 0);
        v.mThumbnailView.setBitmapScale(1f);
    }
}