Skip to content

Commit efb0faf

Browse files
committed
Remove the double-swipe to access quick settings on phones.
On the plus side, the settings button is back! Now that we have two buttons on the right-hand side it's more important than ever that the notification panel header not allow errant taps to go all the way back to the notification panel, where they will drag/close it. Bug: 7319756 // remove double-swipe Bug: 7217201 // finally make the notification header black Change-Id: I8b2d6c7a7cfaaed2bfbcd61fb45db9f234cb002d
1 parent eb21452 commit efb0faf

File tree

9 files changed

+77
-38
lines changed

9 files changed

+77
-38
lines changed
-218 Bytes
Binary file not shown.
-209 Bytes
Binary file not shown.
-252 Bytes
Binary file not shown.

packages/SystemUI/res/layout/status_bar_expanded_header.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<LinearLayout
1919
xmlns:android="http://schemas.android.com/apk/res/android"
2020
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
21+
android:id="@+id/header"
2122
android:layout_width="match_parent"
2223
android:layout_height="wrap_content"
2324
android:background="@drawable/notification_header_bg"
@@ -61,9 +62,18 @@
6162
android:padding="2dp"
6263
/>
6364

65+
<ImageView android:id="@+id/settings_button"
66+
android:layout_width="50dp"
67+
android:layout_height="50dp"
68+
android:scaleType="center"
69+
android:src="@drawable/ic_notify_quicksettings"
70+
android:contentDescription="@string/accessibility_settings_button"
71+
/>
72+
6473
<ImageView android:id="@+id/clear_all_button"
65-
android:layout_width="48dp"
66-
android:layout_height="48dp"
74+
android:layout_width="50dp"
75+
android:layout_height="50dp"
76+
android:layout_marginLeft="18dp"
6777
android:scaleType="center"
6878
android:src="@drawable/ic_notify_clear"
6979
android:contentDescription="@string/accessibility_clear_all"

packages/SystemUI/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<drawable name="recents_callout_line">#99ffffff</drawable>
2929
<drawable name="notification_item_background_legacy_color">#ffaaaaaa</drawable>
3030
<drawable name="intruder_bg_pressed">#ff33B5E5</drawable>
31+
<drawable name="notification_header_bg">#FF000000</drawable>
3132

3233
<!-- ==================== system bar only ==================== -->
3334
<drawable name="system_bar_background">#ff000000</drawable>

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public float getBarHeight() {
6868
return getMeasuredHeight();
6969
}
7070

