From 5dfcbf1bb145538e61fe3e213ba82b40d35535ba Mon Sep 17 00:00:00 2001 From: Charlie Anderson Date: Wed, 30 Apr 2025 14:53:07 -0400 Subject: [PATCH] Fix folder close animation from jumping by initializing animation manager correctly. Bug: 414528208 Test: creating new folder and opening/closing Flag: EXEMPT bugfix Change-Id: Ic9b587d170804297e6e67d673059c8a839d409bc --- src/com/android/launcher3/folder/Folder.java | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 2452f8ab21..4f7565b652 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -205,7 +205,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo // use mActivityContext. protected LauncherDelegate mLauncherDelegate; protected final ActivityContext mActivityContext; - protected FolderAnimationCreator mOpenCloseAnimationManager; public FolderInfo mInfo; private CharSequence mFromTitle; @@ -606,17 +605,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo replaceFolderWithFinalItem(); } }); - boolean shouldUseSpringMotion = Flags.enableLauncherIconShapes() - && Flags.enableExpressiveFolderExpansion(); - if (shouldUseSpringMotion) { - ShapeDelegate shapeDelegate = - ThemeManager.INSTANCE.get(mActivityContext.asContext()).getFolderShape(); - mOpenCloseAnimationManager = new FolderAnimationSpringBuilderManager( - this, shapeDelegate, mLauncherDelegate - ); - } else { - mOpenCloseAnimationManager = new FolderAnimationManager(this); - } } public void reapplyItemInfo() { @@ -802,7 +790,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo Log.d("b/383526431", "animateOpen: content child count after cancelling" + " animation: " + mContent.getTotalChildCount()); - AnimatorSet animatorSet = mOpenCloseAnimationManager.createAnimatorSet(true); + AnimatorSet animatorSet = getFolderAnimationManager() + .createAnimatorSet(/* isOpening */ true); animatorSet.addListener(new AnimatorListenerAdapter() { @Override @@ -888,6 +877,20 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo return true; } + private FolderAnimationCreator getFolderAnimationManager() { + boolean shouldUseSpringMotion = Flags.enableLauncherIconShapes() + && Flags.enableExpressiveFolderExpansion(); + if (shouldUseSpringMotion) { + ShapeDelegate shapeDelegate = + ThemeManager.INSTANCE.get(mActivityContext.asContext()).getFolderShape(); + return new FolderAnimationSpringBuilderManager( + this, shapeDelegate, mLauncherDelegate + ); + } else { + return new FolderAnimationManager(this); + } + } + /** * If there's a folder already open, we want to close it before opening another one. */ @@ -959,7 +962,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mContent.snapToPageImmediately(mContent.getDestinationPage()); cancelRunningAnimations(); - AnimatorSet animatorSet = mOpenCloseAnimationManager.createAnimatorSet(false); + AnimatorSet animatorSet = getFolderAnimationManager() + .createAnimatorSet(/* isOpening */ false); animatorSet.addListener(new AnimatorListenerAdapter() { @Override