1717package com .android .systemui .statusbar .phone ;
1818
1919import android .animation .Animator ;
20+ import android .animation .Animator .AnimatorListener ;
2021import android .animation .AnimatorListenerAdapter ;
2122import android .animation .AnimatorSet ;
2223import android .animation .ObjectAnimator ;
8586import com .android .systemui .statusbar .policy .DateView ;
8687import com .android .systemui .statusbar .policy .IntruderAlertView ;
8788import com .android .systemui .statusbar .policy .LocationController ;
89+ import com .android .systemui .statusbar .policy .OnSizeChangedListener ;
8890import com .android .systemui .statusbar .policy .NetworkController ;
8991import com .android .systemui .statusbar .policy .NotificationRowLayout ;
9092
@@ -104,7 +106,8 @@ public class PhoneStatusBar extends BaseStatusBar {
104106 public static final String ACTION_STATUSBAR_START
105107 = "com.android.internal.policy.statusbar.START" ;
106108
107- private static final boolean DIM_BEHIND_EXPANDED_PANEL = false ;
109+ private static final boolean DIM_BEHIND_EXPANDED_PANEL = true ;
110+ private static final boolean SHOW_CARRIER_LABEL = true ;
108111
109112 private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000 ;
110113 private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001 ;
@@ -169,6 +172,11 @@ public class PhoneStatusBar extends BaseStatusBar {
169172 View mSettingsButton ;
170173 RotationToggle mRotationButton ;
171174
175+ // carrier/wifi label
176+ private TextView mCarrierLabel ;
177+ private boolean mCarrierLabelVisible = false ;
178+ private int mCarrierLabelHeight ;
179+
172180 // drag bar
173181 CloseDragHandle mCloseView ;
174182 private int mCloseViewHeight ;
@@ -386,6 +394,14 @@ public boolean onTouch(View v, MotionEvent event) {
386394
387395 mPile = (NotificationRowLayout )mStatusBarWindow .findViewById (R .id .latestItems );
388396 mPile .setLongPressListener (getNotificationLongClicker ());
397+ if (SHOW_CARRIER_LABEL ) {
398+ mPile .setOnSizeChangedListener (new OnSizeChangedListener () {
399+ @ Override
400+ public void onSizeChanged (View view , int w , int h , int oldw , int oldh ) {
401+ updateCarrierLabelVisibility ();
402+ }
403+ });
404+ }
389405 mExpandedContents = mPile ; // was: expanded.findViewById(R.id.notificationLinearLayout);
390406
391407 mClearButton = mStatusBarWindow .findViewById (R .id .clear_all_button );
@@ -397,6 +413,9 @@ public boolean onTouch(View v, MotionEvent event) {
397413 mSettingsButton = mStatusBarWindow .findViewById (R .id .settings_button );
398414 mSettingsButton .setOnClickListener (mSettingsButtonListener );
399415 mRotationButton = (RotationToggle ) mStatusBarWindow .findViewById (R .id .rotation_lock_button );
416+
417+ mCarrierLabel = (TextView )mStatusBarWindow .findViewById (R .id .carrier_label );
418+ mCarrierLabel .setVisibility (mCarrierLabelVisible ? View .VISIBLE : View .INVISIBLE );
400419
401420 mScrollView = (ScrollView )mStatusBarWindow .findViewById (R .id .scroll );
402421 mScrollView .setVerticalScrollBarEnabled (false ); // less drawing during pulldowns
@@ -422,8 +441,17 @@ public boolean onTouch(View v, MotionEvent event) {
422441 mNetworkController = new NetworkController (mContext );
423442 final SignalClusterView signalCluster =
424443 (SignalClusterView )mStatusBarView .findViewById (R .id .signal_cluster );
444+
425445 mNetworkController .addSignalCluster (signalCluster );
426446 signalCluster .setNetworkController (mNetworkController );
447+
448+ // for wifi-only devices, we show SSID; otherwise, we show PLMN
449+ if (mNetworkController .hasMobileDataFeature ()) {
450+ mNetworkController .addMobileLabelView (mCarrierLabel );
451+ } else {
452+ mNetworkController .addWifiLabelView (mCarrierLabel );
453+ }
454+
427455// final ImageView wimaxRSSI =
428456// (ImageView)sb.findViewById(R.id.wimax_signal);
429457// if (wimaxRSSI != null) {
@@ -862,6 +890,45 @@ protected void updateNotificationIcons() {
862890 }
863891 }
864892
893+ protected void updateCarrierLabelVisibility () {
894+ if (!SHOW_CARRIER_LABEL ) return ;
895+ // The idea here is to only show the carrier label when there is enough room to see it,
896+ // i.e. when there aren't enough notifications to fill the panel.
897+ if (DEBUG ) {
898+ Slog .d (TAG , String .format ("pileh=%d scrollh=%d carrierh=%d" ,
899+ mPile .getHeight (), mScrollView .getHeight (), mCarrierLabelHeight ));
900+ }
901+
902+ final boolean makeVisible =
903+ mPile .getHeight () < (mScrollView .getHeight () - mCarrierLabelHeight );
904+
905+ if (mCarrierLabelVisible != makeVisible ) {
906+ mCarrierLabelVisible = makeVisible ;
907+ if (DEBUG ) {
908+ Slog .d (TAG , "making carrier label " + (makeVisible ?"visible" :"invisible" ));
909+ }
910+ mCarrierLabel .animate ().cancel ();
911+ if (makeVisible ) {
912+ mCarrierLabel .setVisibility (View .VISIBLE );
913+ }
914+ mCarrierLabel .animate ()
915+ .alpha (makeVisible ? 1f : 0f )
916+ //.setStartDelay(makeVisible ? 500 : 0)
917+ //.setDuration(makeVisible ? 750 : 100)
918+ .setDuration (150 )
919+ .setListener (makeVisible ? null : new AnimatorListenerAdapter () {
920+ @ Override
921+ public void onAnimationEnd (Animator animation ) {
922+ if (!mCarrierLabelVisible ) { // race
923+ mCarrierLabel .setVisibility (View .INVISIBLE );
924+ mCarrierLabel .setAlpha (0f );
925+ }
926+ }
927+ })
928+ .start ();
929+ }
930+ }
931+
865932 @ Override
866933 protected void setAreThereNotifications () {
867934 final boolean any = mNotificationData .size () > 0 ;
@@ -919,6 +986,8 @@ public void onAnimationEnd(Animator _a) {
919986 })
920987 .start ();
921988 }
989+
990+ updateCarrierLabelVisibility ();
922991 }
923992
924993 public void showClock (boolean show ) {
@@ -1078,6 +1147,8 @@ private void makeExpandedVisible(boolean revealAfterDraw) {
10781147 mExpandedVisible = true ;
10791148 makeSlippery (mNavigationBarView , true );
10801149
1150+ updateCarrierLabelVisibility ();
1151+
10811152 updateExpandedViewPos (EXPANDED_LEAVE_ALONE );
10821153
10831154 // Expand the window to encompass the full screen in anticipation of the drag.
@@ -1933,6 +2004,8 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
19332004 panelh = 0 ;
19342005 }
19352006
2007+ if (panelh == mTrackingPosition ) return ;
2008+
19362009 mTrackingPosition = panelh ;
19372010
19382011 FrameLayout .LayoutParams lp = (FrameLayout .LayoutParams ) mNotificationPanel .getLayoutParams ();
@@ -1944,13 +2017,17 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
19442017 }
19452018 mNotificationPanel .setLayoutParams (lp );
19462019
2020+ final int barh = getCloseViewHeight () + getStatusBarHeight ();
2021+ final float frac = saturate ((float )(panelh - barh ) / (disph - barh ));
2022+
19472023 if (DIM_BEHIND_EXPANDED_PANEL && ActivityManager .isHighEndGfx (mDisplay )) {
19482024 // woo, special effects
1949- final int barh = getCloseViewHeight () + getStatusBarHeight ();
1950- final float frac = saturate ((float )(panelh - barh ) / (disph - barh ));
1951- final int color = ((int )(0xB0 * Math .sin (frac * 1.57f ))) << 24 ;
2025+ final float k = (float )(1f -0.5f *(1f -Math .cos (3.14159f * Math .pow (1f -frac , 2.2f ))));
2026+ final int color = ((int )(0xB0 * k )) << 24 ;
19522027 mStatusBarWindow .setBackgroundColor (color );
19532028 }
2029+
2030+ updateCarrierLabelVisibility ();
19542031 }
19552032
19562033 void updateDisplaySize () {
@@ -2185,11 +2262,15 @@ protected void loadDimens() {
21852262 if (mNotificationPanelGravity <= 0 ) {
21862263 mNotificationPanelGravity = Gravity .CENTER_VERTICAL | Gravity .TOP ;
21872264 }
2188- mNotificationPanelMinHeight =
2265+ final int notificationPanelDecorationHeight =
21892266 res .getDimensionPixelSize (R .dimen .notification_panel_padding_top )
21902267 + res .getDimensionPixelSize (R .dimen .notification_panel_header_height )
2191- + res .getDimensionPixelSize (R .dimen .close_handle_underlap )
21922268 + getNinePatchPadding (res .getDrawable (R .drawable .notification_panel_bg )).bottom ;
2269+ mNotificationPanelMinHeight =
2270+ notificationPanelDecorationHeight
2271+ + res .getDimensionPixelSize (R .dimen .close_handle_underlap );
2272+
2273+ mCarrierLabelHeight = res .getDimensionPixelSize (R .dimen .carrier_label_height );
21932274
21942275 if (false ) Slog .v (TAG , "updateResources" );
21952276 }
0 commit comments