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

Commit bff3b73c authored by Mykola Podolian's avatar Mykola Podolian Committed by Android (Google) Code Review
Browse files

Merge "Hide hotseat when bubble bar is expanded." into main

parents d60904d5 69f4974e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -158,6 +158,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
                shouldDelayLauncherStateAnim);
    }

    @Override
    public void stashHotseat(boolean stash) {
        mTaskbarLauncherStateController.stashHotseat(stash);
    }

    /**
     * Adds the Launcher resume animator to the given animator set.
     *
+54 −17
Original line number Diff line number Diff line
@@ -17,9 +17,12 @@ package com.android.launcher3.taskbar;

import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_ALIGNMENT;
import static com.android.launcher3.Hotseat.ALPHA_CHANNEL_TASKBAR_STASH;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_OVERVIEW;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_FOR_BUBBLES;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
import static com.android.launcher3.util.FlagDebugUtils.formatFlagChange;
@@ -41,6 +44,7 @@ import androidx.annotation.Nullable;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat.HotseatQsbAlphaId;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepTransitionManager;
import com.android.launcher3.Utilities;
@@ -145,7 +149,7 @@ public class TaskbarLauncherStateController {
    private AnimatedFloat mTaskbarBackgroundAlpha;
    private AnimatedFloat mTaskbarAlpha;
    private AnimatedFloat mTaskbarCornerRoundness;
    private MultiProperty mIconAlphaForHome;
    private MultiProperty mTaskbarAlphaForHome;
    private QuickstepLauncher mLauncher;

    private boolean mIsDestroyed = false;
@@ -175,11 +179,11 @@ public class TaskbarLauncherStateController {
                    if (mIsQsbInline && !dp.isQsbInline) {
                        // We only modify QSB alpha if isQsbInline = true. If we switch to a DP
                        // where isQsbInline = false, then we need to reset the alpha.
                        mLauncher.getHotseat().setQsbAlpha(1f);
                        mLauncher.getHotseat().setQsbAlpha(1f, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                    }
                    mIsQsbInline = dp.isQsbInline;
                    TaskbarLauncherStateController.this.updateIconAlphaForHome(
                            mIconAlphaForHome.getValue());
                            mTaskbarAlphaForHome.getValue(), ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                }
            };

@@ -242,7 +246,7 @@ public class TaskbarLauncherStateController {
                .getTaskbarBackgroundAlpha();
        mTaskbarAlpha = mControllers.taskbarDragLayerController.getTaskbarAlpha();
        mTaskbarCornerRoundness = mControllers.getTaskbarCornerRoundness();
        mIconAlphaForHome = mControllers.taskbarViewController
        mTaskbarAlphaForHome = mControllers.taskbarViewController
                .getTaskbarIconAlpha().get(ALPHA_INDEX_HOME);

        resetIconAlignment();
@@ -266,7 +270,7 @@ public class TaskbarLauncherStateController {

        mIconAlignment.finishAnimation();

        mLauncher.getHotseat().setIconsAlpha(1f);
        mLauncher.getHotseat().setIconsAlpha(1f, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
        mLauncher.getStateManager().removeStateListener(mStateListener);

        mCanSyncViews = !mControllers.taskbarActivityContext.isPhoneMode();
@@ -701,14 +705,17 @@ public class TaskbarLauncherStateController {
                public void onAnimationEnd(Animator animation) {
                    if (isInStashedState && committed) {
                        // Reset hotseat alpha to default
                        mLauncher.getHotseat().setIconsAlpha(1);
                        mLauncher.getHotseat().setIconsAlpha(1, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                    }
                }

                @Override
                public void onAnimationStart(Animator animation) {
                    if (mLauncher.getHotseat().getIconsAlpha() > 0) {
                        updateIconAlphaForHome(mLauncher.getHotseat().getIconsAlpha());
                    float hotseatIconsAlpha = mLauncher.getHotseat()
                            .getIconsAlpha(ALPHA_CHANNEL_TASKBAR_ALIGNMENT)
                            .getValue();
                    if (hotseatIconsAlpha > 0) {
                        updateIconAlphaForHome(hotseatIconsAlpha, ALPHA_CHANNEL_TASKBAR_ALIGNMENT);
                    }
                }
            });
@@ -737,6 +744,25 @@ public class TaskbarLauncherStateController {
        }
    }

    protected void stashHotseat(boolean stash) {
        TaskbarStashController stashController = mControllers.taskbarStashController;
        stashController.updateStateForFlag(FLAG_STASHED_FOR_BUBBLES, stash);
        Runnable swapHotseatWithTaskbar = new Runnable() {
            @Override
            public void run() {
                updateIconAlphaForHome(stash ? 1 : 0, ALPHA_CHANNEL_TASKBAR_STASH);
            }
        };
        if (stash) {
            stashController.applyState();
            // if we stashing the hotseat we need to immediately swap it with the animating taskbar
            swapHotseatWithTaskbar.run();
        } else {
            // if we revert stashing make swap after taskbar animation is complete
            stashController.applyState(/* postApplyAction = */ swapHotseatWithTaskbar);
        }
    }

    /**
     * Resets and updates the icon alignment.
     */
