Track OverviewToHomeAnim with StateManager

This way we mark the the current state as NORMAL at the start of
the animation, and cancel it as part of other state transitions.
This allows us to interact with launcher (e.g. to go to all apps
or pull down the notification shade) during the animation.

Also use OverviewToHomeAnim from RecentsView#startHome() to
ensure the animation is consistent, e.g. doesn't fade out
RecentsView, scrolls to page 1, etc.

Bug: 144170434
Change-Id: I5348565b9e705d8ffba39818dde9efe82b16bb7a
This commit is contained in:
Tony Wickham
2020-08-10 18:33:01 -07:00
parent 1ae2937f75
commit 4fb5f74bb4
5 changed files with 40 additions and 11 deletions

View File

@@ -312,7 +312,13 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
handler.setStateWithAnimation(state, mConfig, builder);
}
}
builder.addListener(new AnimationSuccessListener() {
builder.addListener(createStateAnimationListener(state));
mConfig.setAnimation(builder.buildAnim(), state);
return builder;
}
private AnimatorListener createStateAnimationListener(STATE_TYPE state) {
return new AnimationSuccessListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -327,9 +333,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
}
onStateTransitionEnd(state);
}
});
mConfig.setAnimation(builder.buildAnim(), state);
return builder;
};
}
private void onStateTransitionStart(STATE_TYPE state) {
@@ -396,6 +400,19 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
mConfig.playbackController = controller;
}
/**
* @see #setCurrentAnimation(AnimatorSet, Animator...). Using this method tells the StateManager
* that this is a custom animation to the given state, and thus the StateManager will add an
* animation listener to call {@link #onStateTransitionStart} and {@link #onStateTransitionEnd}.
* @param anim The custom animation to the given state.
* @param toState The state we are animating towards.
*/
public void setCurrentAnimation(AnimatorSet anim, STATE_TYPE toState) {
cancelAnimation();
setCurrentAnimation(anim);
anim.addListener(createStateAnimationListener(toState));
}
/**
* Sets the animation as the current state animation, i.e., canceled when
* starting another animation and may block some launcher interactions while running.