71-
public PanelView selectPanelForTouchX(float x) {
71+
public PanelView selectPanelForTouch(MotionEvent touch) {
7272
final int N = mPanels.size();
73-
return mPanels.get((int)(N * x / getMeasuredWidth()));
73+
return mPanels.get((int)(N * touch.getX() / getMeasuredWidth()));
7474
}
7575

7676
public boolean panelsEnabled() {
@@ -84,15 +84,26 @@ public boolean onTouchEvent(MotionEvent event) {
8484

8585
// figure out which panel needs to be talked to here
8686
if (event.getAction() == MotionEvent.ACTION_DOWN) {
87-
final PanelView panel = selectPanelForTouchX(event.getX());
87+
final PanelView panel = selectPanelForTouch(event);
88+
if (panel == null) {
89+
// panel is not there, so we'll eat the gesture
90+
if (DEBUG) LOG("PanelBar.onTouch: no panel for x=%d, bailing", event.getX());
91+
mTouchingPanel = null;
92+
return true;
93+
}
8894
boolean enabled = panel.isEnabled();
8995
if (DEBUG) LOG("PanelBar.onTouch: state=%d ACTION_DOWN: panel %s %s", mState, panel,
9096
(enabled ? "" : " (disabled)"));
91-
if (!enabled)
92-
return false;
97+
if (!enabled) {
98+
// panel is disabled, so we'll eat the gesture
99+
mTouchingPanel = null;
100+
return true;
101+
}
93102
startOpeningPanel(panel);
94103
}
95-
final boolean result = mTouchingPanel.getHandle().dispatchTouchEvent(event);
104+
final boolean result = mTouchingPanel != null
105+
? mTouchingPanel.getHandle().dispatchTouchEvent(event)
106+
: true;
96107
return result;
97108
}
98109

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public final void LOG(String fmt, Object... args) {
2323
}
2424

2525
public static final boolean BRAKES = false;
26-
private static final boolean STRETCH_PAST_CONTENTS = true;
26+
private boolean mRubberbandingEnabled = true;
2727

2828
private float mSelfExpandVelocityPx; // classic value: 2000px/s
2929
private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up")
@@ -86,6 +86,10 @@ public void run() {
8686
protected float mInitialTouchY;
8787
protected float mFinalTouchY;
8888

89+
public void setRubberbandingEnabled(boolean enable) {
90+
mRubberbandingEnabled = enable;
91+
}
92+
8993
private void runPeekAnimation() {
9094
if (DEBUG) LOG("peek to height=%.1f", mPeekHeight);
9195
if (mTimeAnimator.isStarted()) {
@@ -109,7 +113,7 @@ private void animationTick(long dtms) {
109113

110114
mTimeAnimator.start();
111115

112-
mRubberbanding = STRETCH_PAST_CONTENTS // is it enabled at all?
116+
mRubberbanding = mRubberbandingEnabled // is it enabled at all?
113117
&& mExpandedHeight > getFullHeight() // are we past the end?
114118
&& mVel >= -mFlingGestureMinDistPx; // was this not possibly a "close" gesture?
115119
if (mRubberbanding) {
@@ -413,7 +417,7 @@ public void setExpandedHeightInternal(float h) {
413417
}
414418

415419
if (h < 0) h = 0;
416-
if (!(STRETCH_PAST_CONTENTS && (mTracking || mRubberbanding)) && h > fh) h = fh;
420+
if (!(mRubberbandingEnabled && (mTracking || mRubberbanding)) && h > fh) h = fh;
417421
mExpandedHeight = h;
418422

419423
if (DEBUG) LOG("setExpansion: height=%.1f fh=%.1f tracking=%s rubber=%s", h, fh, mTracking?"T":"f", mRubberbanding?"T":"f");

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

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ public boolean onTouch(View v, MotionEvent event) {
344344

345345
mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar);
346346
mStatusBarView.setBar(this);
347+
347348

348349
PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder);
349350
mStatusBarView.setPanelHolder(holder);
@@ -356,6 +357,15 @@ public boolean onTouch(View v, MotionEvent event) {
356357
View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS |
357358
View.STATUS_BAR_DISABLE_CLOCK);
358359

360+
// make the header non-responsive to clicks
361+
mNotificationPanel.findViewById(R.id.header).setOnTouchListener(
362+
new View.OnTouchListener() {
363+
@Override
364+
public boolean onTouch(View v, MotionEvent event) {
365+
return true; // e eats everything
366+
}
367+
});
368+
359369
if (!ActivityManager.isHighEndGfx()) {
360370
mStatusBarWindow.setBackground(null);
361371
mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor(
@@ -410,7 +420,12 @@ public boolean onTouch(View v, MotionEvent event) {
410420
mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date);
411421
mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button);
412422
if (mSettingsButton != null) {
413-
mSettingsButton.setOnClickListener(mSettingsButtonListener);
423+
if (mStatusBarView.hasFullWidthNotifications()) {
424+
mSettingsButton.setOnClickListener(mSettingsButtonListener);
425+
mSettingsButton.setVisibility(View.VISIBLE);
426+
} else {
427+
mSettingsButton.setVisibility(View.GONE);
428+
}
414429
}
415430

416431
mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll);
@@ -1900,18 +1915,7 @@ public void run() {
19001915

19011916
private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
19021917
public void onClick(View v) {
1903-
// We take this as a good indicator that Setup is running and we shouldn't
1904-
// allow you to go somewhere else
1905-
if (!isDeviceProvisioned()) return;
1906-
try {
1907-
// Dismiss the lock screen when Settings starts.
1908-
ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity();
1909-
} catch (RemoteException e) {
1910-
}
1911-
v.getContext().startActivityAsUser(new Intent(Settings.ACTION_SETTINGS)
1912-
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
1913-
new UserHandle(UserHandle.USER_CURRENT));
1914-
animateCollapsePanels();
1918+
animateExpandSettingsPanel();
19151919
}
19161920
};
19171921

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

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ public class PhoneStatusBarView extends PanelBar {
4545

4646
public PhoneStatusBarView(Context context, AttributeSet attrs) {
4747
super(context, attrs);
48-
}
49-
50-
public void setBar(PhoneStatusBar bar) {
51-
mBar = bar;
52-
}
5348

54-
@Override
55-
public void onAttachedToWindow() {
5649
Resources res = getContext().getResources();
5750
mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
5851
mSettingsPanelDragzoneMin = res.getDimension(R.dimen.settings_panel_dragzone_min);
@@ -61,10 +54,24 @@ public void onAttachedToWindow() {
6154
} catch (NotFoundException ex) {
6255
mSettingsPanelDragzoneFrac = 0f;
6356
}
64-
6557
mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f;
6658
}
6759

60+
public void setBar(PhoneStatusBar bar) {
61+
mBar = bar;
62+
}
63+
64+
public boolean hasFullWidthNotifications() {
65+
return mFullWidthNotifications;
66+
}
67+
68+
@Override
69+
public void onAttachedToWindow() {
70+
for (PanelView pv : mPanels) {
71+
pv.setRubberbandingEnabled(!mFullWidthNotifications);
72+
}
73+
}
74+
6875
@Override
6976
public void addPanel(PanelView pv) {
7077
super.addPanel(pv);
@@ -73,6 +80,7 @@ public void addPanel(PanelView pv) {
7380
} else if (pv.getId() == R.id.settings_panel){
7481
mSettingsPanel = pv;
7582
}
83+
pv.setRubberbandingEnabled(!mFullWidthNotifications);
7684
}
7785

7886
@Override
@@ -96,13 +104,14 @@ public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent ev
96104
}
97105

98106
@Override
99-
public PanelView selectPanelForTouchX(float x) {
107+
public PanelView selectPanelForTouch(MotionEvent touch) {
108+
final float x = touch.getX();
109+
100110
if (mFullWidthNotifications) {
101-
if (DEBUG) {
102-
Slog.v(TAG, "notif frac=" + mNotificationPanel.getExpandedFraction());
103-
}
104-
return (mNotificationPanel.getExpandedFraction() > 0f)
105-
? mSettingsPanel : mNotificationPanel;
111+
// No double swiping. If either panel is open, nothing else can be pulled down.
112+
return (mSettingsPanel.getExpandedHeight() + mNotificationPanel.getExpandedHeight()> 0)
113+
? null
114+
: mNotificationPanel;
106115
}
107116

108117
// We split the status bar into thirds: the left 2/3 are for notifications, and the

0 commit comments

Comments
 (0)