Skip to content

Commit 173bae2

Browse files
committed
Improvements to notification/settings panels:
A) Hide icons corresponding to the active panel with a downward push animation. Notes: 1. this animation will now apply any time the status bar icons are disabled via DISABLE_NOTIFICATION_ICONS. 2. DISABLE_SYSTEM_INFO will now only hide the right hand icons (system status icons, battery, clock). But you weren't using it anyway, right? B) Stop pulling down the panels in response to just a touch on the status bar. (That should never have worked.) In general, we now require that a fling proceed more than 10dp to be treated as a fling with velocity (as opposed to a v=0 fling, or "let-go"). C) If a panel is pulled down more than halfway and then let go with v=0, it is expanded. If less than halfway, it is contracted. (Helps fix B) above, plus it just makes good sense.) Bug: 7211541 (A) Bug: 7227237 (B) Bug: 7228541 (B) Change-Id: I5662269b753376804bf629239835dc212716d5c3
1 parent a8a7e71 commit 173bae2

File tree

5 files changed

+124
-118
lines changed

5 files changed

+124
-118
lines changed

packages/SystemUI/res/layout/status_bar.xml

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
android:layout_width="@dimen/status_bar_icon_size"
3636
android:layout_height="match_parent"
3737
android:paddingLeft="6dip"
38-
android:paddingBottom="2dip"
38+
android:paddingBottom="2dip"
3939
android:src="@drawable/ic_sysbar_lights_out_dot_small"
4040
android:scaleType="center"
4141
android:visibility="gone"
4242
/>
4343

44-
<LinearLayout android:id="@+id/icons"
44+
<LinearLayout android:id="@+id/status_bar_contents"
4545
android:layout_width="match_parent"
4646
android:layout_height="match_parent"
4747
android:paddingLeft="6dip"
@@ -50,7 +50,7 @@
5050
>
5151

5252
<LinearLayout
53-
android:id="@+id/notification_icon_area"
53+
android:id="@+id/notification_icon_area"
5454
android:layout_width="0dip"
5555
android:layout_height="match_parent"
5656
android:layout_weight="1"
@@ -71,42 +71,48 @@
7171
android:orientation="horizontal"/>
7272
</LinearLayout>
7373

74-
<LinearLayout android:id="@+id/statusIcons"
74+
<LinearLayout android:id="@+id/system_icon_area"
7575
android:layout_width="wrap_content"
7676
android:layout_height="match_parent"
77-
android:gravity="center_vertical"
78-
android:orientation="horizontal"/>
77+
android:orientation="horizontal">
7978

80-
<LinearLayout
81-
android:id="@+id/signal_battery_cluster"
82-
android:layout_width="wrap_content"
83-
android:layout_height="match_parent"
84-
android:paddingLeft="2dp"
85-
android:orientation="horizontal"
86-
android:gravity="center"
87-
>
88-
<include layout="@layout/signal_cluster_view"
89-
android:id="@+id/signal_cluster"
79+
<LinearLayout android:id="@+id/statusIcons"
9080
android:layout_width="wrap_content"
91-
android:layout_height="wrap_content"
92-
/>
93-
<ImageView
94-
android:id="@+id/battery"
95-
android:layout_height="wrap_content"
81+
android:layout_height="match_parent"
82+
android:gravity="center_vertical"
83+
android:orientation="horizontal"/>
84+
85+
<LinearLayout
86+
android:id="@+id/signal_battery_cluster"
87+
android:layout_width="wrap_content"
88+
android:layout_height="match_parent"
89+
android:paddingLeft="2dp"
90+
android:orientation="horizontal"
91+
android:gravity="center"
92+
>
93+
<include layout="@layout/signal_cluster_view"
94+
android:id="@+id/signal_cluster"
95+
android:layout_width="wrap_content"
96+
android:layout_height="wrap_content"
97+
/>
98+
<ImageView
99+
android:id="@+id/battery"
100+
android:layout_height="wrap_content"
101+
android:layout_width="wrap_content"
102+
android:paddingLeft="4dip"
103+
/>
104+
</LinearLayout>
105+
106+
<com.android.systemui.statusbar.policy.Clock
107+
android:id="@+id/clock"
108+
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
96109
android:layout_width="wrap_content"
97-
android:paddingLeft="4dip"
110+
android:layout_height="match_parent"
111+
android:singleLine="true"
112+
android:paddingLeft="6dip"
113+
android:gravity="center_vertical|left"
98114
/>
99115
</LinearLayout>
100-
101-
<com.android.systemui.statusbar.policy.Clock
102-
android:id="@+id/clock"
103-
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
104-
android:layout_width="wrap_content"
105-
android:layout_height="match_parent"
106-
android:singleLine="true"
107-
android:paddingLeft="6dip"
108-
android:gravity="center_vertical|left"
109-
/>
110116
</LinearLayout>
111117

112118
<LinearLayout android:id="@+id/ticker"

packages/SystemUI/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
<!-- Cap on overall resulting fling speed (s^-1) -->
108108
<dimen name="fling_gesture_max_output_velocity">3000dp</dimen>
109109