@@ -746,7 +772,7 @@ public class TaskbarLauncherStateController {
    }

    private void onIconAlignmentRatioChanged() {
        float currentValue = mIconAlphaForHome.getValue();
        float currentValue = mTaskbarAlphaForHome.getValue();
        boolean taskbarWillBeVisible = mIconAlignment.value < 1;
        boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
                || (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
@@ -754,8 +780,10 @@ public class TaskbarLauncherStateController {
        mControllers.taskbarViewController.setLauncherIconAlignment(
                mIconAlignment.value, mLauncher.getDeviceProfile());
        mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
        // Switch taskbar and hotseat in last frame
        updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
        // Switch taskbar and hotseat in last frame and if taskbar is not hidden for bubbles
        boolean isHiddenForBubbles = mControllers.taskbarStashController.isHiddenForBubbles();
        updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0, ALPHA_CHANNEL_TASKBAR_ALIGNMENT,
                /* updateTaskbarAlpha = */ !isHiddenForBubbles);

        // Sync the first frame where we swap taskbar and hotseat.
        if (firstFrameVisChanged && mCanSyncViews && !Utilities.isRunningInTestHarness()) {
@@ -765,12 +793,20 @@ public class TaskbarLauncherStateController {
        }
    }

    private void updateIconAlphaForHome(float alpha) {
    private void updateIconAlphaForHome(float taskbarAlpha, @HotseatQsbAlphaId int alphaChannel) {
        updateIconAlphaForHome(taskbarAlpha, alphaChannel, /* updateTaskbarAlpha = */ true);
    }

    private void updateIconAlphaForHome(float taskbarAlpha,
            @HotseatQsbAlphaId int alphaChannel,
            boolean updateTaskbarAlpha) {
        if (mIsDestroyed) {
            return;
        }
        mIconAlphaForHome.setValue(alpha);
        boolean hotseatVisible = alpha == 0
        if (updateTaskbarAlpha) {
            mTaskbarAlphaForHome.setValue(taskbarAlpha);
        }
        boolean hotseatVisible = taskbarAlpha == 0
                || mControllers.taskbarActivityContext.isPhoneMode()
                || (!mControllers.uiController.isHotseatIconOnTopWhenAligned()
                && mIconAlignment.value > 0);
@@ -778,9 +814,10 @@ public class TaskbarLauncherStateController {
         * Hide Launcher Hotseat icons when Taskbar icons have opacity. Both icon sets
         * should not be visible at the same time.
         */
        mLauncher.getHotseat().setIconsAlpha(hotseatVisible ? 1 : 0);
        float targetAlpha = hotseatVisible ? 1 : 0;
        mLauncher.getHotseat().setIconsAlpha(targetAlpha, alphaChannel);
        if (mIsQsbInline) {
            mLauncher.getHotseat().setQsbAlpha(hotseatVisible ? 1 : 0);
            mLauncher.getHotseat().setQsbAlpha(targetAlpha, alphaChannel);
        }
    }

@@ -868,7 +905,7 @@ public class TaskbarLauncherStateController {
        pw.println(String.format(
                "%s\tmTaskbarBackgroundAlpha=%.2f", prefix, mTaskbarBackgroundAlpha.value));
        pw.println(String.format(
                "%s\tmIconAlphaForHome=%.2f", prefix, mIconAlphaForHome.getValue()));
                "%s\tmTaskbarAlphaForHome=%.2f", prefix, mTaskbarAlphaForHome.getValue()));
        pw.println(String.format("%s\tmPrevState=%s", prefix,
                mPrevState == null ? null : getStateString(mPrevState)));
        pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState)));
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa
        return bubblesExpanded && !mControllers.navbarButtonsViewController.isImeVisible()
                && !isShadeVisible
                && !mControllers.taskbarStashController.isStashed()
                && (mTaskbarVisible || showScrimForBubbles);
                && (mTaskbarVisible || showScrimForBubbles)
                && !mControllers.taskbarStashController.isHiddenForBubbles();
    }

    private float getScrimAlpha() {
+30 −2
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    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;
    public static final int FLAG_STASHED_FOR_BUBBLES = 1 << 13; // show handle for stashed hotseat

    // If any of these flags are enabled, isInApp should return true.
    private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
@@ -122,7 +123,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba

    // If any of these flags are enabled, the taskbar must be stashed.
    private static final int FLAGS_FORCE_STASHED = FLAG_STASHED_SYSUI | FLAG_STASHED_DEVICE_LOCKED
            | FLAG_STASHED_IN_TASKBAR_ALL_APPS | FLAG_STASHED_SMALL_SCREEN;
            | FLAG_STASHED_IN_TASKBAR_ALL_APPS | FLAG_STASHED_SMALL_SCREEN
            | FLAG_STASHED_FOR_BUBBLES;

    /**
     * How long to stash/unstash when manually invoked via long press.
@@ -395,6 +397,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        return mIsStashed;
    }

    /** Sets the hotseat stashed. */
    public void stashHotseat(boolean stash) {
        mControllers.uiController.stashHotseat(stash);
    }

    /**
     * Returns whether the taskbar should be stashed in apps (e.g. user long pressed to stash).
     */
@@ -434,6 +441,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        return hasAnyFlag(FLAG_IN_OVERVIEW);
    }

    /** Returns whether taskbar is hidden for bubbles. */
    public boolean isHiddenForBubbles() {
        return hasAnyFlag(FLAG_STASHED_FOR_BUBBLES);
    }

    /**
     * Returns the height that taskbar will be touchable.
     */
