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
This commit is contained in:
Charlie Anderson
2025-04-30 14:53:07 -04:00
parent 7103e478b3
commit 5dfcbf1bb1
+18 -14
View File
@@ -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