Fix Launcher icons not animated during unfold

If icons are re-bound during the animation, they were not moved. I was able to reproduce this case 100% of times by folding, restarting launcher and unfolding. From a perfetto trace it seems that in this case `finishBindingItems` was called after the animation already started, therefore not registering any view.

With this cl, items are animated also after they are rebound.

Bug: 197834977
Test: folded -> restarted launcher -> unfolded -> verified icons are now moving towards the center
Change-Id: I5b001c502860c17d6ea5d54d099f04b2ddf1820a
This commit is contained in:
Nicolo' Mazzucato
2022-02-16 17:30:48 +01:00
parent e424f57dcb
commit d4a5bb244a
3 changed files with 52 additions and 11 deletions
@@ -65,6 +65,7 @@ import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.ObjectWrapper;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.OverviewCommandHelper;
@@ -496,6 +497,20 @@ public abstract class BaseQuickstepLauncher extends Launcher
WellbeingModel.INSTANCE.get(this);
}
@Override
public void onInitialBindComplete(IntSet boundPages, RunnableList pendingTasks) {
pendingTasks.add(() -> {
// This is added in pending task as we need to wait for views to be positioned
// correctly before registering them for the animation.
if (mLauncherUnfoldAnimationController != null) {
// This is needed in case items are rebound while the unfold animation is in
// progress.
mLauncherUnfoldAnimationController.updateRegisteredViewsIfNeeded();
}
});
super.onInitialBindComplete(boundPages, pendingTasks);
}
@Override
public Stream<SystemShortcut.Factory> getSupportedShortcuts() {
Stream<SystemShortcut.Factory> base = Stream.of(WellbeingModel.SHORTCUT_FACTORY);