mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary. Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that. Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well). Test: TaplTestsQuickstep Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition Fixes: 214562370 Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
This commit is contained in:
@@ -208,51 +208,83 @@ import java.util.function.Supplier;
|
||||
|
||||
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
if (hasAnyFlag(changedFlags, FLAG_RESUMED)) {
|
||||
|
||||
// Add the state animation first to ensure FLAG_IN_STASHED_LAUNCHER_STATE is set and we can
|
||||
// determine whether goingToUnstashedLauncherStateChanged.
|
||||
boolean wasGoingToUnstashedLauncherState = goingToUnstashedLauncherState();
|
||||
if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
|
||||
boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
|
||||
playStateTransitionAnim(animatorSet, duration, committed);
|
||||
|
||||
if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
|
||||
// We're about to be paused, set immediately to ensure seamless handoff.
|
||||
updateStateForFlag(FLAG_RESUMED, false);
|
||||
applyState(0 /* duration */);
|
||||
}
|
||||
}
|
||||
boolean goingToUnstashedLauncherStateChanged = wasGoingToUnstashedLauncherState
|
||||
!= goingToUnstashedLauncherState();
|
||||
|
||||
boolean launcherStateChangedDuringAnimToResumeAlignment =
|
||||
mIconAlignmentForResumedState.isAnimating() && goingToUnstashedLauncherStateChanged;
|
||||
if (hasAnyFlag(changedFlags, FLAG_RESUMED)
|
||||
|| launcherStateChangedDuringAnimToResumeAlignment) {
|
||||
boolean isResumed = isResumed();
|
||||
ObjectAnimator anim = mIconAlignmentForResumedState
|
||||
.animateToValue(isResumed && goingToUnstashedLauncherState()
|
||||
? 1 : 0)
|
||||
.setDuration(duration);
|
||||
float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0;
|
||||
// If we're already animating to the value, just leave it be instead of restarting it.
|
||||
if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
|
||||
ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
|
||||
.animateToValue(toAlignmentForResumedState)
|
||||
.setDuration(duration);
|
||||
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mIsAnimatingToLauncherViaResume = false;
|
||||
}
|
||||
resumeAlignAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mIsAnimatingToLauncherViaResume = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsAnimatingToLauncherViaResume = isResumed;
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsAnimatingToLauncherViaResume = isResumed;
|
||||
|
||||
TaskbarStashController stashController = mControllers.taskbarStashController;
|
||||
stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
|
||||
stashController.applyState(duration);
|
||||
}
|
||||
});
|
||||
animatorSet.play(anim);
|
||||
TaskbarStashController stashController =
|
||||
mControllers.taskbarStashController;
|
||||
stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
|
||||
stashController.applyState(duration);
|
||||
}
|
||||
});
|
||||
animatorSet.play(resumeAlignAnim);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)) {
|
||||
boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
|
||||
Animator animator = mIconAlignmentForGestureState
|
||||
.animateToValue(isRecentsAnimationRunning && goingToUnstashedLauncherState()
|
||||
? 1 : 0);
|
||||
if (isRecentsAnimationRunning) {
|
||||
animator.setDuration(duration);
|
||||
}
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mIsAnimatingToLauncherViaGesture = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
|
||||
boolean launcherStateChangedDuringAnimToGestureAlignment =
|
||||
mIconAlignmentForGestureState.isAnimating() && goingToUnstashedLauncherStateChanged;
|
||||
if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)
|
||||
|| launcherStateChangedDuringAnimToGestureAlignment) {
|
||||
boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
|
||||
float toAlignmentForGestureState = isRecentsAnimationRunning
|
||||
&& goingToUnstashedLauncherState() ? 1 : 0;
|
||||
// If we're already animating to the value, just leave it be instead of restarting it.
|
||||
if (!mIconAlignmentForGestureState.isAnimatingToValue(toAlignmentForGestureState)) {
|
||||
Animator gestureAlignAnim = mIconAlignmentForGestureState
|
||||
.animateToValue(toAlignmentForGestureState);
|
||||
if (isRecentsAnimationRunning) {
|
||||
gestureAlignAnim.setDuration(duration);
|
||||
}
|
||||
});
|
||||
animatorSet.play(animator);
|
||||
gestureAlignAnim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mIsAnimatingToLauncherViaGesture = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
|
||||
}
|
||||
});
|
||||
animatorSet.play(gestureAlignAnim);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
|
||||
@@ -265,17 +297,6 @@ import java.util.function.Supplier;
|
||||
.setDuration(duration));
|
||||
}
|
||||
|
||||
if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
|
||||
boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
|
||||
playStateTransitionAnim(animatorSet, duration, committed);
|
||||
|
||||
if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
|
||||
// We're about to be paused, set immediately to ensure seamless handoff.
|
||||
updateStateForFlag(FLAG_RESUMED, false);
|
||||
applyState(0 /* duration */);
|
||||
}
|
||||
}
|
||||
|
||||
if (start) {
|
||||
animatorSet.start();
|
||||
}
|
||||
@@ -315,8 +336,11 @@ import java.util.function.Supplier;
|
||||
animatorSet.play(stashAnimator);
|
||||
}
|
||||
|
||||
animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
|
||||
.setDuration(duration));
|
||||
// If we're already animating to the value, just leave it be instead of restarting it.
|
||||
if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) {
|
||||
animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
|
||||
.setDuration(duration));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isResumed() {
|
||||
|
||||
Reference in New Issue
Block a user