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

Commit 0d771378 authored by Mike Schneider's avatar Mike Schneider
Browse files

Fade navbar-handle in/out during TRANSITION_HANDLE_FADE

The existing code relied on the INSTANT / FINAL_FRAME interpolators,
however these did not work as expected for sub-animations with shorter durations,
since the INSTANT / FINAL_FRAME interpolator applies to the sub-animations durations

This caused the stashed handle to jumpcut in/out, while the taskbar icons were
actually visible in the area of the navbar.

This is fixed to polish the lock/unlock animation (b/275319714), but happenes to fix b/276941963 as well.

Before: http://shortn/_uxw2oe7QeA
After: http://shortn/_yMY8IQIM60

Bug: 275319714
Bug: 276941963
Fixed: 275319714
Fixed: 276941963

Test: manual (http://shortn/_rnGNSkRH3w), tapl tests
Change-Id: I79e431e9ee21ede069864ee217bb343f0c32dfc7
parent 975fa692
Loading
Loading
Loading
Loading
+58 −37
Original line number Diff line number Diff line
@@ -749,56 +749,77 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba

    private void createTransientAnimToIsStashed(AnimatorSet as, boolean isStashed, long duration,
            @StashAnimation int animationType) {
        Interpolator skipInterpolator = null;
        // Target values of the properties this is going to set
        final float backgroundOffsetTarget = isStashed ? 1 : 0;
        final float iconAlphaTarget = isStashed ? 0 : 1;
        final float stashedHandleAlphaTarget = isStashed ? 1 : 0;

        // Timing for the alpha values depend on the animation played
        long iconAlphaStartDelay = 0, iconAlphaDuration = 0, stashedHandleAlphaDelay = 0,
                stashedHandleAlphaDuration = 0;
        if (duration > 0) {
            if (animationType == TRANSITION_HANDLE_FADE) {
                // When fading, the handle fades in/out at the beginning of the transition with
                // TASKBAR_STASH_ALPHA_DURATION.
                stashedHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
                // The iconAlphaDuration must be set to duration for the skippable interpolators
                // below to work.
                iconAlphaDuration = duration;
            } else {
                iconAlphaStartDelay = TASKBAR_STASH_ALPHA_START_DELAY;
                iconAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;
                stashedHandleAlphaDuration = TASKBAR_STASH_ALPHA_DURATION;

                if (isStashed) {
            play(as, mTaskbarBackgroundOffset.animateToValue(1), 0, duration, EMPHASIZED);
                    if (animationType == TRANSITION_HOME_TO_APP) {
                        iconAlphaStartDelay = TASKBAR_STASH_ICON_ALPHA_HOME_TO_APP_START_DELAY;
                    }
                    stashedHandleAlphaDelay = iconAlphaStartDelay;
                    stashedHandleAlphaDuration = Math.max(0, duration - iconAlphaStartDelay);
                }

            long alphaStartDelay = duration == 0 ? 0 : animationType == TRANSITION_HOME_TO_APP
                    ? TASKBAR_STASH_ICON_ALPHA_HOME_TO_APP_START_DELAY
                    : TASKBAR_STASH_ALPHA_START_DELAY;
            long alphaDuration = duration == 0 ? 0 : TASKBAR_STASH_ALPHA_DURATION;
            play(as, mIconAlphaForStash.animateToValue(0), alphaStartDelay, alphaDuration, LINEAR);
            play(as, mTaskbarStashedHandleAlpha.animateToValue(1), alphaStartDelay,
                    Math.max(0, duration - alphaStartDelay), LINEAR);
            }
        }

            play(as, mControllers.taskbarSpringOnStashController.createSpringToStash(), 0, duration,
                    LINEAR);
        play(as, mTaskbarStashedHandleAlpha.animateToValue(stashedHandleAlphaTarget),
                stashedHandleAlphaDelay,
                stashedHandleAlphaDuration, LINEAR);

        // The rest of the animations might be "skipped" in TRANSITION_HANDLE_FADE transitions.
        AnimatorSet skippable = as;
        if (animationType == TRANSITION_HANDLE_FADE) {
                skipInterpolator = INSTANT;
            skippable = new AnimatorSet();
            as.play(skippable);
            skippable.setInterpolator(isStashed ? INSTANT : FINAL_FRAME);
        }
        } else  {

        final boolean animateBg = animationType != TRANSITION_UNSTASH_SUW_MANUAL;
        if (animateBg) {
                play(as, mTaskbarBackgroundOffset.animateToValue(0), 0, duration, EMPHASIZED);
            play(skippable, mTaskbarBackgroundOffset.animateToValue(backgroundOffsetTarget), 0,
                    duration, EMPHASIZED);
        } else {
                as.addListener(AnimatorListeners.forEndCallback(
                        () -> mTaskbarBackgroundOffset.updateValue(0)));
            skippable.addListener(AnimatorListeners.forEndCallback(
                    () -> mTaskbarBackgroundOffset.updateValue(backgroundOffsetTarget)));
        }

            long alphaStartDelay = duration == 0 ? 0 : TASKBAR_STASH_ALPHA_START_DELAY;
            long alphaDuration = duration == 0 ? 0 : TASKBAR_STASH_ALPHA_DURATION;
            play(as, mIconAlphaForStash.animateToValue(1), alphaStartDelay, alphaDuration, LINEAR);
            play(as, mTaskbarStashedHandleAlpha.animateToValue(0), 0, alphaDuration, LINEAR);
        play(skippable, mIconAlphaForStash.animateToValue(iconAlphaTarget), iconAlphaStartDelay,
                iconAlphaDuration,
                LINEAR);

            if (animationType == TRANSITION_HANDLE_FADE) {
                skipInterpolator = FINAL_FRAME;
            }
        if (isStashed) {
            play(skippable, mControllers.taskbarSpringOnStashController.createSpringToStash(),
                    0, duration, LINEAR);
        }
        mControllers.taskbarViewController.addRevealAnimToIsStashed(as, isStashed, duration,
                EMPHASIZED);

        if (skipInterpolator != null) {
            as.setInterpolator(skipInterpolator);
        }
        mControllers.taskbarViewController.addRevealAnimToIsStashed(skippable, isStashed, duration,
                EMPHASIZED);

        play(as, mControllers.stashedHandleViewController
        play(skippable, mControllers.stashedHandleViewController
                .createRevealAnimToIsStashed(isStashed), 0, duration, EMPHASIZED);

        // Return the stashed handle to its default scale in case it was changed as part of the
        // feedforward hint. Note that the reveal animation above also visually scales it.
        as.play(mTaskbarStashedHandleHintScale.animateToValue(1f)
        skippable.play(mTaskbarStashedHandleHintScale.animateToValue(1f)
                .setDuration(isStashed ? duration / 2 : duration));
    }