Invert playNonAtomicComponent() as onlyPlayAtomicComponent()

This avoids the double negative we use in a few places, so should be clearer.
Also added some comments to explain what the animComponents are used for.

Change-Id: Ibd25bd12efce6553b377bbd9c0651e4f4ac3e498
This commit is contained in:
Tony Wickham
2020-03-11 18:21:53 -07:00
parent 31ff98e144
commit 984c01cbcd
6 changed files with 39 additions and 17 deletions
@@ -313,10 +313,10 @@ public class LauncherStateManager {
}
public AnimatorSet createAtomicAnimation(LauncherState fromState, LauncherState toState,
AnimatorSetBuilder builder, @AnimationFlags int atomicComponent, long duration) {
AnimatorSetBuilder builder, @AnimationFlags int animFlags, long duration) {
prepareForAtomicAnimation(fromState, toState, builder);
AnimationConfig config = new AnimationConfig();
config.animComponents = atomicComponent;
config.mAnimFlags = animFlags;
config.duration = duration;
for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) {
handler.setStateWithAnimation(toState, builder, config);
@@ -371,7 +371,7 @@ public class LauncherStateManager {
@AnimationFlags int animComponents) {
mConfig.reset();
mConfig.userControlled = true;
mConfig.animComponents = animComponents;
mConfig.mAnimFlags = animComponents;
mConfig.duration = duration;
mConfig.playbackController = AnimatorPlaybackController.wrap(
createAnimationToNewWorkspaceInternal(state, builder, null), duration)
@@ -585,7 +585,7 @@ public class LauncherStateManager {
public long duration;
public boolean userControlled;
public AnimatorPlaybackController playbackController;
public @AnimationFlags int animComponents = ANIM_ALL_COMPONENTS;
private @AnimationFlags int mAnimFlags = ANIM_ALL_COMPONENTS;
private PropertySetter mPropertySetter;
private AnimatorSet mCurrentAnimation;
@@ -599,7 +599,7 @@ public class LauncherStateManager {
public void reset() {
duration = 0;
userControlled = false;
animComponents = ANIM_ALL_COMPONENTS;
mAnimFlags = ANIM_ALL_COMPONENTS;
mPropertySetter = null;
mTargetState = null;
@@ -640,19 +640,39 @@ public class LauncherStateManager {
mCurrentAnimation.addListener(this);
}
/**
* @return Whether Overview is scaling as part of this animation. If this is the only
* component (i.e. NON_ATOMIC_COMPONENT isn't included), then this scaling is happening
* atomically, rather than being part of a normal state animation. StateHandlers can use
* this to designate part of their animation that should scale with Overview.
*/
public boolean playAtomicOverviewScaleComponent() {
return hasAnimationComponent(PLAY_ATOMIC_OVERVIEW_SCALE);
return hasAnimationFlag(PLAY_ATOMIC_OVERVIEW_SCALE);
}
public boolean playNonAtomicComponent() {
return hasAnimationComponent(PLAY_NON_ATOMIC);
/**
* @return Whether this animation will play atomically at the same time as a different,
* user-controlled state transition. StateHandlers, which contribute to both animations, can
* use this to avoid animating the same properties in both animations, since they'd conflict
* with one another.
*/
public boolean onlyPlayAtomicComponent() {
return getAnimComponents() == PLAY_ATOMIC_OVERVIEW_SCALE
|| getAnimComponents() == PLAY_ATOMIC_OVERVIEW_PEEK;
}
/**
* Returns true if the config and any of the provided component flags
*/
public boolean hasAnimationComponent(@AnimationFlags int a) {
return (animComponents & a) != 0;
public boolean hasAnimationFlag(@AnimationFlags int a) {
return (mAnimFlags & a) != 0;
}
/**
* @return Only the flags that determine which animation components to play.
*/
public @AnimationFlags int getAnimComponents() {
return mAnimFlags & ANIM_ALL_COMPONENTS;
}
}
@@ -120,7 +120,7 @@ public class WorkspaceStateTransitionAnimation {
hotseatIconsAlpha, fadeInterpolator);
}
if (!config.playNonAtomicComponent()) {
if (config.onlyPlayAtomicComponent()) {
// Only the alpha and scale, handled above, are included in the atomic animation.
return;
}
@@ -175,7 +175,8 @@ public class WorkspaceStateTransitionAnimation {
float pageAlpha = pageAlphaProvider.getPageAlpha(childIndex);
int drawableAlpha = Math.round(pageAlpha * (state.hasWorkspacePageBackground ? 255 : 0));
if (config.playNonAtomicComponent()) {
if (!config.onlyPlayAtomicComponent()) {
// Don't update the scrim during the atomic animation.
propertySetter.setInt(cl.getScrimBackground(),
DRAWABLE_ALPHA, drawableAlpha, ZOOM_OUT);
}
@@ -162,7 +162,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
return;
}
if (!config.playNonAtomicComponent()) {
if (config.onlyPlayAtomicComponent()) {
// There is no atomic component for the all apps transition, so just return early.
return;
}