Skip to content

Commit 5a8aefa

Browse files
committed
No more double-swiping to toggle panels on tablets.
This also fixes up the drag regions so that quick settings is only assigned the right 1/3 of the display (or 100dp, whichever is larger). It had been that more than half of the status bar, when dragged, would pull down QS. Bug: 7217002 Change-Id: I515b6e19deab305b99784c7287d8f04fa9b22dc7
1 parent 666d475 commit 5a8aefa

File tree

3 files changed

+42
-19
lines changed

3 files changed

+42
-19
lines changed

packages/SystemUI/res/values-sw600dp/dimens.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@
4040
<!-- Size of application thumbnail -->
4141
<dimen name="status_bar_recents_thumbnail_width">200dp</dimen>
4242
<dimen name="status_bar_recents_thumbnail_height">177dp</dimen>
43+
44+
<!-- On tablet-sized devices, we allocate the rightmost third(ish) of the draggable status bar
45+
to quick settings. -->
46+
<item type="dimen" name="settings_panel_dragzone_fraction">35%</item>
4347
</resources>

packages/SystemUI/res/values/dimens.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,13 @@
166166
<integer name="notification_panel_layout_gravity">0x37</integer>
167167
<integer name="settings_panel_layout_gravity">0x37</integer>
168168

169-
<!-- Quick settings panels minimum fling open target width. -->
170-
<dimen name="settings_panel_fling_gutter">90dp</dimen>
169+
<!-- Fraction of the status bar that, when dragged, will produce the quick settings panel
170+
instead of the notification panel. See also @dimen/settings_panel_dragzone_min.
171+
If zero, the settings panel will not be directly draggable from the status bar. -->
172+
<item type="dimen" name="settings_panel_dragzone_fraction">0%</item>
173+
174+
<!-- Quick settings dragzone, if used, should be at least this big (may be zero). -->
175+
<dimen name="settings_panel_dragzone_min">100dp</dimen>
171176

172177
<!-- Height of the carrier/wifi name label -->
173178
<dimen name="carrier_label_height">24dp</dimen>

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.content.Context;
2222
import android.content.res.Configuration;
2323
import android.content.res.Resources;
24+
import android.content.res.Resources.NotFoundException;
2425
import android.graphics.Canvas;
2526
import android.graphics.Color;
2627
import android.graphics.Rect;
@@ -46,8 +47,9 @@ public class PhoneStatusBarView extends PanelBar {
4647

4748
PhoneStatusBar mBar;
4849
int mScrimColor;
49-
float mMinFlingGutter;
50-
float mNotificationWidth;
50+
float mSettingsPanelDragzoneFrac;
51+
float mSettingsPanelDragzoneMin;
52+
5153
boolean mFullWidthNotifications;
5254
PanelView mFadingPanel = null;
5355
PanelView mNotificationPanel, mSettingsPanel;
@@ -64,13 +66,14 @@ public void setBar(PhoneStatusBar bar) {
6466
public void onAttachedToWindow() {
6567
Resources res = getContext().getResources();
6668
mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
67-
mMinFlingGutter = res.getDimension(R.dimen.settings_panel_fling_gutter);
68-
mFullWidthNotifications = false;
69+
mSettingsPanelDragzoneMin = res.getDimension(R.dimen.settings_panel_dragzone_min);
6970
try {
70-
mNotificationWidth = res.getDimension(R.dimen.notification_panel_width);
71-
} catch (Resources.NotFoundException ex) {
72-
mFullWidthNotifications = true;
71+
mSettingsPanelDragzoneFrac = res.getFraction(R.dimen.settings_panel_dragzone_fraction, 1, 1);
72+
} catch (NotFoundException ex) {
73+
mSettingsPanelDragzoneFrac = 0f;
7374
}
75+
76+
mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f;
7477
}
7578

7679
@Override
@@ -105,19 +108,30 @@ public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent ev
105108

106109
@Override
107110
public PanelView selectPanelForTouchX(float x) {
108-
// We split the status bar into thirds: the left 2/3 are for notifications, and the
111+
if (mFullWidthNotifications) {
112+
if (DEBUG) {
113+
Slog.v(TAG, "notif frac=" + mNotificationPanel.getExpandedFraction());
114+
}
115+
return (mNotificationPanel.getExpandedFraction() == 1.0f)
116+
? mSettingsPanel : mNotificationPanel;
117+
}
118+
119+
// We split the status bar into thirds: the left 2/3 are for notifications, and the
109120
// right 1/3 for quick settings. If you pull the status bar down a second time you'll
110121
// toggle panels no matter where you pull it down.
122+
111123
final float w = (float) getMeasuredWidth();
112-
final float gutter = w - mNotificationWidth;
113-
final boolean useGutter = !mFullWidthNotifications && gutter > mMinFlingGutter;
114-
final float threshold = 1.0f - (gutter / w);
115-
final float f = x / w;
116-
if ((useGutter && f > threshold && mSettingsPanel.getExpandedFraction() != 1.0f) ||
117-
mNotificationPanel.getExpandedFraction() == 1.0f) {
118-
return mSettingsPanel;
124+
float region = (w * mSettingsPanelDragzoneFrac);
125+
126+
if (DEBUG) {
127+
Slog.v(TAG, String.format(
128+
"w=%.1f frac=%.3f region=%.1f min=%.1f x=%.1f w-x=%.1f",
129+
w, mSettingsPanelDragzoneFrac, region, mSettingsPanelDragzoneMin, x, (w-x)));
119130
}
120-
return mNotificationPanel;
131+
132+
if (region < mSettingsPanelDragzoneMin) region = mSettingsPanelDragzoneMin;
133+
134+
return (w - x < region) ? mSettingsPanel : mNotificationPanel;
121135
}
122136

123137
@Override
@@ -159,7 +173,7 @@ public void panelExpansionChanged(PanelView pv, float frac) {
159173
Slog.v(TAG, "panelExpansionChanged: f=" + frac);
160174
}
161175

162-
if (mFadingPanel == pv
176+
if (mFadingPanel == pv
163177
&& mScrimColor != 0 && ActivityManager.isHighEndGfx()) {
164178
// woo, special effects
165179
final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2.2f))));

0 commit comments

Comments
 (0)