Fixed an animation bug with inline view updates
The height is now updated in an animated fashion.
Bug: 16947659
Change-Id: I4e89e6ca78f8d3c0f1e6f7eb61134a394c6d7d73
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
index 1cd18a0..6ac0bef 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
@@ -660,6 +660,7 @@
}
public void reset() {
+ super.reset();
setTintColor(0);
setShowingLegacyBackground(false);
setBelowSpeedBump(false);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 0960c00..a275572 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -59,6 +59,7 @@
private boolean mClearable;
private ExpansionLogger mLogger;
private String mLoggingKey;
+ private boolean mWasReset;
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
@@ -88,6 +89,7 @@
mPublicLayout.reset();
mPrivateLayout.reset();
mMaxExpandHeight = 0;
+ mWasReset = true;
logExpansionEvent(false, wasExpanded);
}
@@ -246,11 +248,12 @@
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
- boolean updateExpandHeight = mMaxExpandHeight == 0;
+ boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
mMaxExpandHeight = mPrivateLayout.getMaxHeight();
if (updateExpandHeight) {
applyExpansionToLayout();
}
+ mWasReset = false;
}
public void setSensitive(boolean sensitive) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 46d4a9a..df64edf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -255,6 +255,10 @@
public void setBelowSpeedBump(boolean below) {
}
+ public void reset() {
+ mOnHeightChangedListener.onReset(this);
+ }
+
/**
* A listener notifying when {@link #getActualHeight} changes.
*/
@@ -265,5 +269,12 @@
* padding or the padding between the elements changed
*/
void onHeightChanged(ExpandableView view);
+
+ /**
+ * Called when the view is reset and therefore the height will change abruptly
+ *
+ * @param view The view which was reset.
+ */
+ void onReset(ExpandableView view);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index a07bc5c..1d08658 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -1469,6 +1469,10 @@
}
@Override
+ public void onReset(ExpandableView view) {
+ }
+
+ @Override
public void onScrollChanged() {
if (mQsExpanded) {
requestScrollerTopPaddingUpdate(false /* animate */);
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 fec5e74..d2b97d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -163,6 +163,8 @@
private int mNotificationTopPadding;
private float mTopPaddingOverflow;
private boolean mDontReportNextOverScroll;
+ private boolean mRequestViewResizeAnimationOnLayout;
+ private boolean mNeedViewResizeAnimation;
/**
* The maximum scrollPosition which we are allowed to reach when a notification was expanded.
@@ -319,9 +321,18 @@
setMaxLayoutHeight(getHeight());
updateContentHeight();
clampScrollPosition();
+ requestAnimationOnViewResize();
requestChildrenUpdate();
}
+ private void requestAnimationOnViewResize() {
+ if (mRequestViewResizeAnimationOnLayout && mIsExpanded && mAnimationsEnabled) {
+ mNeedViewResizeAnimation = true;
+ mNeedsAnimation = true;
+ }
+ mRequestViewResizeAnimationOnLayout = false;
+ }
+
public void updateSpeedBumpIndex(int newIndex) {
int currentIndex = indexOfChild(mSpeedBumpView);
@@ -1598,9 +1609,18 @@
generateHideSensitiveEvent();
generateDarkEvent();
generateGoToFullShadeEvent();
+ generateViewResizeEvent();
mNeedsAnimation = false;
}
+ private void generateViewResizeEvent() {
+ if (mNeedViewResizeAnimation) {
+ mAnimationEvents.add(
+ new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_VIEW_RESIZE));
+ }
+ mNeedViewResizeAnimation = false;
+ }
+
private void generateSnapBackEvents() {
for (View child : mSnappedBackChildren) {
mAnimationEvents.add(new AnimationEvent(child,
@@ -1892,6 +1912,11 @@
requestChildrenUpdate();
}
+ @Override
+ public void onReset(ExpandableView view) {
+ mRequestViewResizeAnimationOnLayout = true;
+ }
+
private void updateScrollPositionOnExpandInBottom(ExpandableView view) {
if (view instanceof ExpandableNotificationRow) {
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
@@ -2258,6 +2283,14 @@
// ANIMATION_TYPE_HIDE_SENSITIVE
new AnimationFilter()
.animateHideSensitive(),
+
+ // ANIMATION_TYPE_VIEW_RESIZE
+ new AnimationFilter()
+ .animateAlpha()
+ .animateHeight()
+ .animateTopInset()
+ .animateY()
+ .animateZ(),
};
static int[] LENGTHS = new int[] {
@@ -2297,6 +2330,9 @@
// ANIMATION_TYPE_HIDE_SENSITIVE
StackStateAnimator.ANIMATION_DURATION_STANDARD,
+
+ // ANIMATION_TYPE_VIEW_RESIZE
+ StackStateAnimator.ANIMATION_DURATION_STANDARD,
};
static final int ANIMATION_TYPE_ADD = 0;
@@ -2311,6 +2347,7 @@
static final int ANIMATION_TYPE_DARK = 9;
static final int ANIMATION_TYPE_GO_TO_FULL_SHADE = 10;
static final int ANIMATION_TYPE_HIDE_SENSITIVE = 11;
+ static final int ANIMATION_TYPE_VIEW_RESIZE = 12;
final long eventStartTime;
final View changingView;