Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f922d35 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Fix recents animation flicker

The recents animation can sometimes start before launcher has started when started with 3-button mode. This causes the animation to start before the recents UI has been initialized by Launcher. Added a callback to properly synchronize launcher start and the recents animation.

Fixes: 229360539
Test: started the recents animation and checked logs (order of operations), when the recents animation or launcher started first
Change-Id: I5938bbba778a2886b4a1e4ee4844eaf28c6fac0e
parent bb44c03b
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -84,6 +84,8 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T

    private STATE_TYPE mTargetState;

    @Nullable private Runnable mOnInitBackgroundStateUICallback = null;

    protected BaseActivityInterface(boolean rotationSupportedByActivity,
            STATE_TYPE overviewState, STATE_TYPE backgroundState) {
        this.rotationSupportedByActivity = rotationSupportedByActivity;
@@ -408,6 +410,21 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
        return null;
    }

    protected void runOnInitBackgroundStateUI(Runnable callback) {
        mOnInitBackgroundStateUICallback = callback;
        ACTIVITY_TYPE activity = getCreatedActivity();
        if (activity != null && activity.getStateManager().getState() == mBackgroundState) {
            onInitBackgroundStateUI();
        }
    }

    private void onInitBackgroundStateUI() {
        if (mOnInitBackgroundStateUICallback != null) {
            mOnInitBackgroundStateUICallback.run();
            mOnInitBackgroundStateUICallback = null;
        }
    }

    public interface AnimationFactory {

        void createActivityInterface(long transitionLength);
@@ -447,13 +464,14 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
            mStartState = mActivity.getStateManager().getState();
        }

        protected ACTIVITY_TYPE initUI() {
        protected ACTIVITY_TYPE initBackgroundStateUI() {
            STATE_TYPE resetState = mStartState;
            if (mStartState.shouldDisableRestore()) {
                resetState = mActivity.getStateManager().getRestState();
            }
            mActivity.getStateManager().setRestState(resetState);
            mActivity.getStateManager().goToState(mBackgroundState, false);
            onInitBackgroundStateUI();
            return mActivity;
        }

+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public final class FallbackActivityInterface extends
            boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
        notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
        DefaultAnimationFactory factory = new DefaultAnimationFactory(callback);
        factory.initUI();
        factory.initBackgroundStateUI();
        return factory;
    }

+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public final class LauncherActivityInterface extends
            }
        };

        BaseQuickstepLauncher launcher = factory.initUI();
        BaseQuickstepLauncher launcher = factory.initBackgroundStateUI();
        // Since all apps is not visible, we can safely reset the scroll position.
        // This ensures then the next swipe up to all-apps starts from scroll 0.
        launcher.getAppsView().reset(false /* animate */);
+2 −1
Original line number Diff line number Diff line
@@ -217,7 +217,8 @@ public class OverviewCommandHelper {
            @Override
            public void onRecentsAnimationStart(RecentsAnimationController controller,
                    RecentsAnimationTargets targets) {
                interactionHandler.onGestureEnded(0, new PointF(), new PointF());
                activityInterface.runOnInitBackgroundStateUI(() ->
                        interactionHandler.onGestureEnded(0, new PointF(), new PointF()));
                cmd.removeListener(this);
            }

+5 −2
Original line number Diff line number Diff line
@@ -1280,13 +1280,16 @@ public class Launcher extends StatefulActivity<LauncherState>
     * @param info The data structure describing the shortcut.
     */
    View createShortcut(WorkspaceItemInfo info) {
        return createShortcut((ViewGroup) mWorkspace.getChildAt(mWorkspace.getCurrentPage()), info);
        // This can be called before PagedView#pageScrollsInitialized returns true, so use the
        // first page, which we always assume to be present.
        return createShortcut((ViewGroup) mWorkspace.getChildAt(0), info);
    }

    /**
     * Creates a view representing a shortcut inflated from the specified resource.
     *
     * @param parent The group the shortcut belongs to.
     * @param parent The group the shortcut belongs to. This is not necessarily the group where
     *               the shortcut should be added.
     * @param info   The data structure describing the shortcut.
     * @return A View inflated from layoutResId.
     */