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

Commit 33da74f8 authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "focusTransitionScaleAndDimOut should always go from 1f to 0f" into main

parents e29e3192 c378e64b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ private constructor(
    private val disappearanceDurationMs: Long,
    private val interpolator: Interpolator,
) {
    private val borderAnimationProgress = AnimatedFloat { updateOutline() }
    private val borderAnimationProgress = AnimatedFloat { _ -> updateOutline() }
    private val borderPaint =
        Paint(Paint.ANTI_ALIAS_FLAG).apply {
            color = borderColor
@@ -224,6 +224,7 @@ private constructor(

        val borderWidth: Float
            get() = borderWidthPx * animationProgress

        val alignmentAdjustment: Float
            // Outset the border by half the width to create an outwards-growth animation
            get() = -borderWidth / 2f + alignmentAdjustmentInset
+1 −1
Original line number Diff line number Diff line
@@ -3816,7 +3816,7 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
                    anim.setFloat(taskView, taskView.getSecondaryDismissTranslationProperty(),
                            secondaryTranslation, clampToProgress(LINEAR, animationStartProgress,
                                    dismissTranslationInterpolationEnd));
                    anim.setFloat(taskView, TaskView.SCALE_AND_DIM_OUT, 0f,
                    anim.add(taskView.getFocusTransitionScaleAndDimOutAnimator(),
                            clampToProgress(LINEAR, 0f, ANIMATION_DISMISS_PROGRESS_MIDPOINT));
                } else {
                    float primaryTranslation =
+10 −19
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.launcher3.Flags.enableOverviewIconMenu
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.anim.AnimatedFloat
import com.android.launcher3.config.FeatureFlags.ENABLE_KEYBOARD_QUICK_SWITCH
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
import com.android.launcher3.model.data.ItemInfo
@@ -419,17 +420,17 @@ constructor(
        focusTransitionPropertyFactory.get(FOCUS_TRANSITION_INDEX_FULLSCREEN)
    private val focusTransitionScaleAndDim =
        focusTransitionPropertyFactory.get(FOCUS_TRANSITION_INDEX_SCALE_AND_DIM)

    /**
     * Variant of [focusTransitionScaleAndDim] that has a built-in interpolator, to be used with
     * [com.android.launcher3.anim.PendingAnimation] via [SCALE_AND_DIM_OUT] only. PendingAnimation
     * doesn't support interpolator per animation, so we'll have to interpolate inside the property.
     * Returns an animator of [focusTransitionScaleAndDim] that transition out with a built-in
     * interpolator.
     */
    private var focusTransitionScaleAndDimOut = focusTransitionScaleAndDim.value
        set(value) {
            field = value
    fun getFocusTransitionScaleAndDimOutAnimator(): ObjectAnimator =
        AnimatedFloat { v ->
                focusTransitionScaleAndDim.value =
                FOCUS_TRANSITION_FAST_OUT_INTERPOLATOR.getInterpolation(field)
                    FOCUS_TRANSITION_FAST_OUT_INTERPOLATOR.getInterpolation(v)
            }
            .animateToValue(1f, 0f)

    private var iconAndDimAnimator: ObjectAnimator? = null
    // The current background requests to load the task thumbnail and icon
@@ -1615,16 +1616,6 @@ constructor(
                override fun get(taskView: TaskView) = taskView.focusTransitionProgress
            }

        @JvmField
        val SCALE_AND_DIM_OUT: FloatProperty<TaskView> =
            object : FloatProperty<TaskView>("scaleAndDimFastOut") {
                override fun setValue(taskView: TaskView, v: Float) {
                    taskView.focusTransitionScaleAndDimOut = v
                }

                override fun get(taskView: TaskView) = taskView.focusTransitionScaleAndDimOut
            }

        private val SPLIT_SELECT_TRANSLATION_X: FloatProperty<TaskView> =
            object : FloatProperty<TaskView>("splitSelectTranslationX") {
                override fun setValue(taskView: TaskView, v: Float) {
+14 −3
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.util.FloatProperty;

import java.util.function.Consumer;

/**
 * A mutable float which allows animating the value
 */
@@ -38,9 +40,9 @@ public class AnimatedFloat {
                }
            };

    private static final Runnable NO_OP = () -> { };
    private static final Consumer<Float> NO_OP = t -> { };

    private final Runnable mUpdateCallback;
    private final Consumer<Float> mUpdateCallback;
    private ObjectAnimator mValueAnimator;
    // Only non-null when an animation is playing to this value.
    private Float mEndValue;
@@ -52,6 +54,10 @@ public class AnimatedFloat {
    }

    public AnimatedFloat(Runnable updateCallback) {
        this(v -> updateCallback.run());
    }

    public AnimatedFloat(Consumer<Float> updateCallback) {
        mUpdateCallback = updateCallback;
    }

@@ -60,6 +66,11 @@ public class AnimatedFloat {
        value = initialValue;
    }

    public AnimatedFloat(Consumer<Float> updateCallback, float initialValue) {
        this(updateCallback);
        value = initialValue;
    }

    /**
     * Returns an animation from the current value to the given value.
     */
@@ -99,7 +110,7 @@ public class AnimatedFloat {
    public void updateValue(float v) {
        if (Float.compare(v, value) != 0) {
            value = v;
            mUpdateCallback.run();
            mUpdateCallback.accept(value);
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -59,6 +59,13 @@ public class PendingAnimation extends AnimatedPropertySetter {
        add(anim, springProperty);
    }

    /**
     * Utility method to sent an interpolator on an animation and add it to the list
     */
    public void add(Animator anim, TimeInterpolator interpolator) {
        add(anim, interpolator, SpringProperty.DEFAULT);
    }

    @Override
    public void add(Animator anim) {
        add(anim, SpringProperty.DEFAULT);