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 ;
8687import com .android .systemui .statusbar .policy .DateView ;
8788import com .android .systemui .statusbar .policy .IntruderAlertView ;
8889import com .android .systemui .statusbar .policy .LocationController ;
90+ import com .android .systemui .statusbar .policy .OnSizeChangedListener ;
8991import com .android .systemui .statusbar .policy .NetworkController ;
9092import com .android .systemui .statusbar .policy .NotificationRowLayout ;
9193
@@ -105,7 +107,8 @@ public class PhoneStatusBar extends BaseStatusBar {
105107 public static final String ACTION_STATUSBAR_START
106108 = "com.android.internal.policy.statusbar.START" ;
107109
108- private static final boolean DIM_BEHIND_EXPANDED_PANEL = false ;
110+ private static final boolean DIM_BEHIND_EXPANDED_PANEL = true ;
111+ private static final boolean SHOW_CARRIER_LABEL = true ;
109112
110113 private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000 ;
111114 private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001 ;
@@ -170,6 +173,11 @@ public class PhoneStatusBar extends BaseStatusBar {
170173 View mSettingsButton ;
171174 RotationToggle mRotationButton ;
172175
176+ // carrier/wifi label
177+ private TextView mCarrierLabel ;
178+ private boolean mCarrierLabelVisible = false ;
179+ private int mCarrierLabelHeight ;
180+
173181 // drag bar
174182 CloseDragHandle mCloseView ;
175183 private int mCloseViewHeight ;
@@ -385,6 +393,14 @@ public boolean onTouch(View v, MotionEvent event) {
385393
386394 mPile = (NotificationRowLayout )mStatusBarWindow .findViewById (R .id .latestItems );
387395 mPile .setLongPressListener (getNotificationLongClicker ());
396+ if (SHOW_CARRIER_LABEL ) {
397+ mPile .setOnSizeChangedListener (new OnSizeChangedListener () {
398+ @ Override
399+ public void onSizeChanged (View view , int w , int h , int oldw , int oldh ) {
400+ updateCarrierLabelVisibility ();
401+ }
402+ });
403+ }
388404 mExpandedContents = mPile ; // was: expanded.findViewById(R.id.notificationLinearLayout);
389405
390406 mClearButton = mStatusBarWindow .findViewById (R .id .clear_all_button );
@@ -396,6 +412,9 @@ public boolean onTouch(View v, MotionEvent event) {
396412 mSettingsButton = mStatusBarWindow .findViewById (R .id .settings_button );
397413 mSettingsButton .setOnClickListener (mSettingsButtonListener );
398414 mRotationButton = (RotationToggle ) mStatusBarWindow .findViewById (R .id .rotation_lock_button );
415+
416+ mCarrierLabel = (TextView )mStatusBarWindow .findViewById (R .id .carrier_label );
417+ mCarrierLabel .setVisibility (mCarrierLabelVisible ? View .VISIBLE : View .INVISIBLE );
399418
400419 mScrollView = (ScrollView )mStatusBarWindow .findViewById (R .id .scroll );
401420 mScrollView .setVerticalScrollBarEnabled (false ); // less drawing during pulldowns
@@ -421,8 +440,17 @@ public boolean onTouch(View v, MotionEvent event) {
421440 mNetworkController = new NetworkController (mContext );
422441 final SignalClusterView signalCluster =
423442 (SignalClusterView )mStatusBarView .findViewById (R .id .signal_cluster );
443+
424444 mNetworkController .addSignalCluster (signalCluster );
425445 signalCluster .setNetworkController (mNetworkController );
446+
447+ // for wifi-only devices, we show SSID; otherwise, we show PLMN
448+ if (mNetworkController .hasMobileDataFeature ()) {
449+ mNetworkController .addMobileLabelView (mCarrierLabel );
450+ } else {
451+ mNetworkController .addWifiLabelView (mCarrierLabel );
452+ }
453+
426454// final ImageView wimaxRSSI =
427455// (ImageView)sb.findViewById(R.id.wimax_signal);
428456// if (wimaxRSSI != null) {
@@ -861,6 +889,45 @@ protected void updateNotificationIcons() {
861889 }
862890 }
863891
892+ protected void updateCarrierLabelVisibility () {
893+ if (!SHOW_CARRIER_LABEL ) return ;
894+ // The idea here is to only show the carrier label when there is enough room to see it,
895+ // i.e. when there aren't enough notifications to fill the panel.
896+ if (DEBUG ) {
897+ Slog .d (TAG , String .format ("pileh=%d scrollh=%d carrierh=%d" ,
898+ mPile .getHeight (), mScrollView .getHeight (), mCarrierLabelHeight ));
899+ }
900+
901+ final boolean makeVisible =
902+ mPile .getHeight () < (mScrollView .getHeight () - mCarrierLabelHeight );
903+
904+ if (mCarrierLabelVisible != makeVisible ) {
905+ mCarrierLabelVisible = makeVisible ;
906+ if (DEBUG ) {
907+ Slog .d (TAG , "making carrier label " + (makeVisible ?"visible" :"invisible" ));
908+ }
909+ mCarrierLabel .animate ().cancel ();
910+ if (makeVisible ) {
911+ mCarrierLabel .setVisibility (View .VISIBLE );
912+ }
913+ mCarrierLabel .animate ()
914+ .alpha (makeVisible ? 1f : 0f )
915+ //.setStartDelay(makeVisible ? 500 : 0)
916+ //.setDuration(makeVisible ? 750 : 100)
917+ .setDuration (150 )
918+ .setListener (makeVisible ? null : new AnimatorListenerAdapter () {
919+ @ Override
920+ public void onAnimationEnd (Animator animation ) {
921+ if (!mCarrierLabelVisible ) { // race
922+ mCarrierLabel .setVisibility (View .INVISIBLE );
923+ mCarrierLabel .setAlpha (0f );
924+ }
925+ }
926+ })
927+ .start ();
928+ }
929+ }
930+
864931 @ Override
865932 protected void setAreThereNotifications () {
866933 final boolean any = mNotificationData .size () > 0 ;
@@ -918,6 +985,8 @@ public void onAnimationEnd(Animator _a) {
918985 })
919986 .start ();
920987 }
988+
989+ updateCarrierLabelVisibility ();
921990 }
922991
923992 public void showClock (boolean show ) {
@@ -1092,6 +1161,8 @@ private void makeExpandedVisible(boolean revealAfterDraw) {
10921161 mExpandedVisible = true ;
10931162 makeSlippery (mNavigationBarView , true );
10941163
1164+ updateCarrierLabelVisibility ();
1165+
10951166 updateExpandedViewPos (EXPANDED_LEAVE_ALONE );
10961167
10971168 // Expand the window to encompass the full screen in anticipation of the drag.
@@ -1947,6 +2018,8 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
19472018 panelh = 0 ;
19482019 }
19492020
2021+ if (panelh == mTrackingPosition ) return ;
2022+
19502023 mTrackingPosition = panelh ;
19512024
19522025 FrameLayout .LayoutParams lp = (FrameLayout .LayoutParams ) mNotificationPanel .getLayoutParams ();
@@ -1958,13 +2031,17 @@ else if (expandedPosition == EXPANDED_LEAVE_ALONE) {
19582031 }
19592032 mNotificationPanel .setLayoutParams (lp );
19602033
2034+ final int barh = getCloseViewHeight () + getStatusBarHeight ();
2035+ final float frac = saturate ((float )(panelh - barh ) / (disph - barh ));
2036+
19612037 if (DIM_BEHIND_EXPANDED_PANEL && ActivityManager .isHighEndGfx (mDisplay )) {
19622038 // woo, special effects
1963- final int barh = getCloseViewHeight () + getStatusBarHeight ();
1964- final float frac = saturate ((float )(panelh - barh ) / (disph - barh ));
1965- final int color = ((int )(0xB0 * Math .sin (frac * 1.57f ))) << 24 ;
2039+ final float k = (float )(1f -0.5f *(1f -Math .cos (3.14159f * Math .pow (1f -frac , 2.2f ))));
2040+ final int color = ((int )(0xB0 * k )) << 24 ;
19662041 mStatusBarWindow .setBackgroundColor (color );
19672042 }
2043+
2044+ updateCarrierLabelVisibility ();
19682045 }
19692046
19702047 void updateDisplaySize () {
@@ -2199,11 +2276,15 @@ protected void loadDimens() {
21992276 if (mNotificationPanelGravity <= 0 ) {
22002277 mNotificationPanelGravity = Gravity .CENTER_VERTICAL | Gravity .TOP ;
22012278 }
2202- mNotificationPanelMinHeight =
2279+ final int notificationPanelDecorationHeight =
22032280 res .getDimensionPixelSize (R .dimen .notification_panel_padding_top )
22042281 + res .getDimensionPixelSize (R .dimen .notification_panel_header_height )
2205- + res .getDimensionPixelSize (R .dimen .close_handle_underlap )
22062282 + getNinePatchPadding (res .getDrawable (R .drawable .notification_panel_bg )).bottom ;
2283+ mNotificationPanelMinHeight =
2284+ notificationPanelDecorationHeight
2285+ + res .getDimensionPixelSize (R .dimen .close_handle_underlap );
2286+
2287+ mCarrierLabelHeight = res .getDimensionPixelSize (R .dimen .carrier_label_height );
22072288
22082289 if (false ) Slog .v (TAG , "updateResources" );
22092290 }
0 commit comments