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

Commit 86a4b653 authored by Jon Miranda's avatar Jon Miranda
Browse files

Add FLAG_DELAY_TASKBAR_BG_TAG to restrict when taskbar bg anim gets delayed.

We set it only when user swipes up to unstash.

Fixes: 360778703
Test: swipe up to home, long click on taskbar icon before it settles
Flag: com.android.launcher3.enable_scaling_reveal_home_animation
Change-Id: I24ff466ee6730e3739d85307363567cfa1455cbf
parent b41def03
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING;
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN;
import static com.android.launcher3.taskbar.TaskbarStashController.SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE;
import static com.android.launcher3.testing.shared.ResourceUtils.getBoolByName;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback;
@@ -1550,10 +1551,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {

    /**
     * Called when we want to unstash taskbar when user performs swipes up gesture.
     * @param delayTaskbarBackground whether we will delay the taskbar background animation
     */
    public void onSwipeToUnstashTaskbar() {
    public void onSwipeToUnstashTaskbar(boolean delayTaskbarBackground) {
        boolean wasStashed = mControllers.taskbarStashController.isStashed();
        mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(/* stash= */ false);
        mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(/* stash= */ false,
                SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE, delayTaskbarBackground);
        boolean isStashed = mControllers.taskbarStashController.isStashed();
        if (isStashed != wasStashed) {
            VibratorWrapper.INSTANCE.get(this).vibrateForTaskbarUnstash();
+56 −20
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    private static final String TAG = "TaskbarStashController";
    private static final boolean DEBUG = false;

    /**
     * Def. value for @param shouldBubblesFollow in
     * {@link #updateAndAnimateTransientTaskbar(boolean)} */
    public static boolean SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE = true;

    public static final int FLAG_IN_APP = 1 << 0;
    public static final int FLAG_STASHED_IN_APP_SYSUI = 1 << 1; // shade open, ...
    public static final int FLAG_STASHED_IN_APP_SETUP = 1 << 2; // setup wizard and AllSetActivity
@@ -94,6 +99,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    public static final int FLAG_STASHED_SYSUI = 1 << 9; //  app pinning,...
    public static final int FLAG_STASHED_DEVICE_LOCKED = 1 << 10; // device is locked: keyguard, ...
    public static final int FLAG_IN_OVERVIEW = 1 << 11; // launcher is in overview
    // An internal no-op flag to determine whether we should delay the taskbar background animation
    private static final int FLAG_DELAY_TASKBAR_BG_TAG = 1 << 12;

    // If any of these flags are enabled, isInApp should return true.
    private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
@@ -489,9 +496,17 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    /**
     * Stash or unstashes the transient taskbar, using the default TASKBAR_STASH_DURATION.
     * If bubble bar exists, it will match taskbars stashing behavior.
     * Will not delay taskbar background by default.
     */
    public void updateAndAnimateTransientTaskbar(boolean stash) {
        updateAndAnimateTransientTaskbar(stash, /* shouldBubblesFollow= */ true);
        updateAndAnimateTransientTaskbar(stash, SHOULD_BUBBLES_FOLLOW_DEFAULT_VALUE, false);
    }

    /**
     * Stash or unstashes the transient taskbar, using the default TASKBAR_STASH_DURATION.
     */
    public void updateAndAnimateTransientTaskbar(boolean stash, boolean shouldBubblesFollow) {
        updateAndAnimateTransientTaskbar(stash, shouldBubblesFollow, false);
    }

    /**
@@ -499,14 +514,15 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
     *
     * @param stash               whether transient taskbar should be stashed.
     * @param shouldBubblesFollow whether bubbles should match taskbars behavior.
     * @param delayTaskbarBackground whether we will delay the taskbar background animation
     */
    public void updateAndAnimateTransientTaskbar(boolean stash, boolean shouldBubblesFollow) {
    public void updateAndAnimateTransientTaskbar(boolean stash, boolean shouldBubblesFollow,
            boolean delayTaskbarBackground) {
        if (!DisplayController.isTransientTaskbar(mActivity)) {
            return;
        }

        if (
                stash
        if (stash
                && !mControllers.taskbarAutohideSuspendController
                .isSuspendedForTransientTaskbarInLauncher()
                && mControllers.taskbarAutohideSuspendController
@@ -515,12 +531,30 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
            return;
        }

        boolean shouldApplyState = false;

        if (delayTaskbarBackground) {
            mControllers.taskbarStashController.updateStateForFlag(FLAG_DELAY_TASKBAR_BG_TAG, true);
            shouldApplyState = true;
        }

        if (hasAnyFlag(FLAG_STASHED_IN_APP_AUTO) != stash) {
            mTaskbarSharedState.taskbarWasStashedAuto = stash;
            updateStateForFlag(FLAG_STASHED_IN_APP_AUTO, stash);
            shouldApplyState = true;
        }

        if (shouldApplyState) {
            applyState();
        }

        // Effectively a no-opp to remove the tag.
        if (delayTaskbarBackground) {
            mControllers.taskbarStashController.updateStateForFlag(FLAG_DELAY_TASKBAR_BG_TAG,
                    false);
            mControllers.taskbarStashController.applyState(0);
        }

        mControllers.bubbleControllers.ifPresent(controllers -> {
            if (shouldBubblesFollow) {
                final boolean willStash = mIsStashedPredicate.test(mState);
@@ -587,11 +621,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
     * @param isStashed             whether it's a stash animation or an unstash animation
     * @param duration              duration of the animation
     * @param animationType         what transition type to play.
     * @param skipTaskbarBackgroundDelay Iff true, skips delaying the taskbar background.
     * @param shouldDelayBackground whether we should delay the taskbar bg animation
     * @param jankTag               tag to be used in jank monitor trace.
     */
    private void createAnimToIsStashed(boolean isStashed, long duration,
            @StashAnimation int animationType, boolean skipTaskbarBackgroundDelay, String jankTag) {
            @StashAnimation int animationType, boolean shouldDelayBackground, String jankTag) {
        if (animationType == TRANSITION_UNSTASH_SUW_MANUAL && isStashed) {
            // The STASH_ANIMATION_SUW_MANUAL must only be used during an unstash animation.
            Log.e(TAG, "Illegal arguments:Using TRANSITION_UNSTASH_SUW_MANUAL to stash taskbar");
@@ -630,7 +664,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba

        if (isTransientTaskbar) {
            createTransientAnimToIsStashed(mAnimator, isStashed, duration,
                    skipTaskbarBackgroundDelay, animationType);
                    shouldDelayBackground, animationType);
        } else {
            createAnimToIsStashed(mAnimator, isStashed, duration, stashTranslation, animationType);
        }
@@ -736,7 +770,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    }

    private void createTransientAnimToIsStashed(AnimatorSet as, boolean isStashed, long duration,
            boolean skipTaskbarBackgroundDelay, @StashAnimation int animationType) {
            boolean shouldDelayBackground, @StashAnimation int animationType) {
        // Target values of the properties this is going to set
        final float backgroundOffsetTarget = isStashed ? 1 : 0;
        final float iconAlphaTarget = isStashed ? 0 : 1;
@@ -787,7 +821,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
                backgroundAndHandleAlphaStartDelay,
                backgroundAndHandleAlphaDuration, LINEAR);

        if (enableScalingRevealHomeAnimation() && isStashed && !skipTaskbarBackgroundDelay) {

        if (enableScalingRevealHomeAnimation()
                && !isStashed
                && shouldDelayBackground) {
            play(as, getTaskbarBackgroundAnimatorWhenNotGoingHome(duration),
                    0, 0, LINEAR);
            as.addListener(AnimatorListeners.forEndCallback(
@@ -1349,10 +1386,9 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
                mIsStashed = isStashed;
                mLastStartedTransitionType = animationType;

                boolean skipTaskbarBgDelay = !hasAnyFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS)
                        && hasAnyFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, changedFlags);
                boolean shouldDelayBackground = hasAnyFlag(FLAG_DELAY_TASKBAR_BG_TAG);
                // This sets mAnimator.
                createAnimToIsStashed(mIsStashed, duration, animationType, skipTaskbarBgDelay,
                createAnimToIsStashed(mIsStashed, duration, animationType, shouldDelayBackground,
                        computeTaskbarJankMonitorTag(changedFlags));
                return mAnimator;
            }
+3 −3
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
                            if (!mHasPassedTaskbarNavThreshold && passedTaskbarNavThreshold
                                    && !mGestureState.isInExtendedSlopRegion()) {
                                mHasPassedTaskbarNavThreshold = true;
                                mTaskbarActivityContext.onSwipeToUnstashTaskbar();
                                mTaskbarActivityContext.onSwipeToUnstashTaskbar(true);
                            }

                            if (dY < 0) {
@@ -287,7 +287,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
            // start a single unstash timeout if hovering bottom edge under the hinted taskbar.
            if (!sUnstashHandler.hasMessagesOrCallbacks()) {
                sUnstashHandler.postDelayed(() -> {
                    mTaskbarActivityContext.onSwipeToUnstashTaskbar();
                    mTaskbarActivityContext.onSwipeToUnstashTaskbar(false);
                    mIsStashedTaskbarHovered = false;
                }, HOVER_TASKBAR_UNSTASH_TIMEOUT);
            }
@@ -315,7 +315,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
            startStashedTaskbarHover(/* isHovered = */ true);
        } else if (mBottomEdgeBounds.contains(x, y)) {
            // If hover screen's bottom edge not below the stashed taskbar, unstash it.
            mTaskbarActivityContext.onSwipeToUnstashTaskbar();
            mTaskbarActivityContext.onSwipeToUnstashTaskbar(false);
        }
    }