summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ats Jenk <atsjenk@google.com> 2025-03-18 17:10:25 -0700
committer Ats Jenk <atsjenk@google.com> 2025-03-19 09:49:54 -0700
commit25e28ec42118f3b3dc8ebc5372c1037aba7dfa30 (patch)
tree0167701f21270359b96ccd084139ecaa9ddd5e25
parent34f9f07edf00f62d54803c60a5c30af678e33195 (diff)
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
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/animation/SizeChangeAnimation.java6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java2
2 files changed, 7 insertions, 1 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/SizeChangeAnimation.java b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/SizeChangeAnimation.java
index 8e78686ac13d..44b1608f03ce 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/SizeChangeAnimation.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/SizeChangeAnimation.java
@@ -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);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java
index fa22a3961002..134178b184c0 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java
@@ -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();
}