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

Commit a75f5768 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Exposing AnimatorListeners in StateManager to receive both success and failure callback

Updating various callers to use onSuccess or onEnd appropriately

Test: Manual
Bug: 185554764
Change-Id: I357dd1fdbe111e7a30d4c8dee520fbd7d9956b7d
parent b1754bfc
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3.hybridhotseat;


import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.hybridhotseat.HotseatEduController.getSettingsIntent;
import static com.android.launcher3.hybridhotseat.HotseatEduController.getSettingsIntent;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_PREDICTION_PINNED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_PREDICTION_PINNED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_RANKED;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_RANKED;
@@ -150,7 +151,7 @@ public class HotseatPredictionController implements DragController.DragListener,
     * Shows appropriate hotseat education based on prediction enabled and migration states.
     * Shows appropriate hotseat education based on prediction enabled and migration states.
     */
     */
    public void showEdu() {
    public void showEdu() {
        mLauncher.getStateManager().goToState(NORMAL, true, () -> {
        mLauncher.getStateManager().goToState(NORMAL, true, forSuccessCallback(() -> {
            if (mPredictedItems.isEmpty()) {
            if (mPredictedItems.isEmpty()) {
                // launcher has empty predictions set
                // launcher has empty predictions set
                Snackbar.show(mLauncher, R.string.hotsaet_tip_prediction_disabled,
                Snackbar.show(mLauncher, R.string.hotsaet_tip_prediction_disabled,
@@ -165,7 +166,7 @@ public class HotseatPredictionController implements DragController.DragListener,
                        .collect(Collectors.toList()));
                        .collect(Collectors.toList()));
                eduController.showEdu();
                eduController.showEdu();
            }
            }
        });
        }));
    }
    }


    /**
    /**
@@ -255,8 +256,8 @@ public class HotseatPredictionController implements DragController.DragListener,
            }
            }
        }
        }
        if (animate) {
        if (animate) {
            animationSet.addListener(AnimationSuccessListener
            animationSet.addListener(
                    .forRunnable(this::removeOutlineDrawings));
                    forSuccessCallback(this::removeOutlineDrawings));
            animationSet.start();
            animationSet.start();
        } else {
        } else {
            removeOutlineDrawings();
            removeOutlineDrawings();
+2 −2
Original line number Original line Diff line number Diff line
@@ -35,7 +35,7 @@ import androidx.annotation.NonNull;


import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.states.StateAnimationConfig;
@@ -78,7 +78,7 @@ public final class RecentsViewStateController extends
            mRecentsView.updateEmptyMessage();
            mRecentsView.updateEmptyMessage();
        } else {
        } else {
            builder.addListener(
            builder.addListener(
                    AnimationSuccessListener.forRunnable(mRecentsView::resetTaskVisuals));
                    AnimatorListeners.forSuccessCallback(mRecentsView::resetTaskVisuals));
        }
        }


        // Create or dismiss split screen select animations
        // Create or dismiss split screen select animations
+4 −3
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.launcher3.LauncherAnimUtils.newCancelListener;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU;
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
@@ -38,7 +39,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.anim.PendingAnimation;
@@ -199,7 +200,7 @@ public class NavBarToHomeTouchController implements TouchController,
                        .animateWithVelocity(velocity);
                        .animateWithVelocity(velocity);
            } else {
            } else {
                mLauncher.getStateManager().goToState(mEndState, true,
                mLauncher.getStateManager().goToState(mEndState, true,
                        () -> onSwipeInteractionCompleted(mEndState));
                        forEndCallback(() -> onSwipeInteractionCompleted(mEndState)));
            }
            }
            if (mStartState != mEndState) {
            if (mStartState != mEndState) {
                logHomeGesture();
                logHomeGesture();
@@ -214,7 +215,7 @@ public class NavBarToHomeTouchController implements TouchController,
            // Quickly return to the state we came from (we didn't move far).
            // Quickly return to the state we came from (we didn't move far).
            ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
            ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
            anim.setFloatValues(progress, 0);
            anim.setFloatValues(progress, 0);
            anim.addListener(AnimationSuccessListener.forRunnable(
            anim.addListener(AnimatorListeners.forSuccessCallback(
                    () -> onSwipeInteractionCompleted(mStartState)));
                    () -> onSwipeInteractionCompleted(mStartState)));
            anim.setDuration(80).start();
            anim.setDuration(80).start();
        }
        }
+3 −2
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
@@ -172,13 +173,13 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
        }
        }
        mNormalToHintOverviewScrimAnimator = null;
        mNormalToHintOverviewScrimAnimator = null;
        mCurrentAnimation.getTarget().addListener(newCancelListener(() ->
        mCurrentAnimation.getTarget().addListener(newCancelListener(() ->
                mLauncher.getStateManager().goToState(OVERVIEW, true, () -> {
                mLauncher.getStateManager().goToState(OVERVIEW, true, forSuccessCallback(() -> {
                    mOverviewResistYAnim = AnimatorControllerWithResistance
                    mOverviewResistYAnim = AnimatorControllerWithResistance
                            .createRecentsResistanceFromOverviewAnim(mLauncher, null)
                            .createRecentsResistanceFromOverviewAnim(mLauncher, null)
                            .createPlaybackController();
                            .createPlaybackController();
                    mReachedOverview = true;
                    mReachedOverview = true;
                    maybeSwipeInteractionToOverviewComplete();
                    maybeSwipeInteractionToOverviewComplete();
                })));
                }))));


        mCurrentAnimation.getTarget().removeListener(mClearStateOnCancelListener);
        mCurrentAnimation.getTarget().removeListener(mClearStateOnCancelListener);
        mCurrentAnimation.dispatchOnCancel();
        mCurrentAnimation.dispatchOnCancel();
+2 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS;
import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS;
import static com.android.launcher3.LauncherState.QUICK_SWITCH;
import static com.android.launcher3.LauncherState.QUICK_SWITCH;
import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD;
import static com.android.launcher3.anim.AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
import static com.android.launcher3.anim.Interpolators.ACCEL_0_75;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -418,7 +419,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
                        targetState.ordinal > mStartState.ordinal
                        targetState.ordinal > mStartState.ordinal
                                ? LAUNCHER_UNKNOWN_SWIPEUP
                                ? LAUNCHER_UNKNOWN_SWIPEUP
                                : LAUNCHER_UNKNOWN_SWIPEDOWN));
                                : LAUNCHER_UNKNOWN_SWIPEDOWN));
        mLauncher.getStateManager().goToState(targetState, false, this::clearState);
        mLauncher.getStateManager().goToState(targetState, false, forEndCallback(this::clearState));
    }
    }


    private void cancelAnimations() {
    private void cancelAnimations() {
Loading