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

Commit 25e28ec4 authored by Ats Jenk's avatar Ats Jenk
Browse files

Fix issue with applying interpolators twice

SizeChangeAnimation internally uses view animations on a timeline of
1000ms. These view animations are driven by a ValueAnimator that is
returned to callers of SizeChangeAnimation. This ValueAnimator defines
the actual duration of the animation and can be used to define an
interpolator.
But there is an issue with applying interpolators to the ValueAnimator.
The internal view animations also have their own interpolator set. They
don't override the default and by default they use
accelerate/decelerate.
This means that we are applying two interpolators to the animation
curve: whatever is applied to the ValueAnimator + accelerate/decelerate.
Resulting in the animation curve not matching with what is expected.

Fixing this by ensuring that the internal view animations use a linear
interpolator. This allows the animation curve to be only controlled by
the ValueAnimator. Giving control to callers of SizeChangeAnimation to
define the animation timings.

Bug: 403659671
Test: manual, check the animation, log out animted values and check
  against a known correct animation curve
Flag: com.android.wm.shell.enable_bubble_to_fullscreen

Change-Id: Idf20bf7fd9a43f5e9fa4c3d2b9a41480a3dc33dd
parent 34f9f07e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import android.view.animation.ScaleAnimation;
import android.view.animation.Transformation;
import android.view.animation.TranslateAnimation;

import com.android.wm.shell.shared.animation.Interpolators;

import java.util.function.Consumer;

/**
@@ -182,6 +184,8 @@ public class SizeChangeAnimation {
        float startScaleY = SCALE_FACTOR * ((float) startBounds.height()) / endBounds.height()
                + (1.f - SCALE_FACTOR);
        final AnimationSet animSet = new AnimationSet(true);
        // Use a linear interpolator so the driving ValueAnimator sets the interpolation
        animSet.setInterpolator(Interpolators.LINEAR);

        final Animation scaleAnim = new ScaleAnimation(startScaleX, 1, startScaleY, 1);
        scaleAnim.setDuration(scalePeriod);
@@ -229,6 +233,8 @@ public class SizeChangeAnimation {
                + (1.f - SCALE_FACTOR));

        AnimationSet snapAnimSet = new AnimationSet(true);
        // Use a linear interpolator so the driving ValueAnimator sets the interpolation
        snapAnimSet.setInterpolator(Interpolators.LINEAR);
        // Animation for the "old-state" snapshot that is atop the task.
        final Animation snapAlphaAnim = new AlphaAnimation(1.f, 0.f);
        snapAlphaAnim.setDuration(scalePeriod);
+1 −1
Original line number Diff line number Diff line
@@ -615,7 +615,7 @@ public class BubbleBarAnimationHelper {

        bbev.setSurfaceZOrderedOnTop(true);
        a.setDuration(EXPANDED_VIEW_ANIMATE_TO_REST_DURATION);
        a.setInterpolator(Interpolators.EMPHASIZED);
        a.setInterpolator(EMPHASIZED);
        a.start();
    }