private float mMaxShelfEnd;
private int mRelativeOffset;
private boolean mInteractive;
+ private boolean mAnimationsEnabled = true;
public NotificationShelf(Context context, AttributeSet attrs) {
super(context, attrs);
mMaxShelfEnd = maxShelfEnd;
}
+ public void setAnimationsEnabled(boolean enabled) {
+ mAnimationsEnabled = enabled;
+ mCollapsedIcons.setAnimationsEnabled(enabled);
+ if (!enabled) {
+ // we need to wait with enabling the animations until the first frame has passed
+ mShelfIcons.setAnimationsEnabled(false);
+ }
+ }
+
private class ShelfState extends ExpandableViewState {
private float openedAmount;
private boolean hasItemsInStableShelf;
setOpenedAmount(openedAmount);
updateAppearance();
setHasItemsInStableShelf(hasItemsInStableShelf);
+ mShelfIcons.setAnimationsEnabled(mAnimationsEnabled);
}
@Override
setOpenedAmount(openedAmount);
updateAppearance();
setHasItemsInStableShelf(hasItemsInStableShelf);
+ mShelfIcons.setAnimationsEnabled(mAnimationsEnabled);
}
}
}
private float mOpenedAmount = 0.0f;
private float mVisualOverflowAdaption;
private boolean mDisallowNextAnimation;
+ private boolean mAnimationsEnabled = true;
public NotificationIconContainer(Context context, AttributeSet attrs) {
super(context, attrs);
return mIconSize;
}
+ public void setAnimationsEnabled(boolean enabled) {
+ if (!enabled && mAnimationsEnabled) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View child = getChildAt(i);
+ ViewState childState = mIconStates.get(child);
+ if (childState != null) {
+ childState.cancelAnimations(child);
+ childState.applyToView(child);
+ }
+ }
+ }
+ mAnimationsEnabled = enabled;
+ }
+
public class IconState extends ViewState {
public float iconAppearAmount = 1.0f;
public float clampedAppearAmount = 1.0f;
StatusBarIconView icon = (StatusBarIconView) view;
boolean animate = false;
AnimationProperties animationProperties = null;
- if (justAdded) {
- super.applyToView(icon);
- if (iconAppearAmount != 0.0f) {
- icon.setAlpha(0.0f);
- icon.setVisibleState(StatusBarIconView.STATE_HIDDEN, false /* animate */);
- animationProperties = ADD_ICON_PROPERTIES;
+ boolean animationsAllowed = mAnimationsEnabled && !mDisallowNextAnimation;
+ if (animationsAllowed) {
+ if (justAdded) {
+ super.applyToView(icon);
+ if (iconAppearAmount != 0.0f) {
+ icon.setAlpha(0.0f);
+ icon.setVisibleState(StatusBarIconView.STATE_HIDDEN,
+ false /* animate */);
+ animationProperties = ADD_ICON_PROPERTIES;
+ animate = true;
+ }
+ } else if (visibleState != icon.getVisibleState()) {
+ animationProperties = DOT_ANIMATION_PROPERTIES;
animate = true;
}
- } else if (visibleState != icon.getVisibleState()) {
- animationProperties = DOT_ANIMATION_PROPERTIES;
- animate = true;
- }
- if (!animate && mAddAnimationStartIndex >= 0
- && indexOfChild(view) >= mAddAnimationStartIndex
- && (icon.getVisibleState() != StatusBarIconView.STATE_HIDDEN
+ if (!animate && mAddAnimationStartIndex >= 0
+ && indexOfChild(view) >= mAddAnimationStartIndex
+ && (icon.getVisibleState() != StatusBarIconView.STATE_HIDDEN
|| visibleState != StatusBarIconView.STATE_HIDDEN)) {
- animationProperties = DOT_ANIMATION_PROPERTIES;
- animate = true;
- }
- if (needsCannedAnimation) {
- AnimationFilter animationFilter = mTempProperties.getAnimationFilter();
- animationFilter.reset();
- animationFilter.combineFilter(ICON_ANIMATION_PROPERTIES.getAnimationFilter());
- mTempProperties.resetCustomInterpolators();
- mTempProperties.combineCustomInterpolators(ICON_ANIMATION_PROPERTIES);
- if (animationProperties != null) {
- animationFilter.combineFilter(animationProperties.getAnimationFilter());
- mTempProperties.combineCustomInterpolators(animationProperties);
+ animationProperties = DOT_ANIMATION_PROPERTIES;
+ animate = true;
+ }
+ if (needsCannedAnimation) {
+ AnimationFilter animationFilter = mTempProperties.getAnimationFilter();
+ animationFilter.reset();
+ animationFilter.combineFilter(
+ ICON_ANIMATION_PROPERTIES.getAnimationFilter());
+ mTempProperties.resetCustomInterpolators();
+ mTempProperties.combineCustomInterpolators(ICON_ANIMATION_PROPERTIES);
+ if (animationProperties != null) {
+ animationFilter.combineFilter(animationProperties.getAnimationFilter());
+ mTempProperties.combineCustomInterpolators(animationProperties);
+ }
+ animationProperties = mTempProperties;
+ animationProperties.setDuration(CANNED_ANIMATION_DURATION);
+ animate = true;
+ mCannedAnimationStartIndex = indexOfChild(view);
+ }
+ if (!animate && mCannedAnimationStartIndex >= 0
+ && indexOfChild(view) > mCannedAnimationStartIndex
+ && (icon.getVisibleState() != StatusBarIconView.STATE_HIDDEN
+ || visibleState != StatusBarIconView.STATE_HIDDEN)) {
+ AnimationFilter animationFilter = mTempProperties.getAnimationFilter();
+ animationFilter.reset();
+ animationFilter.animateX();
+ mTempProperties.resetCustomInterpolators();
+ animationProperties = mTempProperties;
+ animationProperties.setDuration(CANNED_ANIMATION_DURATION);
+ animate = true;
}
- animationProperties = mTempProperties;
- animationProperties.setDuration(CANNED_ANIMATION_DURATION);
- animate = true;
- mCannedAnimationStartIndex = indexOfChild(view);
- }
- if (!animate && mCannedAnimationStartIndex >= 0
- && indexOfChild(view) > mCannedAnimationStartIndex
- && (icon.getVisibleState() != StatusBarIconView.STATE_HIDDEN
- || visibleState != StatusBarIconView.STATE_HIDDEN)) {
- AnimationFilter animationFilter = mTempProperties.getAnimationFilter();
- animationFilter.reset();
- animationFilter.animateX();
- mTempProperties.resetCustomInterpolators();
- animationProperties = mTempProperties;
- animationProperties.setDuration(CANNED_ANIMATION_DURATION);
- animate = true;
}
- icon.setVisibleState(visibleState);
- if (animate && !mDisallowNextAnimation) {
+ icon.setVisibleState(visibleState, animationsAllowed);
+ if (animate) {
animateTo(icon, animationProperties);
} else {
super.applyToView(view);