Skip to content

Commit e5011a3

Browse files
committed
Suppress header flash when collapsing notifications panel.
LayoutTransition is poking through and it shouldn't be. This change also fixes a few related animation glitches around the carrier label and fling velocity. Bug: 6628429 Change-Id: I6655c9f9a8c95c7abd9c6d7099957cb229b86d5a
1 parent 913bf80 commit e5011a3

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

packages/SystemUI/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
<dimen name="fling_collapse_min_velocity">200dp</dimen>
8888
<!-- Cap on contribution of x dimension of gesture to overall velocity -->
8989
<dimen name="fling_gesture_max_x_velocity">200dp</dimen>
90+
<!-- Cap on overall resulting fling speed (s^-1) -->
91+
<dimen name="fling_gesture_max_output_velocity">3000dp</dimen>
9092

9193
<!-- Minimum fraction of the display a gesture must travel, at any velocity, to qualify as a
9294
collapse request -->

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ public class PhoneStatusBar extends BaseStatusBar {
134134
private float mExpandAccelPx; // classic value: 2000px/s/s
135135
private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up")
136136

137+
private float mFlingGestureMaxOutputVelocityPx; // how fast can it really go? (should be a little
138+
// faster than mSelfCollapseVelocityPx)
139+
137140
PhoneStatusBarPolicy mIconPolicy;
138141

139142
// These are no longer handled by the policy, because we need custom strategies for them
@@ -392,12 +395,13 @@ public boolean onTouch(View v, MotionEvent event) {
392395
mTickerView = mStatusBarView.findViewById(R.id.ticker);
393396

394397
mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems);
398+
mPile.setLayoutTransitionsEnabled(false);
395399
mPile.setLongPressListener(getNotificationLongClicker());
396400
if (SHOW_CARRIER_LABEL) {
397401
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
398402
@Override
399403
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
400-
updateCarrierLabelVisibility();
404+
updateCarrierLabelVisibility(false);
401405
}
402406
});
403407
}
@@ -889,7 +893,7 @@ protected void updateNotificationIcons() {
889893
}
890894
}
891895

892-
protected void updateCarrierLabelVisibility() {
896+
protected void updateCarrierLabelVisibility(boolean force) {
893897
if (!SHOW_CARRIER_LABEL) return;
894898
// The idea here is to only show the carrier label when there is enough room to see it,
895899
// i.e. when there aren't enough notifications to fill the panel.
@@ -901,7 +905,7 @@ protected void updateCarrierLabelVisibility() {
901905
final boolean makeVisible =
902906
mPile.getHeight() < (mScrollView.getHeight() - mCarrierLabelHeight);
903907

904-
if (mCarrierLabelVisible != makeVisible) {
908+
if (force || mCarrierLabelVisible != makeVisible) {
905909
mCarrierLabelVisible = makeVisible;
906910
if (DEBUG) {
907911
Slog.d(TAG, "making carrier label " + (makeVisible?"visible":"invisible"));
@@ -986,7 +990,7 @@ public void onAnimationEnd(Animator _a) {
986990
.start();
987991
}
988992

989-
updateCarrierLabelVisibility();
993+
updateCarrierLabelVisibility(false);
990994
}
991995

992996
public void showClock(boolean show) {
@@ -1159,9 +1163,10 @@ private void makeExpandedVisible(boolean revealAfterDraw) {
11591163
}
11601164

11611165
mExpandedVisible = true;
1166+
mPile.setLayoutTransitionsEnabled(true);
11621167
makeSlippery(mNavigationBarView, true);
11631168

1164-
updateCarrierLabelVisibility();
1169+
updateCarrierLabelVisibility(true);
11651170

11661171
updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
11671172

@@ -1279,6 +1284,7 @@ void performCollapse() {
12791284
return;
12801285
}
12811286
mExpandedVisible = false;
1287+
mPile.setLayoutTransitionsEnabled(false);
12821288
visibilityChanged(false);
12831289
makeSlippery(mNavigationBarView, false);
12841290

@@ -1562,6 +1568,9 @@ boolean interceptTouchEvent(MotionEvent event) {
15621568
}
15631569

15641570
float vel = (float)Math.hypot(yVel, xVel);
1571+
if (vel > mFlingGestureMaxOutputVelocityPx) {
1572+
vel = mFlingGestureMaxOutputVelocityPx;
1573+
}
15651574
if (negative) {
15661575
vel = -vel;
15671576
}
@@ -2041,7 +2050,7 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
20412050
mStatusBarWindow.setBackgroundColor(color);
20422051
}
20432052

2044-
updateCarrierLabelVisibility();
2053+
updateCarrierLabelVisibility(false);
20452054
}
20462055

20472056
void updateDisplaySize() {
@@ -2268,6 +2277,8 @@ protected void loadDimens() {
22682277

22692278
mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity);
22702279

2280+
mFlingGestureMaxOutputVelocityPx = res.getDimension(R.dimen.fling_gesture_max_output_velocity);
2281+
22712282
mNotificationPanelMarginBottomPx
22722283
= (int) res.getDimension(R.dimen.notification_panel_margin_bottom);
22732284
mNotificationPanelMarginLeftPx

packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ public class NotificationRowLayout
6868
// animation is done
6969
boolean mRemoveViews = true;
7070

71+
private LayoutTransition mRealLayoutTransition;
72+
7173
public NotificationRowLayout(Context context, AttributeSet attrs) {
7274
this(context, attrs, 0);
7375
}
7476

7577
public NotificationRowLayout(Context context, AttributeSet attrs, int defStyle) {
7678
super(context, attrs, defStyle);
7779

78-
setLayoutTransition(new LayoutTransition());
80+
mRealLayoutTransition = new LayoutTransition();
81+
setLayoutTransitionsEnabled(true);
7982

8083
setOrientation(LinearLayout.VERTICAL);
8184

@@ -121,9 +124,9 @@ public void setAnimateBounds(boolean anim) {
121124

122125
private void logLayoutTransition() {
123126
Log.v(TAG, "layout " +
124-
(getLayoutTransition().isChangingLayout() ? "is " : "is not ") +
127+
(mRealLayoutTransition.isChangingLayout() ? "is " : "is not ") +
125128
"in transition and animations " +
126-
(getLayoutTransition().isRunning() ? "are " : "are not ") +
129+
(mRealLayoutTransition.isRunning() ? "are " : "are not ") +
127130
"running.");
128131
}
129132

@@ -225,6 +228,18 @@ public void setViewRemoval(boolean removeViews) {
225228
mRemoveViews = removeViews;
226229
}
227230

231+
// Suppress layout transitions for a little while.
232+
public void setLayoutTransitionsEnabled(boolean b) {
233+
if (b) {
234+
setLayoutTransition(mRealLayoutTransition);
235+
} else {
236+
if (mRealLayoutTransition.isRunning()) {
237+
mRealLayoutTransition.cancel();
238+
}
239+
setLayoutTransition(null);
240+
}
241+
}
242+
228243
public void dismissRowAnimated(View child) {
229244
dismissRowAnimated(child, 0);
230245
}

0 commit comments

Comments
 (0)