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

Commit 596594c6 authored by Jagrut Desai's avatar Jagrut Desai
Browse files

Fix launching app animation from launcher all apps.

This cl includes
	- making pinned taskbar animate slide in/out animation from bottom of screen.
        - no icon aligment with hotseat when taksbar is pinned

The solution
	- upon state change applied on TaskbarLauncherStateController. offset taskbar background and icons to bottom of screeen and animate with slide in/out effects.

Test: manual, presubmit
Bug: 314279101
Flag: EXEMPT bugfix

Change-Id: Ife336ebd57eb2f60c2bc33ed6a4527c42111808f
parent 6f10fb57
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener

    public static final int CONTENT_ALPHA_DURATION = 217;
    public static final int TRANSIENT_TASKBAR_TRANSITION_DURATION = 417;
    public static final int PINNED_TASKBAR_TRANSITION_DURATION = 600;
    public static final int TASKBAR_TO_APP_DURATION = 600;
    // TODO(b/236145847): Tune TASKBAR_TO_HOME_DURATION to 383 after conflict with unlock animation
    // is solved.
@@ -1726,8 +1727,21 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
        return new AnimatorBackState(rectFSpringAnim, anim);
    }

    public static int getTaskbarToHomeDuration() {
        if (enableScalingRevealHomeAnimation()) {
    /** Get animation duration for taskbar for going to home. */
    public static int getTaskbarToHomeDuration(boolean isPinnedTaskbar) {
        return getTaskbarToHomeDuration(false, isPinnedTaskbar);
    }

    /**
     * Get animation duration for taskbar for going to home.
     *
     * @param shouldOverrideToFastAnimation should overwrite scaling reveal home animation duration
     */
    public static int getTaskbarToHomeDuration(boolean shouldOverrideToFastAnimation,
            boolean isPinnedTaskbar) {
        if (isPinnedTaskbar) {
            return PINNED_TASKBAR_TRANSITION_DURATION;
        } else if (enableScalingRevealHomeAnimation() && !shouldOverrideToFastAnimation) {
            return TASKBAR_TO_HOME_DURATION_SLOW;
        } else {
            return TASKBAR_TO_HOME_DURATION_FAST;
+6 −2
Original line number Diff line number Diff line
@@ -210,8 +210,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
    }

    private int getTaskbarAnimationDuration(boolean isVisible) {
        if (isVisible && !mLauncher.getPredictiveBackToHomeInProgress()) {
            return getTaskbarToHomeDuration();
        // fast animation duration since we will not be playing workspace reveal animation.
        boolean shouldOverrideToFastAnimation =
                !isHotseatIconOnTopWhenAligned() || mLauncher.getPredictiveBackToHomeInProgress();
        boolean isPinnedTaskbar = DisplayController.isPinnedTaskbar(mLauncher);
        if (isVisible || isPinnedTaskbar) {
            return getTaskbarToHomeDuration(shouldOverrideToFastAnimation, isPinnedTaskbar);
        } else {
            return DisplayController.isTransientTaskbar(mLauncher)
                    ? TRANSIENT_TASKBAR_TRANSITION_DURATION
+86 −15
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3.taskbar;

import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.app.animation.Interpolators.FINAL_FRAME;
import static com.android.app.animation.Interpolators.INSTANT;
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_ALIGNMENT;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_STASH;
@@ -222,7 +223,9 @@ public class TaskbarLauncherStateController {
                    updateStateForFlag(FLAG_LAUNCHER_IN_STATE_TRANSITION, true);
                    if (!mShouldDelayLauncherStateAnim) {
                        if (toState == LauncherState.NORMAL) {
                            applyState(QuickstepTransitionManager.getTaskbarToHomeDuration());
                            applyState(QuickstepTransitionManager.getTaskbarToHomeDuration(
                                    DisplayController.isPinnedTaskbar(
                                            mControllers.taskbarActivityContext)));
                        } else {
                            applyState();
                        }
@@ -459,9 +462,12 @@ public class TaskbarLauncherStateController {

    private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
        final boolean isInLauncher = isInLauncher();
        final boolean isInOverview = mControllers.uiController.isInOverviewUi();
        final boolean isIconAlignedWithHotseat = isIconAlignedWithHotseat();
        final float toAlignment = isIconAlignedWithHotseat ? 1 : 0;
        boolean handleOpenFloatingViews = false;
        boolean isPinnedTaskbar = DisplayController.isPinnedTaskbar(
                mControllers.taskbarActivityContext);
        if (DEBUG) {
            Log.d(TAG, "onStateChangeApplied - isInLauncher: " + isInLauncher
                    + ", mLauncherState: " + mLauncherState
@@ -573,10 +579,17 @@ public class TaskbarLauncherStateController {
        }

        float backgroundAlpha = isInLauncher && isTaskbarAlignedWithHotseat() ? 0 : 1;
        AnimatedFloat taskbarBgOffset =
                mControllers.taskbarDragLayerController.getTaskbarBackgroundOffset();
        boolean showTaskbar = !isInLauncher || isInOverview;
        float taskbarBgOffsetEnd = showTaskbar ? 0f : 1f;
        float taskbarBgOffsetStart = showTaskbar ? 1f : 0f;

        // Don't animate if background has reached desired value.
        if (mTaskbarBackgroundAlpha.isAnimating()
                || mTaskbarBackgroundAlpha.value != backgroundAlpha) {
                || mTaskbarBackgroundAlpha.value != backgroundAlpha
                || taskbarBgOffset.isAnimatingToValue(taskbarBgOffsetStart)
                || taskbarBgOffset.value != taskbarBgOffsetEnd) {
            mTaskbarBackgroundAlpha.cancelAnimation();
            if (DEBUG) {
                Log.d(TAG, "onStateChangeApplied - taskbarBackgroundAlpha - "
@@ -587,25 +600,35 @@ public class TaskbarLauncherStateController {
            boolean isInLauncherIconNotAligned = isInLauncher && !isIconAlignedWithHotseat;
            boolean notInLauncherIconNotAligned = !isInLauncher && !isIconAlignedWithHotseat;
            boolean isInLauncherIconIsAligned = isInLauncher && isIconAlignedWithHotseat;
            // When Hotseat icons are not on top don't change duration or add start delay.
            // This will keep the duration in sync for icon alignment and background fade in/out.
            // For example, launching app from launcher all apps.
            boolean isHotseatIconOnTopWhenAligned =
                    mControllers.uiController.isHotseatIconOnTopWhenAligned();

            float startDelay = 0;
            // We want to delay the background from fading in so that the icons have time to move
            // into the bounds of the background before it appears.
            if (isInLauncherIconNotAligned) {
                startDelay = duration * TASKBAR_BG_ALPHA_LAUNCHER_NOT_ALIGNED_DELAY_MULT;
            } else if (notInLauncherIconNotAligned) {
            } else if (notInLauncherIconNotAligned && isHotseatIconOnTopWhenAligned) {
                startDelay = duration * TASKBAR_BG_ALPHA_NOT_LAUNCHER_NOT_ALIGNED_DELAY_MULT;
            }
            float newDuration = duration - startDelay;
            if (isInLauncherIconIsAligned) {
            if (isInLauncherIconIsAligned && isHotseatIconOnTopWhenAligned) {
                // Make the background fade out faster so that it is gone by the time the
                // icons move outside of the bounds of the background.
                newDuration = duration * TASKBAR_BG_ALPHA_LAUNCHER_IS_ALIGNED_DURATION_MULT;
            }
            Animator taskbarBackgroundAlpha = mTaskbarBackgroundAlpha
                    .animateToValue(backgroundAlpha)
                    .setDuration((long) newDuration);
            Animator taskbarBackgroundAlpha = mTaskbarBackgroundAlpha.animateToValue(
                    backgroundAlpha);
            if (isPinnedTaskbar) {
                setupPinnedTaskbarAnimation(animatorSet, showTaskbar, taskbarBgOffset,
                        taskbarBgOffsetStart, taskbarBgOffsetEnd, duration, taskbarBackgroundAlpha);
            } else {
                taskbarBackgroundAlpha.setDuration((long) newDuration);
                taskbarBackgroundAlpha.setStartDelay((long) startDelay);
            }
            animatorSet.play(taskbarBackgroundAlpha);
        }

@@ -671,15 +694,18 @@ public class TaskbarLauncherStateController {
                        + mIconAlignment.value
                        + " -> " + toAlignment + ": " + duration);
            }
            if (!isPinnedTaskbar) {
                if (hasAnyFlag(FLAG_TASKBAR_HIDDEN)) {
                    iconAlignAnim.setInterpolator(FINAL_FRAME);
                } else {
                    animatorSet.play(iconAlignAnim);
                }
            }
        }

        Interpolator interpolator = enableScalingRevealHomeAnimation()
        Interpolator interpolator = enableScalingRevealHomeAnimation() && !isPinnedTaskbar
                ? ScalingWorkspaceRevealAnim.SCALE_INTERPOLATOR : EMPHASIZED;

        animatorSet.setInterpolator(interpolator);

        if (start) {
@@ -688,6 +714,49 @@ public class TaskbarLauncherStateController {
        return animatorSet;
    }

    private void setupPinnedTaskbarAnimation(AnimatorSet animatorSet, boolean showTaskbar,
            AnimatedFloat taskbarBgOffset, float taskbarBgOffsetStart, float taskbarBgOffsetEnd,
            long duration, Animator taskbarBackgroundAlpha) {
        float targetAlpha = !showTaskbar ? 1 : 0;
        mLauncher.getHotseat().setIconsAlpha(targetAlpha, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
        if (mIsQsbInline) {
            mLauncher.getHotseat().setQsbAlpha(targetAlpha,
                    ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
        }

        if ((taskbarBgOffset.value != taskbarBgOffsetEnd && !taskbarBgOffset.isAnimating())
                || taskbarBgOffset.isAnimatingToValue(taskbarBgOffsetStart)) {
            taskbarBgOffset.cancelAnimation();
            Animator taskbarIconAlpha = mTaskbarAlphaForHome.animateToValue(
                    showTaskbar ? 1f : 0f);
            AnimatedFloat taskbarIconTranslationYForHome =
                    mControllers.taskbarViewController.mTaskbarIconTranslationYForHome;
            ObjectAnimator taskbarBackgroundOffset = taskbarBgOffset.animateToValue(
                    taskbarBgOffsetStart,
                    taskbarBgOffsetEnd);
            ObjectAnimator taskbarIconsYTranslation = null;
            float taskbarHeight =
                    mControllers.taskbarActivityContext.getDeviceProfile().taskbarHeight;
            if (showTaskbar) {
                taskbarIconsYTranslation = taskbarIconTranslationYForHome.animateToValue(
                        taskbarHeight, 0);
            } else {
                taskbarIconsYTranslation = taskbarIconTranslationYForHome.animateToValue(0,
                        taskbarHeight);
            }

            taskbarIconAlpha.setDuration(duration);
            taskbarIconsYTranslation.setDuration(duration);
            taskbarBackgroundOffset.setDuration(duration);

            animatorSet.play(taskbarIconAlpha);
            animatorSet.play(taskbarIconsYTranslation);
            animatorSet.play(taskbarBackgroundOffset);
        }
        taskbarBackgroundAlpha.setInterpolator(showTaskbar ? INSTANT : FINAL_FRAME);
        taskbarBackgroundAlpha.setDuration(duration);
    }

    /**
     * Whether the taskbar is aligned with the hotseat in the current/target launcher state.
     *
@@ -950,7 +1019,8 @@ public class TaskbarLauncherStateController {
         *
         * @param finishedToApp {@code true} if the recents animation finished to showing an app and
         *                      not workspace or overview
         * @param canceled {@code true} if the recents animation was canceled instead of finishing
         * @param canceled      {@code true} if the recents animation was canceled instead of
         *                      finishing
         *                      to completion
         */
        private void endGestureStateOverride(boolean finishedToApp, boolean canceled) {
@@ -968,6 +1038,7 @@ public class TaskbarLauncherStateController {

    /**
     * Updates the visible state immediately to ensure a seamless handoff.
     *
     * @param finishedToApp True iff user is in an app.
     */
    private void updateStateForUserFinishedToApp(boolean finishedToApp) {
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.app.animation.Interpolators.INSTANT;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.internal.jank.InteractionJankMonitor.Configuration;
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.QuickstepTransitionManager.PINNED_TASKBAR_TRANSITION_DURATION;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_SHOW;
@@ -398,6 +399,9 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
     * Returns how long the stash/unstash animation should play.
     */
    public long getStashDuration() {
        if (DisplayController.isPinnedTaskbar(mActivity)) {
            return PINNED_TASKBAR_TRANSITION_DURATION;
        }
        return DisplayController.isTransientTaskbar(mActivity)
                ? TRANSIENT_TASKBAR_STASH_DURATION
                : TASKBAR_STASH_DURATION;
+3 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    private final TaskbarView mTaskbarView;
    private final MultiValueAlpha mTaskbarIconAlpha;
    private final AnimatedFloat mTaskbarIconScaleForStash = new AnimatedFloat(this::updateScale);
    private final AnimatedFloat mTaskbarIconTranslationYForHome = new AnimatedFloat(
    public final AnimatedFloat mTaskbarIconTranslationYForHome = new AnimatedFloat(
            this::updateTranslationY);
    private final AnimatedFloat mTaskbarIconTranslationYForStash = new AnimatedFloat(
            this::updateTranslationY);
@@ -796,6 +796,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
     */
    private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
        PendingAnimation setter = new PendingAnimation(100);
        // icon alignment not needed for pinned taskbar.
        if (DisplayController.isPinnedTaskbar(mActivity)) return setter.createPlaybackController();
        mOnControllerPreCreateCallback.run();
        DeviceProfile taskbarDp = mActivity.getDeviceProfile();
        Rect hotseatPadding = launcherDp.getHotseatLayoutPadding(mActivity);
Loading