Fixed a bug where notification icons where not animating
Bug: 16043845
Change-Id: I23217d90803fd247f6d1b4d2aea056deb5749c15
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index c3eb94c..f5d6605 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1263,7 +1263,9 @@
// Add a basic notification template
publicViewLocal = LayoutInflater.from(mContext).inflate(
com.android.internal.R.layout.notification_template_material_base,
- expandedPublic, true);
+ expandedPublic, false);
+ publicViewLocal.setIsRootNamespace(true);
+ expandedPublic.setContractedChild(publicViewLocal);
final TextView title = (TextView) publicViewLocal.findViewById(com.android.internal.R.id.title);
try {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index dfcc408..e3a0b18 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -17,10 +17,15 @@
package com.android.systemui.statusbar;
import android.content.Context;
+import android.graphics.drawable.AnimatedVectorDrawable;
+import android.graphics.drawable.AnimationDrawable;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import android.widget.ImageView;
import com.android.systemui.R;
public class ExpandableNotificationRow extends ActivatableNotificationView {
@@ -62,6 +67,51 @@
private boolean mWasReset;
private NotificationGuts mGuts;
+ public void setIconAnimationRunning(boolean running) {
+ setIconAnimationRunning(running, mPublicLayout);
+ setIconAnimationRunning(running, mPrivateLayout);
+ }
+
+ private void setIconAnimationRunning(boolean running, NotificationContentView layout) {
+ if (layout != null) {
+ View contractedChild = layout.getContractedChild();
+ View expandedChild = layout.getExpandedChild();
+ setIconAnimationRunningForChild(running, contractedChild);
+ setIconAnimationRunningForChild(running, expandedChild);
+ }
+ }
+
+ private void setIconAnimationRunningForChild(boolean running, View child) {
+ if (child != null) {
+ ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
+ setIconRunning(icon, running);
+ ImageView rightIcon = (ImageView) child.findViewById(
+ com.android.internal.R.id.right_icon);
+ setIconRunning(rightIcon, running);
+ }
+ }
+
+ private void setIconRunning(ImageView imageView, boolean running) {
+ if (imageView != null) {
+ Drawable drawable = imageView.getDrawable();
+ if (drawable instanceof AnimationDrawable) {
+ AnimationDrawable animationDrawable = (AnimationDrawable) drawable;
+ if (running) {
+ animationDrawable.start();
+ } else {
+ animationDrawable.stop();
+ }
+ } else if (drawable instanceof AnimatedVectorDrawable) {
+ AnimatedVectorDrawable animationDrawable = (AnimatedVectorDrawable) drawable;
+ if (running) {
+ animationDrawable.start();
+ } else {
+ animationDrawable.stop();
+ }
+ }
+ }
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 8b4c2c4..e31eb7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -88,6 +88,14 @@
mContractedVisible = true;
}
+ public View getContractedChild() {
+ return mContractedChild;
+ }
+
+ public View getExpandedChild() {
+ return mExpandedChild;
+ }
+
public void setContractedChild(View child) {
if (mContractedChild != null) {
mContractedChild.animate().cancel();
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 148b00c..fed579c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -1467,6 +1467,7 @@
// drawn when removed
getOverlay().add(child);
}
+ updateAnimationState(false, child);
// Make sure the clipRect we might have set is removed
child.setClipBounds(null);
@@ -1545,10 +1546,28 @@
mStackScrollAlgorithm.notifyChildrenChanged(this);
((ExpandableView) child).setOnHeightChangedListener(this);
generateAddAnimation(child, false /* fromMoreCard */);
+ updateAnimationState(mAnimationsEnabled && mIsExpanded, child);
}
public void setAnimationsEnabled(boolean animationsEnabled) {
mAnimationsEnabled = animationsEnabled;
+ updateNotificationAnimationStates();
+ }
+
+ private void updateNotificationAnimationStates() {
+ boolean running = mIsExpanded && mAnimationsEnabled;
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View child = getChildAt(i);
+ updateAnimationState(running, child);
+ }
+ }
+
+ private void updateAnimationState(boolean running, View child) {
+ if (child instanceof ExpandableNotificationRow) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) child;
+ row.setIconAnimationRunning(running);
+ }
}
public boolean isAddOrRemoveAnimationPending() {
@@ -1918,8 +1937,12 @@
}
private void setIsExpanded(boolean isExpanded) {
+ boolean changed = isExpanded != mIsExpanded;
mIsExpanded = isExpanded;
mStackScrollAlgorithm.setIsExpanded(isExpanded);
+ if (changed) {
+ updateNotificationAnimationStates();
+ }
}
@Override