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

Commit 3dc8e1a4 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Animate thumbnail dim after quick scrub settles" into ub-launcher3-master

parents a86c21b8 291bfd9c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -630,9 +630,9 @@ public abstract class RecentsView<T extends BaseActivity>
        TaskView firstTask = (TaskView) getChildAt(0);
        if (firstTask != null) {
            if (animate) {
                firstTask.animateIconToScale(scale);
                firstTask.animateIconToScaleAndDim(scale);
            } else {
                firstTask.setIconScale(scale);
                firstTask.setIconScaleAndDim(scale);
            }
        }
    }
+18 −1
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Property;
import android.view.View;

import com.android.launcher3.BaseActivity;
@@ -46,6 +48,19 @@ public class TaskThumbnailView extends View {

    private static final LightingColorFilter[] sDimFilterCache = new LightingColorFilter[256];

    public static final Property<TaskThumbnailView, Float> DIM_ALPHA =
            new FloatProperty<TaskThumbnailView>("dimAlpha") {
                @Override
                public void setValue(TaskThumbnailView thumbnail, float dimAlpha) {
                    thumbnail.setDimAlpha(dimAlpha);
                }

                @Override
                public Float get(TaskThumbnailView thumbnailView) {
                    return thumbnailView.mDimAlpha;
                }
            };

    private final float mCornerRadius;

    private final BaseActivity mActivity;
@@ -111,6 +126,8 @@ public class TaskThumbnailView extends View {

    /**
     * Sets the alpha of the dim layer on top of this view.
     *
     * If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be black.
     */
    public void setDimAlpha(float dimAlpha) {
        mDimAlpha = dimAlpha;
@@ -149,7 +166,7 @@ public class TaskThumbnailView extends View {
    }

    private void updateThumbnailPaintFilter() {
        int mul = (int) (mDimAlpha * 255);
        int mul = (int) ((1 - mDimAlpha) * 255);
        if (mBitmapShader != null) {
            LightingColorFilter filter = getLightingColorFilter(mul);
            mPaint.setColorFilter(filter);
+26 −3
Original line number Diff line number Diff line
@@ -16,6 +16,11 @@

package com.android.quickstep.views;

import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.ActivityOptions;
import android.content.Context;
@@ -75,6 +80,8 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
    private TaskThumbnailView mSnapshotView;
    private ImageView mIconView;
    private float mCurveScale;
    private float mCurveDimAlpha;
    private Animator mDimAlphaAnim;

    public TaskView(Context context) {
        this(context, null);
@@ -166,14 +173,27 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
        // Do nothing
    }

    public void animateIconToScale(float scale) {
    public void animateIconToScaleAndDim(float scale) {
        mIconView.animate().scaleX(scale).scaleY(scale).setDuration(SCALE_ICON_DURATION).start();
        mDimAlphaAnim = ObjectAnimator.ofFloat(mSnapshotView, DIM_ALPHA, scale * mCurveDimAlpha);
        mDimAlphaAnim.setDuration(SCALE_ICON_DURATION);
        mDimAlphaAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mDimAlphaAnim = null;
            }
        });
        mDimAlphaAnim.start();
    }

    protected void setIconScale(float iconScale) {
    protected void setIconScaleAndDim(float iconScale) {
        mIconView.animate().cancel();
        mIconView.setScaleX(iconScale);
        mIconView.setScaleY(iconScale);
        if (mDimAlphaAnim != null) {
            mDimAlphaAnim.cancel();
        }
        mSnapshotView.setDimAlpha(iconScale * mCurveDimAlpha);
    }

    public void resetVisualProperties() {
@@ -190,7 +210,10 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
        float curveInterpolation =
                CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation);

        mSnapshotView.setDimAlpha(1 - curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
        mCurveDimAlpha = curveInterpolation * MAX_PAGE_SCRIM_ALPHA;
        if (mDimAlphaAnim == null && mIconView.getScaleX() > 0) {
            mSnapshotView.setDimAlpha(mCurveDimAlpha);
        }

        mCurveScale = 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
        setScaleX(mCurveScale);