Skip to content

Commit a5e211b

Browse files
author
Selim Cinek
committed
Fixed an animation bug with inline view updates
The height is now updated in an animated fashion. Bug: 16947659 Change-Id: I4e89e6ca78f8d3c0f1e6f7eb61134a394c6d7d73
1 parent 1584609 commit a5e211b

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ public void setOnActivatedListener(OnActivatedListener onActivatedListener) {
660660
}
661661

662662
public void reset() {
663+
super.reset();
663664
setTintColor(0);
664665
setShowingLegacyBackground(false);
665666
setBelowSpeedBump(false);

packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
5959
private boolean mClearable;
6060
private ExpansionLogger mLogger;
6161
private String mLoggingKey;
62+
private boolean mWasReset;
6263

6364
public interface ExpansionLogger {
6465
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
@@ -88,6 +89,7 @@ public void reset() {
8889
mPublicLayout.reset();
8990
mPrivateLayout.reset();
9091
mMaxExpandHeight = 0;
92+
mWasReset = true;
9193
logExpansionEvent(false, wasExpanded);
9294
}
9395

@@ -246,11 +248,12 @@ private boolean isExpanded() {
246248
@Override
247249
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
248250
super.onLayout(changed, left, top, right, bottom);
249-
boolean updateExpandHeight = mMaxExpandHeight == 0;
251+
boolean updateExpandHeight = mMaxExpandHeight == 0 && !mWasReset;
250252
mMaxExpandHeight = mPrivateLayout.getMaxHeight();
251253
if (updateExpandHeight) {
252254
applyExpansionToLayout();
253255
}
256+
mWasReset = false;
254257
}
255258

256259
public void setSensitive(boolean sensitive) {

packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ public abstract void performRemoveAnimation(long duration, float translationDire
255255
public void setBelowSpeedBump(boolean below) {
256256
}
257257

258+
public void reset() {
259+
mOnHeightChangedListener.onReset(this);
260+
}
261+
258262
/**
259263
* A listener notifying when {@link #getActualHeight} changes.
260264
*/
@@ -265,5 +269,12 @@ public interface OnHeightChangedListener {
265269
* padding or the padding between the elements changed
266270
*/
267271
void onHeightChanged(ExpandableView view);
272+
273+
/**
274+
* Called when the view is reset and therefore the height will change abruptly
275+
*
276+
* @param view The view which was reset.
277+
*/
278+
void onReset(ExpandableView view);
268279
}
269280
}

packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,10 @@ public void onHeightChanged(ExpandableView view) {
14681468
requestPanelHeightUpdate();
14691469
}
14701470

1471+
@Override
1472+
public void onReset(ExpandableView view) {
1473+
}
1474+
14711475
@Override
14721476
public void onScrollChanged() {
14731477
if (mQsExpanded) {

packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ public class NotificationStackScrollLayout extends ViewGroup
163163
private int mNotificationTopPadding;
164164
private float mTopPaddingOverflow;
165165
private boolean mDontReportNextOverScroll;
166+
private boolean mRequestViewResizeAnimationOnLayout;
167+
private boolean mNeedViewResizeAnimation;
166168

167169
/**
168170
* The maximum scrollPosition which we are allowed to reach when a notification was expanded.
@@ -319,9 +321,18 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
319321
setMaxLayoutHeight(getHeight());
320322
updateContentHeight();
321323
clampScrollPosition();
324+
requestAnimationOnViewResize();
322325
requestChildrenUpdate();
323326
}
324327

328+
private void requestAnimationOnViewResize() {
329+
if (mRequestViewResizeAnimationOnLayout && mIsExpanded && mAnimationsEnabled) {
330+
mNeedViewResizeAnimation = true;
331+
mNeedsAnimation = true;
332+
}
333+
mRequestViewResizeAnimationOnLayout = false;
334+
}
335+
325336
public void updateSpeedBumpIndex(int newIndex) {
326337
int currentIndex = indexOfChild(mSpeedBumpView);
327338

@@ -1598,9 +1609,18 @@ private void generateChildHierarchyEvents() {
15981609
generateHideSensitiveEvent();
15991610
generateDarkEvent();
16001611
generateGoToFullShadeEvent();
1612+
generateViewResizeEvent();
16011613
mNeedsAnimation = false;
16021614
}
16031615

1616+
private void generateViewResizeEvent() {
1617+
if (mNeedViewResizeAnimation) {
1618+
mAnimationEvents.add(
1619+
new AnimationEvent(null, AnimationEvent.ANIMATION_TYPE_VIEW_RESIZE));
1620+
}
1621+
mNeedViewResizeAnimation = false;
1622+
}
1623+
16041624
private void generateSnapBackEvents() {
16051625
for (View child : mSnappedBackChildren) {
16061626
mAnimationEvents.add(new AnimationEvent(child,
@@ -1892,6 +1912,11 @@ public void onHeightChanged(ExpandableView view) {
18921912
requestChildrenUpdate();
18931913
}
18941914

1915+
@Override
1916+
public void onReset(ExpandableView view) {
1917+
mRequestViewResizeAnimationOnLayout = true;
1918+
}
1919+
18951920
private void updateScrollPositionOnExpandInBottom(ExpandableView view) {
18961921
if (view instanceof ExpandableNotificationRow) {
18971922
ExpandableNotificationRow row = (ExpandableNotificationRow) view;
@@ -2258,6 +2283,14 @@ static class AnimationEvent {
22582283
// ANIMATION_TYPE_HIDE_SENSITIVE
22592284
new AnimationFilter()
22602285
.animateHideSensitive(),
2286+
2287+
// ANIMATION_TYPE_VIEW_RESIZE
2288+
new AnimationFilter()
2289+
.animateAlpha()
2290+
.animateHeight()
2291+
.animateTopInset()
2292+
.animateY()
2293+
.animateZ(),
22612294
};
22622295

22632296
static int[] LENGTHS = new int[] {
@@ -2297,6 +2330,9 @@ static class AnimationEvent {
22972330

22982331
// ANIMATION_TYPE_HIDE_SENSITIVE
22992332
StackStateAnimator.ANIMATION_DURATION_STANDARD,
2333+
2334+
// ANIMATION_TYPE_VIEW_RESIZE
2335+
StackStateAnimator.ANIMATION_DURATION_STANDARD,
23002336
};
23012337

23022338
static final int ANIMATION_TYPE_ADD = 0;
@@ -2311,6 +2347,7 @@ static class AnimationEvent {
23112347
static final int ANIMATION_TYPE_DARK = 9;
23122348
static final int ANIMATION_TYPE_GO_TO_FULL_SHADE = 10;
23132349
static final int ANIMATION_TYPE_HIDE_SENSITIVE = 11;
2350+
static final int ANIMATION_TYPE_VIEW_RESIZE = 12;
23142351

23152352
final long eventStartTime;
23162353
final View changingView;

0 commit comments

Comments
 (0)