110+
<!-- Minimum distance a fling must travel (anti-jitter) -->
111+
<dimen name="fling_gesture_min_dist">10dp</dimen>
112+
110113
<!-- Minimum fraction of the display a gesture must travel, at any velocity, to qualify as a
111114
collapse request -->
112115
<item type="dimen" name="collapse_min_display_fraction">10%</item>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.util.AttributeSet;
77
import android.util.Slog;
88
import android.view.MotionEvent;
9+
import android.view.View;
910
import android.widget.FrameLayout;
1011

1112
public class PanelBar extends FrameLayout {
@@ -101,6 +102,7 @@ public void panelExpansionChanged(PanelView panel, float frac) {
101102
PanelView fullyOpenedPanel = null;
102103
LOG("panelExpansionChanged: start state=%d panel=%s", mState, panel.getName());
103104
for (PanelView pv : mPanels) {
105+
final boolean visible = pv.getVisibility() == View.VISIBLE;
104106
// adjust any other panels that may be partially visible
105107
if (pv.getExpandedHeight() > 0f) {
106108
if (mState == STATE_CLOSED) {
@@ -116,6 +118,11 @@ public void panelExpansionChanged(PanelView panel, float frac) {
116118
pv.setExpandedFraction(1f-frac);
117119
}
118120
}
121+
if (pv.getExpandedHeight() > 0f) {
122+
if (!visible) pv.setVisibility(View.VISIBLE);
123+
} else {
124+
if (visible) pv.setVisibility(View.GONE);
125+
}
119126
}
120127
if (fullyOpenedPanel != null && !mTracking) {
121128
go(STATE_OPEN);
@@ -138,6 +145,7 @@ public void collapseAllPanels(boolean animate) {
138145
} else {
139146
pv.setExpandedFraction(0); // just in case
140147
}
148+
pv.setVisibility(View.GONE);
141149
}
142150
if (!waiting) {
143151
// it's possible that nothing animated, so we replicate the termination

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public final void LOG(String fmt, Object... args) {
3737
private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand)
3838
private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s
3939

40+
private float mFlingGestureMinDistPx;
41+
4042
private float mExpandAccelPx; // classic value: 2000px/s/s
4143
private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up")
4244

@@ -78,6 +80,8 @@ public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime)
7880
private float mVel, mAccel;
7981
private int mFullHeight = 0;
8082
private String mViewName;
83+
protected float mInitialTouchY;
84+
protected float mFinalTouchY;
8185

8286
private void animationTick(long dtms) {
8387
if (!mTimeAnimator.isStarted()) {
@@ -88,7 +92,14 @@ private void animationTick(long dtms) {
8892
mTimeAnimator.start();
8993

9094
mRubberbanding = STRETCH_PAST_CONTENTS && mExpandedHeight > getFullHeight();
91-
mClosing = (mExpandedHeight > 0 && mVel < 0) || mRubberbanding;
95+
if (mRubberbanding) {
96+
mClosing = true;
97+
} else if (mVel == 0) {
98+
// if the panel is less than halfway open, close it
99+
mClosing = (mFinalTouchY / getFullHeight()) < 0.5f;
100+
} else {
101+
mClosing = mExpandedHeight > 0 && mVel < 0;
102+
}
92103
} else if (dtms > 0) {
93104
final float dt = dtms * 0.001f; // ms -> s
94105
LOG("tick: v=%.2fpx/s dt=%.4fs", mVel, dt);
@@ -159,6 +170,8 @@ private void loadDimens() {
159170
mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity);
160171
mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity);
161172

173+
mFlingGestureMinDistPx = res.getDimension(R.dimen.fling_gesture_min_dist);
174+
162175
mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1);
163176
mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1);
164177

@@ -207,6 +220,7 @@ public boolean onTouch(View v, MotionEvent event) {
207220
switch (event.getAction()) {
208221
case MotionEvent.ACTION_DOWN:
209222
mTracking = true;
223+
mInitialTouchY = y;
210224
mVelocityTracker = VelocityTracker.obtain();
211225
trackMovement(event);
212226
mBar.onTrackingStarted(PanelView.this);
@@ -223,6 +237,7 @@ public boolean onTouch(View v, MotionEvent event) {
223237

224238
case MotionEvent.ACTION_UP:
225239
case MotionEvent.ACTION_CANCEL:
240+
mFinalTouchY = y;
226241
mTracking = false;
227242
mBar.onTrackingStopped(PanelView.this);
228243
trackMovement(event);
@@ -243,11 +258,21 @@ public boolean onTouch(View v, MotionEvent event) {
243258
if (vel > mFlingGestureMaxOutputVelocityPx) {
244259
vel = mFlingGestureMaxOutputVelocityPx;
245260
}
261+
262+
// if you've barely moved your finger, we treat the velocity as 0
263+
// preventing spurious flings due to touch screen jitter
264+
final float deltaY = (float)Math.abs(mFinalTouchY - mInitialTouchY);
265+
if (deltaY < mFlingGestureMinDistPx
266+
|| vel < mFlingGestureMinDistPx) {
267+
vel = 0;
268+
}
269+
246270
if (negative) {
247271
vel = -vel;
248272
}
249273

250-
LOG("gesture: vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f",
274+
LOG("gesture: dy=%f vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f",
275+
deltaY,
251276
mVelocityTracker.getXVelocity(),
252277
mVelocityTracker.getYVelocity(),
253278
xVel, yVel,

0 commit comments

Comments
 (0)