2121import android .content .Context ;
2222import android .content .res .Configuration ;
2323import android .content .res .Resources ;
24+ import android .content .res .Resources .NotFoundException ;
2425import android .graphics .Canvas ;
2526import android .graphics .Color ;
2627import 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