@@ -995,13 +1007,29 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
    }

    public void applyState() {
        applyState(hasAnyFlag(FLAG_IN_SETUP) ? 0 : TASKBAR_STASH_DURATION);
        applyState(/* postApplyAction = */ null);
    }

    /** Applies state and performs action after state is applied. */
    public void applyState(@Nullable Runnable postApplyAction) {
        applyState(hasAnyFlag(FLAG_IN_SETUP) ? 0 : TASKBAR_STASH_DURATION, postApplyAction);
    }

    public void applyState(long duration) {
        applyState(duration, /* postApplyAction = */ null);
    }

    private void applyState(long duration, @Nullable Runnable postApplyAction) {
        Animator animator = createApplyStateAnimator(duration);
        if (animator != null) {
            if (postApplyAction != null) {
                // performs action on animation end
                animator.addListener(AnimatorListeners.forEndCallback(postApplyAction));
            }
            animator.start();
        } else if (postApplyAction != null) {
            // animator was not created, just execute the action
            postApplyAction.run();
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -428,4 +428,8 @@ public class TaskbarUIController {
    public void setSkipLauncherVisibilityChange(boolean skip) {
        mSkipLauncherVisibilityChange = skip;
    }

    /** Sets whether the hotseat is stashed */
    public void stashHotseat(boolean stash) {
    }
}
Loading