Skip to content

Commit 1fac1fd

Browse files
committed
Fix a longstanding bug in the shade pulldown trajectory.
Two parts to this: 1. We were looking at the measured height of the close view for a lot of our computations, which---particularly with recent changes that dispense with the old 3-window implementation---is increasingly unreliable 2. We were overestimating the minY that the panel must be pulled down before animation starts. It was enforced jankiness! Bug: 5359178 Change-Id: Ie09b62226b7b0977527348b5527478665ece1df8
1 parent a310af8 commit 1fac1fd

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121

122122
<com.android.systemui.statusbar.phone.CloseDragHandle android:id="@+id/close"
123123
android:layout_width="match_parent"
124-
android:layout_height="34dp"
124+
android:layout_height="@dimen/close_handle_height"
125125
android:layout_gravity="bottom"
126126
android:orientation="vertical"
127127
>

packages/SystemUI/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,6 @@
118118
<!-- Diameter of outer shape drawable shown in navbar search-->
119119
<dimen name="navbar_search_outerring_diameter">300dip</dimen>
120120

121+
<!-- Height of the draggable handle at the bottom of the phone notification panel -->
122+
<dimen name="close_handle_height">34dp</dimen>
121123
</resources>

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public class PhoneStatusBar extends BaseStatusBar {
164164

165165
// drag bar
166166
CloseDragHandle mCloseView;
167+
private int mCloseViewHeight;
167168

168169
// all notifications
169170
NotificationData mNotificationData = new NotificationData();
@@ -333,6 +334,7 @@ protected PhoneStatusBarView makeStatusBarView() {
333334

334335
mCloseView = (CloseDragHandle)mStatusBarWindow.findViewById(R.id.close);
335336
mCloseView.mService = this;
337+
mCloseViewHeight = res.getDimensionPixelSize(R.dimen.close_handle_height);
336338

337339
mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore);
338340

@@ -466,6 +468,10 @@ public int getStatusBarHeight() {
466468
return mNaturalBarHeight;
467469
}
468470

471+
private int getCloseViewHeight() {
472+
return mCloseViewHeight;
473+
}
474+
469475
private View.OnClickListener mRecentsClickListener = new View.OnClickListener() {
470476
public void onClick(View v) {
471477
toggleRecentApps();
@@ -1259,7 +1265,7 @@ void incrementAnim() {
12591265
}
12601266

12611267
void doRevealAnimation() {
1262-
final int h = mCloseView.getHeight() + getStatusBarHeight();
1268+
final int h = getCloseViewHeight() + getStatusBarHeight();
12631269
if (mAnimatingReveal && mAnimating && mAnimY < h) {
12641270
incrementAnim();
12651271
if (mAnimY >= h) {
@@ -1420,9 +1426,9 @@ boolean interceptTouchEvent(MotionEvent event) {
14201426
}
14211427
} else if (mTracking) {
14221428
trackMovement(event);
1423-
final int minY = statusBarSize + mCloseView.getHeight();
1429+
final int minY = statusBarSize + getCloseViewHeight();
14241430
if (action == MotionEvent.ACTION_MOVE) {
1425-
if (mAnimatingReveal && y < minY) {
1431+
if (mAnimatingReveal && (y + mViewDelta) < minY) {
14261432
// nothing
14271433
} else {
14281434
mAnimatingReveal = false;
@@ -1855,6 +1861,10 @@ void updateExpandedInvisiblePosition() {
18551861
mTrackingPosition = -mDisplayMetrics.heightPixels;
18561862
}
18571863

1864+
static final float saturate(float a) {
1865+
return a < 0f ? 0f : (a > 1f ? 1f : a);
1866+
}
1867+
18581868
void updateExpandedViewPos(int expandedPosition) {
18591869
if (SPEW) {
18601870
Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
@@ -1905,8 +1915,9 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
19051915
}
19061916
cropView.setLayoutParams(lp);
19071917
// woo, special effects
1908-
final float frac = (float)panelh / disph;
1909-
final int color = ((int)(0xB0 * Math.pow(frac, 0.5))) << 24;
1918+
final int barh = getCloseViewHeight() + getStatusBarHeight();
1919+
final float frac = saturate((float)(panelh - barh) / (disph - barh));
1920+
final int color = ((int)(0xB0 * Math.sin(frac * 1.57f))) << 24;
19101921
mStatusBarWindow.setBackgroundColor(color);
19111922

19121923
// Slog.d(TAG, String.format("updateExpanded: pos=%d frac=%.2f col=0x%08x", pos, frac, color));

0 commit comments

Comments
 (0)