diff options
author | Daniel Sandler <dsandler@android.com> | 2012-09-25 01:21:12 -0400 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-09-25 10:20:00 -0400 |
commit | 5a8aefa6c8ab2f129bc6477a49cd0876ec5d72fa (patch) | |
tree | d4c194b57b8b3a3094e6e76f8dab6b39a223ad6a /packages | |
parent | 666d47502b7a4cf410dc36cac5d42e43f3bc3701 (diff) | |
download | frameworks_base-5a8aefa6c8ab2f129bc6477a49cd0876ec5d72fa.zip frameworks_base-5a8aefa6c8ab2f129bc6477a49cd0876ec5d72fa.tar.gz frameworks_base-5a8aefa6c8ab2f129bc6477a49cd0876ec5d72fa.tar.bz2 |
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
Diffstat (limited to 'packages')
3 files changed, 42 insertions, 19 deletions
diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index b6faff3..a687571 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -40,4 +40,8 @@ <!-- Size of application thumbnail --> <dimen name="status_bar_recents_thumbnail_width">200dp</dimen> <dimen name="status_bar_recents_thumbnail_height">177dp</dimen> + + <!-- On tablet-sized devices, we allocate the rightmost third(ish) of the draggable status bar + to quick settings. --> + <item type="dimen" name="settings_panel_dragzone_fraction">35%</item> </resources> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index e93e857..13cda3a 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -166,8 +166,13 @@ <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> + <!-- Fraction of the status bar that, when dragged, will produce the quick settings panel + instead of the notification panel. See also @dimen/settings_panel_dragzone_min. + If zero, the settings panel will not be directly draggable from the status bar. --> + <item type="dimen" name="settings_panel_dragzone_fraction">0%</item> + + <!-- Quick settings dragzone, if used, should be at least this big (may be zero). --> + <dimen name="settings_panel_dragzone_min">100dp</dimen> <!-- Height of the carrier/wifi name label --> <dimen name="carrier_label_height">24dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index 95b618a..6517e7c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -21,6 +21,7 @@ import android.app.StatusBarManager; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.content.res.Resources.NotFoundException; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Rect; @@ -46,8 +47,9 @@ public class PhoneStatusBarView extends PanelBar { PhoneStatusBar mBar; int mScrimColor; - float mMinFlingGutter; - float mNotificationWidth; + float mSettingsPanelDragzoneFrac; + float mSettingsPanelDragzoneMin; + boolean mFullWidthNotifications; PanelView mFadingPanel = null; PanelView mNotificationPanel, mSettingsPanel; @@ -64,13 +66,14 @@ 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; + mSettingsPanelDragzoneMin = res.getDimension(R.dimen.settings_panel_dragzone_min); try { - mNotificationWidth = res.getDimension(R.dimen.notification_panel_width); - } catch (Resources.NotFoundException ex) { - mFullWidthNotifications = true; + mSettingsPanelDragzoneFrac = res.getFraction(R.dimen.settings_panel_dragzone_fraction, 1, 1); + } catch (NotFoundException ex) { + mSettingsPanelDragzoneFrac = 0f; } + + mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f; } @Override @@ -105,19 +108,30 @@ public class PhoneStatusBarView extends PanelBar { @Override public PanelView selectPanelForTouchX(float x) { - // We split the status bar into thirds: the left 2/3 are for notifications, and the + if (mFullWidthNotifications) { + if (DEBUG) { + Slog.v(TAG, "notif frac=" + mNotificationPanel.getExpandedFraction()); + } + return (mNotificationPanel.getExpandedFraction() == 1.0f) + ? mSettingsPanel : mNotificationPanel; + } + + // We split the status bar into thirds: the left 2/3 are for notifications, and the // 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 ((useGutter && f > threshold && mSettingsPanel.getExpandedFraction() != 1.0f) || - mNotificationPanel.getExpandedFraction() == 1.0f) { - return mSettingsPanel; + float region = (w * mSettingsPanelDragzoneFrac); + + if (DEBUG) { + Slog.v(TAG, String.format( + "w=%.1f frac=%.3f region=%.1f min=%.1f x=%.1f w-x=%.1f", + w, mSettingsPanelDragzoneFrac, region, mSettingsPanelDragzoneMin, x, (w-x))); } - return mNotificationPanel; + + if (region < mSettingsPanelDragzoneMin) region = mSettingsPanelDragzoneMin; + + return (w - x < region) ? mSettingsPanel : mNotificationPanel; } @Override @@ -159,7 +173,7 @@ public class PhoneStatusBarView extends PanelBar { Slog.v(TAG, "panelExpansionChanged: f=" + frac); } - if (mFadingPanel == pv + if (mFadingPanel == pv && mScrimColor != 0 && ActivityManager.isHighEndGfx()) { // woo, special effects final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2.2f)))); |