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

Commit 255887cc authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Taskbar should animate immediately when tapping a live tile" into sc-v2-dev

parents f006d37a ae0c16dd
Loading
Loading
Loading
Loading
+41 −26
Original line number Diff line number Diff line
@@ -38,9 +38,9 @@ import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.recents.model.ThumbnailData;


/**
 * A data source which integrates with a Launcher instance
 */
@@ -159,8 +159,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
     *                 automatically reset once the recents animation finishes
     */
    public Animator createAnimToLauncher(@NonNull LauncherState toState,
            @NonNull RecentsAnimationCallbacks callbacks,
            long duration) {
            @NonNull RecentsAnimationCallbacks callbacks, long duration) {
        TaskbarStashController stashController = mControllers.taskbarStashController;
        ObjectAnimator animator = mIconAlignmentForGestureState
                .animateToValue(1)
@@ -180,31 +179,15 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
                stashController.animateToIsStashed(false, duration);
            }
        });
        callbacks.addListener(new RecentsAnimationListener() {
            @Override
            public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
                endGestureStateOverride(true);
            }

            @Override
            public void onRecentsAnimationFinished(RecentsAnimationController controller) {
                endGestureStateOverride(!controller.getFinishTargetIsLauncher());
            }

            private void endGestureStateOverride(boolean finishedToApp) {
                callbacks.removeListener(this);
                mIsAnimatingToLauncherViaGesture = false;

                mIconAlignmentForGestureState
                        .animateToValue(0)
                        .start();

                if (finishedToApp) {
                    // We only need this for the exiting live tile case.
                    stashController.animateToIsStashed(stashController.isStashedInApp());
                }
            }
        TaskBarRecentsAnimationListener listener = new TaskBarRecentsAnimationListener(callbacks);
        callbacks.addListener(listener);
        RecentsView recentsView = mLauncher.getOverviewPanel();
        recentsView.setTaskLaunchListener(() -> {
            listener.endGestureStateOverride(true);
            callbacks.removeListener(listener);
        });

        return animator;
    }

@@ -249,4 +232,36 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        mIconAlphaForHome.setValue(isVisible ? 1 : 0);
        mLauncher.getHotseat().setIconsAlpha(isVisible ? 0f : 1f);
    }

    private final class TaskBarRecentsAnimationListener implements RecentsAnimationListener {
        private final RecentsAnimationCallbacks mCallbacks;

        TaskBarRecentsAnimationListener(RecentsAnimationCallbacks callbacks) {
            mCallbacks = callbacks;
        }

        @Override
        public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
            endGestureStateOverride(true);
        }

        @Override
        public void onRecentsAnimationFinished(RecentsAnimationController controller) {
            endGestureStateOverride(!controller.getFinishTargetIsLauncher());
        }

        private void endGestureStateOverride(boolean finishedToApp) {
            mCallbacks.removeListener(this);
            mIsAnimatingToLauncherViaGesture = false;

            mIconAlignmentForGestureState
                    .animateToValue(0)
                    .start();

            TaskbarStashController controller = mControllers.taskbarStashController;
            if (finishedToApp) {
                controller.animateToIsStashed(controller.isStashedInApp());
            }
        }
    }
}
+20 −0
Original line number Diff line number Diff line
@@ -602,6 +602,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
            };

    private RunnableList mSideTaskLaunchCallback;
    private TaskLaunchListener mTaskLaunchListener;

    public RecentsView(Context context, AttributeSet attrs, int defStyleAttr,
            BaseActivityInterface sizeStrategy) {
@@ -882,6 +883,21 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        mSideTaskLaunchCallback.add(callback::executeAllAndDestroy);
    }

    /**
     * This is a one-time callback when touching in live tile mode. It's reset to null right
     * after it's called.
     */
    public void setTaskLaunchListener(TaskLaunchListener taskLaunchListener) {
        mTaskLaunchListener = taskLaunchListener;
    }

    public void onTaskLaunchedInLiveTileMode() {
        if (mTaskLaunchListener != null) {
            mTaskLaunchListener.onTaskLaunched();
            mTaskLaunchListener = null;
        }
    }

    private void executeSideTaskLaunchCallback() {
        if (mSideTaskLaunchCallback != null) {
            mSideTaskLaunchCallback.executeAllAndDestroy();
@@ -4210,4 +4226,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        // Set locus context is a binder call, don't want it to happen during a transition
        UI_HELPER_EXECUTOR.post(() -> mActivity.setLocusContext(id, Bundle.EMPTY));
    }

    public interface TaskLaunchListener {
        void onTaskLaunched();
    }
}
+6 −3
Original line number Diff line number Diff line
@@ -584,6 +584,7 @@ public class TaskView extends FrameLayout implements Reusable {
                }
            });
            anim.start();
            recentsView.onTaskLaunchedInLiveTileMode();
        } else {
            launchTaskAnimated();
        }
@@ -614,12 +615,14 @@ public class TaskView extends FrameLayout implements Reusable {
            ActivityOptionsWrapper opts =  mActivity.getActivityLaunchOptions(this, null);
            if (ActivityManagerWrapper.getInstance()
                    .startActivityFromRecents(mTask.key, opts.options)) {
                if (ENABLE_QUICKSTEP_LIVE_TILE.get() &&
                        getRecentsView().getRunningTaskViewId() != -1) {
                RecentsView recentsView = getRecentsView();
                if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskViewId() != -1) {
                    recentsView.onTaskLaunchedInLiveTileMode();

                    // Return a fresh callback in the live tile case, so that it's not accidentally
                    // triggered by QuickstepTransitionManager.AppLaunchAnimationRunner.
                    RunnableList callbackList = new RunnableList();
                    getRecentsView().addSideTaskLaunchCallback(callbackList);
                    recentsView.addSideTaskLaunchCallback(callbackList);
                    return callbackList;
                }
                return opts.onEndCallback;