am e370c468: Merge "[phones] Only allow double-flick opening of the quicksettings panel." into jb-mr1-dev

* commit 'e370c468221bfef8f73c20f9d013cd22f06e2da7':
  [phones] Only allow double-flick opening of the quicksettings panel.
This commit is contained in:
Chris Wren
2012-08-24 09:27:01 -07:00
committed by Android Git Automerger
2 changed files with 18 additions and 2 deletions

View File

@@ -164,6 +164,9 @@
<integer name="notification_panel_layout_gravity">0x37</integer>
<integer name="settings_panel_layout_gravity">0x37</integer>
<!-- Quick settings panels minimum fling open target width. -->
<dimen name="settings_panel_fling_gutter">90dp</dimen>
<!-- Height of the carrier/wifi name label -->
<dimen name="carrier_label_height">24dp</dimen>

View File

@@ -43,6 +43,9 @@ public class PhoneStatusBarView extends PanelBar {
private static final String TAG = "PhoneStatusBarView";
PhoneStatusBar mBar;
int mScrimColor;
float mMinFlingGutter;
float mNotificationWidth;
boolean mFullWidthNotifications;
PanelView mFadingPanel = null;
PanelView mNotificationPanel, mSettingsPanel;
@@ -58,6 +61,13 @@ public class PhoneStatusBarView extends PanelBar {
public void onAttachedToWindow() {
Resources res = getContext().getResources();
mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
mMinFlingGutter = res.getDimension(R.dimen.settings_panel_fling_gutter);
mFullWidthNotifications = false;
try {
mNotificationWidth = res.getDimension(R.dimen.notification_panel_width);
} catch (Resources.NotFoundException ex) {
mFullWidthNotifications = true;
}
}
@Override
@@ -96,9 +106,12 @@ public class PhoneStatusBarView extends PanelBar {
// right 1/3 for quick settings. If you pull the status bar down a second time you'll
// toggle panels no matter where you pull it down.
final float w = (float) getMeasuredWidth();
final float gutter = w - mNotificationWidth;
final boolean useGutter = !mFullWidthNotifications && gutter > mMinFlingGutter;
final float threshold = 1.0f - (gutter / w);
final float f = x / w;
if (f > 0.67f && mSettingsPanel.getExpandedFraction() != 1.0f
|| mNotificationPanel.getExpandedFraction() == 1.0f) {
if ((useGutter && f > threshold && mSettingsPanel.getExpandedFraction() != 1.0f) ||
mNotificationPanel.getExpandedFraction() == 1.0f) {
return mSettingsPanel;
}
return mNotificationPanel;