From ea06691a37ec5ba3f80c335f48c61ee703be65bb Mon Sep 17 00:00:00 2001 From: Charlie Anderson Date: Fri, 19 Sep 2025 10:24:03 -0400 Subject: [PATCH] Convert BubbleTextView Alpha to use spring animation Flag: com.android.launcher3.enable_expressive_folder_expansion Bug: 387543793 Test: Manually verifying Change-Id: Ibadedb1fef2542a4b8373ab3a4557c10c8752a77 --- src/com/android/launcher3/BubbleTextView.java | 7 +++--- .../folder/FolderSpringAnimatorSet.kt | 24 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 44ff7e6a0f..ad2834b683 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -62,6 +62,7 @@ import android.text.TextUtils; import android.text.TextUtils.TruncateAt; import android.text.style.ImageSpan; import android.util.AttributeSet; +import android.util.FloatProperty; import android.util.Log; import android.util.Property; import android.util.TypedValue; @@ -169,15 +170,15 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } }; - public static final Property TEXT_ALPHA_PROPERTY - = new Property(Float.class, "textAlpha") { + public static final FloatProperty TEXT_ALPHA_PROPERTY + = new FloatProperty("textAlpha") { @Override public Float get(BubbleTextView bubbleTextView) { return bubbleTextView.mTextAlpha; } @Override - public void set(BubbleTextView bubbleTextView, Float alpha) { + public void setValue(BubbleTextView bubbleTextView, float alpha) { bubbleTextView.setTextAlpha(alpha); } }; diff --git a/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt b/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt index 13cd3a6e53..8998852a55 100644 --- a/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt +++ b/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt @@ -82,7 +82,7 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { return FolderSpringAnimatorSet(animatorSet) } - private fun playSpringAnimation( + private fun playSpringAnimation( context: Context, animatorSet: AnimatorSet, isOpening: Boolean, @@ -92,8 +92,8 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { startValue: Float, endValue: Float, minVisibleChange: Float, - property: Property, - view: View, + property: Property, + view: T, ) { val animatorBuilder = SpringAnimationBuilder(context) @@ -398,11 +398,19 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { if (isOpening) { titleText.setTextVisibility(false) } - val anim = - titleText.createTextAlphaAnimator(isOpening).apply { - startDelay = (if (isOpening) iconDelay + 100 else iconDelay).toLong() - } - animatorSet.play(anim) + playSpringAnimation( + context = context, + animatorSet = animatorSet, + isOpening = isOpening, + startDelay = if (isOpening) iconDelay + 100 else iconDelay, + stiffness = STIFFNESS_ALPHA, + damping = DAMPING_ALPHA, + startValue = 0f, + endValue = 1f, + minVisibleChange = MIN_VISIBLE_CHANGE_ALPHA, + property = BubbleTextView.TEXT_ALPHA_PROPERTY, + view = titleText, + ) if (!itemsInPreview.contains(icon)) { playSpringAnimation( context = context,