From 09bd29dad1ab506b9d706528e9e8136ac1d81b75 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 3 Feb 2017 15:30:28 -0800 Subject: [PATCH] Disabling animations now when the screen is off Before, notifications were animating weirdly when the Keyboard was shown, this should not happen anymore. Test: add notifications, go to keyboard Change-Id: If0edccf84bdd09be99eaeae2dceee8e29f30ae12 Fixes: 34471382 --- .../systemui/statusbar/NotificationShelf.java | 12 ++ .../phone/NotificationIconContainer.java | 106 +++++++++++------- .../stack/NotificationStackScrollLayout.java | 1 + 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 637f9a780a1fc..2425076a44428 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -68,6 +68,7 @@ public class NotificationShelf extends ActivatableNotificationView { private float mMaxShelfEnd; private int mRelativeOffset; private boolean mInteractive; + private boolean mAnimationsEnabled = true; public NotificationShelf(Context context, AttributeSet attrs) { super(context, attrs); @@ -574,6 +575,15 @@ public class NotificationShelf extends ActivatableNotificationView { 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; @@ -586,6 +596,7 @@ public class NotificationShelf extends ActivatableNotificationView { setOpenedAmount(openedAmount); updateAppearance(); setHasItemsInStableShelf(hasItemsInStableShelf); + mShelfIcons.setAnimationsEnabled(mAnimationsEnabled); } @Override @@ -595,6 +606,7 @@ public class NotificationShelf extends ActivatableNotificationView { setOpenedAmount(openedAmount); updateAppearance(); setHasItemsInStableShelf(hasItemsInStableShelf); + mShelfIcons.setAnimationsEnabled(mAnimationsEnabled); } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index dacd6d54bf239..571ae2653948e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -104,6 +104,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { private float mOpenedAmount = 0.0f; private float mVisualOverflowAdaption; private boolean mDisallowNextAnimation; + private boolean mAnimationsEnabled = true; public NotificationIconContainer(Context context, AttributeSet attrs) { super(context, attrs); @@ -422,6 +423,20 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { 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; @@ -438,54 +453,59 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout { 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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 85b1c32d7eafe..7350276b21322 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -2740,6 +2740,7 @@ public class NotificationStackScrollLayout extends ViewGroup private void updateNotificationAnimationStates() { boolean running = mAnimationsEnabled || mPulsing; + mShelf.setAnimationsEnabled(running); int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i);