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

Commit cd76ac24 authored by Alex Chau's avatar Alex Chau
Browse files

Fade in/out taskbar when launching apps from or back to AllApps/-1

- Added isHotseatIconTopWhenAligned to control both iconAlignment and stash animation to just fade in if hotseat icon isn't on top of the screen in the aligned state

Fix: 257355864
Fix: 213455090
Test: Launch apps from/back to home, taskbar animate from/to hotseat
Test: Launch apps from/back to AllApps/-1, taskbar fade in/out
Test: Repeat aboth with transient or persistent taskbar
Change-Id: I6bdae615ff9e199d23cbfe2d26c8d46a08fbc436
parent 42faae4a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -482,6 +482,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
            final View appsView = mLauncher.getAppsView();
            final float startAlpha = appsView.getAlpha();
            final float startScale = SCALE_PROPERTY.get(appsView);
            if (mDeviceProfile.isTablet) {
                // AllApps should not fade at all in tablets.
                alphas = new float[]{1, 1};
            }
            appsView.setAlpha(alphas[0]);

            ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
+6 −0
Original line number Diff line number Diff line
@@ -355,6 +355,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        return mTaskbarLauncherStateController.isIconAlignedWithHotseat();
    }

    @Override
    public boolean isHotseatIconOnTopWhenAligned() {
        return mTaskbarLauncherStateController.isInHotseatOnTopStates()
                && getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX) == 0;
    }

    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
        super.dumpLogs(prefix, pw);
+12 −3
Original line number Diff line number Diff line
@@ -385,6 +385,13 @@ import java.util.StringJoiner;
        }
    }

    /**
     * Returns if the current Launcher state has hotseat on top of other elemnets.
     */
    public boolean isInHotseatOnTopStates() {
        return mLauncherState != LauncherState.ALL_APPS;
    }

    private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
            boolean committed) {
        boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
@@ -438,14 +445,16 @@ import java.util.StringJoiner;

    private void updateIconAlphaForHome(float alpha) {
        mIconAlphaForHome.setValue(alpha);

        boolean hotseatVisible = alpha == 0
                || (!mControllers.uiController.isHotseatIconOnTopWhenAligned()
                && mIconAlignment.value > 0);
        /*
         * Hide Launcher Hotseat icons when Taskbar icons have opacity. Both icon sets
         * should not be visible at the same time.
         */
        mLauncher.getHotseat().setIconsAlpha(alpha > 0 ? 0 : 1);
        mLauncher.getHotseat().setIconsAlpha(hotseatVisible ? 1 : 0);
        mLauncher.getHotseat().setQsbAlpha(
                mLauncher.getDeviceProfile().isQsbInline && alpha > 0 ? 0 : 1);
                mLauncher.getDeviceProfile().isQsbInline && !hotseatVisible ? 0 : 1);
    }

    private final class TaskBarRecentsAnimationListener implements
+26 −1
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ package com.android.launcher3.taskbar;

import static android.view.HapticFeedbackConstants.LONG_PRESS;

import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
import static com.android.launcher3.taskbar.Utilities.appendFlag;
@@ -535,6 +537,8 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        final float firstHalfDurationScale;
        final float secondHalfDurationScale;

        boolean isHotseatIconOnTopWhenAligned =
                mControllers.uiController.isHotseatIconOnTopWhenAligned();
        if (isStashed) {
            firstHalfDurationScale = 0.75f;
            secondHalfDurationScale = 0.5f;
@@ -555,6 +559,12 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
            secondHalfAnimatorSet.playTogether(
                    mTaskbarStashedHandleAlpha.animateToValue(1)
            );

            // If Hotseat is not the top element, an already stashed Taskbar should fade in.
            if (!isHotseatIconOnTopWhenAligned) {
                fullLengthAnimatorSet.setInterpolator(INSTANT);
                firstHalfAnimatorSet.setInterpolator(INSTANT);
            }
        } else  {
            firstHalfDurationScale = 0.5f;
            secondHalfDurationScale = 0.75f;
@@ -575,6 +585,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
            secondHalfAnimatorSet.playTogether(
                    mIconAlphaForStash.animateToValue(1)
            );

            // If Hotseat is not the top element, the stashed Taskbar should fade out without
            // unstashing.
            if (!isHotseatIconOnTopWhenAligned) {
                fullLengthAnimatorSet.setInterpolator(FINAL_FRAME);
                secondHalfAnimatorSet.setInterpolator(FINAL_FRAME);
            }
        }

        fullLengthAnimatorSet.play(mControllers.stashedHandleViewController
@@ -916,6 +933,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        private final IntPredicate mStashCondition;

        private boolean mIsStashed;
        private boolean mIsHotseatIconOnTopWhenAligned;
        private int mPrevFlags;

        StatePropertyHolder(IntPredicate stashCondition) {
@@ -945,7 +963,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
                mPrevFlags = flags;
            }
            boolean isStashed = mStashCondition.test(flags);
            if (mIsStashed != isStashed) {
            boolean isHotseatIconOnTopWhenAligned =
                    mControllers.uiController.isHotseatIconOnTopWhenAligned();
            // If an animation has started and mIsHotseatIconOnTopWhenAligned is changed, we need
            // to restart the animation with new parameters.
            if (mIsStashed != isStashed
                    || (mIsHotseatIconOnTopWhenAligned != isHotseatIconOnTopWhenAligned
                    && mAnimator != null && mAnimator.isStarted())) {
                if (TestProtocol.sDebugTracing) {
                    Log.d(TestProtocol.TASKBAR_IN_APP_STATE, String.format(
                            "setState: mIsStashed=%b, isStashed=%b, duration=%d, start=:%b",
@@ -955,6 +979,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
                            start));
                }
                mIsStashed = isStashed;
                mIsHotseatIconOnTopWhenAligned = isHotseatIconOnTopWhenAligned;

                // This sets mAnimator.
                createAnimToIsStashed(mIsStashed, duration, startDelay, /* animateBg= */ true);
+7 −0
Original line number Diff line number Diff line
@@ -128,6 +128,13 @@ public class TaskbarUIController {
        return false;
    }

    /**
     * Returns true if hotseat icons are on top of view hierarchy when aligned in the current state.
     */
    public boolean isHotseatIconOnTopWhenAligned() {
        return true;
    }

    @CallSuper
    protected void dumpLogs(String prefix, PrintWriter pw) {
        pw.println(String.format(
Loading