Fixed some issues where conversation badges would not be visible
Badges would only update once the next update of the shelf came in,
so they would sometimes would remain without a background for a
short time.
Bug: 150905003
Test: add conversations, observe normal background after expanding QS and flinging down
Change-Id: If8756ac8916e6e1fc51cf3a90c34c87d8db71db6
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/PropertyAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/PropertyAnimator.java
index fe56552..1f9d3af 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/PropertyAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/PropertyAnimator.java
@@ -96,7 +96,7 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(property);
if (listener != null) {
animator.addListener(listener);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AnimationProperties.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AnimationProperties.java
index 87a3cc9..112d48c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AnimationProperties.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AnimationProperties.java
@@ -16,12 +16,15 @@
package com.android.systemui.statusbar.notification.stack;
+import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.util.ArrayMap;
import android.util.Property;
import android.view.View;
import android.view.animation.Interpolator;
+import java.util.function.Consumer;
+
/**
* Properties for a View animation
*/
@@ -29,7 +32,7 @@
public long duration;
public long delay;
private ArrayMap<Property, Interpolator> mInterpolatorMap;
- private AnimatorListenerAdapter mAnimatorListenerAdapter;
+ private Consumer<Property> mAnimationEndAction;
/**
* @return an animation filter for this animation.
@@ -44,14 +47,32 @@
}
/**
- * @return a listener that should be run whenever any property finished its animation
+ * @return a listener that will be added for a given property during its animation.
*/
- public AnimatorListenerAdapter getAnimationFinishListener() {
- return mAnimatorListenerAdapter;
+ public AnimatorListenerAdapter getAnimationFinishListener(Property property) {
+ if (mAnimationEndAction == null) {
+ return null;
+ }
+ Consumer<Property> endAction = mAnimationEndAction;
+ return new AnimatorListenerAdapter() {
+ private boolean mCancelled;
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ mCancelled = true;
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (!mCancelled) {
+ endAction.accept(property);
+ }
+ }
+ };
}
- public AnimationProperties setAnimationFinishListener(AnimatorListenerAdapter listener) {
- mAnimatorListenerAdapter = listener;
+ public AnimationProperties setAnimationEndAction(Consumer<Property> listener) {
+ mAnimationEndAction = listener;
return this;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
index 72ef7f9..628c4e2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ExpandableViewState.java
@@ -263,7 +263,8 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(
+ null /* no property for this height */);
if (listener != null) {
animator.addListener(listener);
}
@@ -343,7 +344,8 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(
+ null /* no property for top inset */);
if (listener != null) {
animator.addListener(listener);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java
index 14442e3..7785082 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java
@@ -104,7 +104,7 @@
}
@Override
- public AnimatorListenerAdapter getAnimationFinishListener() {
+ public AnimatorListenerAdapter getAnimationFinishListener(Property property) {
return getGlobalAnimationFinishedListener();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ViewState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ViewState.java
index b00068c..3da4e321 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ViewState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ViewState.java
@@ -393,7 +393,7 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(View.ALPHA);
if (listener != null) {
animator.addListener(listener);
}
@@ -450,7 +450,8 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(
+ View.TRANSLATION_Z);
if (listener != null) {
animator.addListener(listener);
}
@@ -515,7 +516,8 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(
+ View.TRANSLATION_X);
if (listener != null) {
animator.addListener(listener);
}
@@ -580,7 +582,8 @@
|| previousAnimator.getAnimatedFraction() == 0)) {
animator.setStartDelay(properties.delay);
}
- AnimatorListenerAdapter listener = properties.getAnimationFinishListener();
+ AnimatorListenerAdapter listener = properties.getAnimationFinishListener(
+ View.TRANSLATION_Y);
if (listener != null) {
animator.addListener(listener);
}
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 623dae8..07eaaa1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java
@@ -19,6 +19,8 @@
import static com.android.systemui.statusbar.phone.HeadsUpAppearanceController.CONTENT_FADE_DELAY;
import static com.android.systemui.statusbar.phone.HeadsUpAppearanceController.CONTENT_FADE_DURATION;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
@@ -27,6 +29,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Icon;
import android.util.AttributeSet;
+import android.util.Property;
import android.view.View;
import android.view.animation.Interpolator;
@@ -43,6 +46,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.function.Consumer;
/**
* A container for notification icons. It handles overflowing icons properly and positions them
@@ -275,7 +279,7 @@
super.onViewAdded(child);
boolean isReplacingIcon = isReplacingIcon(child);
if (!mChangingViewPositions) {
- IconState v = new IconState();
+ IconState v = new IconState(child);
if (isReplacingIcon) {
v.justAdded = false;
v.justReplaced = true;
@@ -703,6 +707,20 @@
public boolean noAnimations;
public boolean isLastExpandIcon;
public int customTransformHeight = NO_VALUE;
+ private final View mView;
+
+ private final Consumer<Property> mCannedAnimationEndListener;
+
+ public IconState(View child) {
+ mView = child;
+ mCannedAnimationEndListener = (property) -> {
+ // If we finished animating out of the shelf
+ if (property == View.TRANSLATION_Y && iconAppearAmount == 0.0f
+ && mView.getVisibility() == VISIBLE) {
+ mView.setVisibility(INVISIBLE);
+ }
+ };
+ }
@Override
public void applyToView(View view) {
@@ -747,6 +765,7 @@
interpolator = Interpolators.ICON_OVERSHOT;
}
sTempProperties.setCustomInterpolator(View.TRANSLATION_Y, interpolator);
+ sTempProperties.setAnimationEndAction(mCannedAnimationEndListener);
if (animationProperties != null) {
animationFilter.combineFilter(animationProperties.getAnimationFilter());
sTempProperties.combineCustomInterpolators(animationProperties);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 5588c24..98ba6e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -379,14 +379,6 @@
private Runnable mPanelAlphaEndAction;
private float mBottomAreaShadeAlpha;
private final ValueAnimator mBottomAreaShadeAlphaAnimator;
- private AnimatorListenerAdapter mAnimatorListenerAdapter = new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- if (mPanelAlphaEndAction != null) {
- mPanelAlphaEndAction.run();
- }
- }
- };
private final AnimatableProperty mPanelAlphaAnimator = AnimatableProperty.from("panelAlpha",
NotificationPanelView::setPanelAlphaInternal,
NotificationPanelView::getCurrentPanelAlpha,
@@ -396,8 +388,11 @@
new AnimationProperties().setDuration(150).setCustomInterpolator(
mPanelAlphaAnimator.getProperty(), Interpolators.ALPHA_OUT);
private final AnimationProperties mPanelAlphaInPropertiesAnimator =
- new AnimationProperties().setDuration(200).setAnimationFinishListener(
- mAnimatorListenerAdapter).setCustomInterpolator(
+ new AnimationProperties().setDuration(200).setAnimationEndAction((property) -> {
+ if (mPanelAlphaEndAction != null) {
+ mPanelAlphaEndAction.run();
+ }
+ }).setCustomInterpolator(
mPanelAlphaAnimator.getProperty(), Interpolators.ALPHA_IN);
private final NotificationEntryManager mEntryManager;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/PropertyAnimatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/PropertyAnimatorTest.java
index 6359234..57278e3 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/PropertyAnimatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/PropertyAnimatorTest.java
@@ -93,7 +93,7 @@
}
@Override
- public AnimatorListenerAdapter getAnimationFinishListener() {
+ public AnimatorListenerAdapter getAnimationFinishListener(Property property) {
return mFinishListener;
}
}.setDuration(200);