From 0d7713780fdb2a2541871f021c6ef130eebbee14 Mon Sep 17 00:00:00 2001 From: Mike Schneider Date: Tue, 4 Apr 2023 08:32:12 +0200 Subject: [PATCH] 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 --- .../taskbar/TaskbarStashController.java | 103 +++++++++++------- 1 file changed, 62 insertions(+), 41 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index f675b57267..69ea9fd03a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -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) { + if (animationType == TRANSITION_HOME_TO_APP) { + iconAlphaStartDelay = TASKBAR_STASH_ICON_ALPHA_HOME_TO_APP_START_DELAY; + } + stashedHandleAlphaDelay = iconAlphaStartDelay; + stashedHandleAlphaDuration = Math.max(0, duration - iconAlphaStartDelay); + } + + } + } + + 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) { + skippable = new AnimatorSet(); + as.play(skippable); + skippable.setInterpolator(isStashed ? INSTANT : FINAL_FRAME); + } + + final boolean animateBg = animationType != TRANSITION_UNSTASH_SUW_MANUAL; + if (animateBg) { + play(skippable, mTaskbarBackgroundOffset.animateToValue(backgroundOffsetTarget), 0, + duration, EMPHASIZED); + } else { + skippable.addListener(AnimatorListeners.forEndCallback( + () -> mTaskbarBackgroundOffset.updateValue(backgroundOffsetTarget))); + } + + play(skippable, mIconAlphaForStash.animateToValue(iconAlphaTarget), iconAlphaStartDelay, + iconAlphaDuration, + LINEAR); if (isStashed) { - play(as, mTaskbarBackgroundOffset.animateToValue(1), 0, duration, EMPHASIZED); - - 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); - - if (animationType == TRANSITION_HANDLE_FADE) { - skipInterpolator = INSTANT; - } - } else { - final boolean animateBg = animationType != TRANSITION_UNSTASH_SUW_MANUAL; - if (animateBg) { - play(as, mTaskbarBackgroundOffset.animateToValue(0), 0, duration, EMPHASIZED); - } else { - as.addListener(AnimatorListeners.forEndCallback( - () -> mTaskbarBackgroundOffset.updateValue(0))); - } - - 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); - - if (animationType == TRANSITION_HANDLE_FADE) { - skipInterpolator = FINAL_FRAME; - } + play(skippable, mControllers.taskbarSpringOnStashController.createSpringToStash(), + 0, duration, LINEAR); } - mControllers.taskbarViewController.addRevealAnimToIsStashed(as, isStashed, duration, + + mControllers.taskbarViewController.addRevealAnimToIsStashed(skippable, isStashed, duration, EMPHASIZED); - if (skipInterpolator != null) { - as.setInterpolator(skipInterpolator); - } - - 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)); }