Skip to content

Commit 3d32a24

Browse files
committed
Back from the dead: Carrier name, background dimming.
Unlike previous versions of Android, we now show the current wifi SSID in the carrier label if connected to wifi. Bug: 6612419 Bug: 6620626 Change-Id: Ifb5ba8efe6dd387e960efc6a9b1da69a08e97d96
1 parent 37e0c36 commit 3d32a24

File tree

7 files changed

+152
-10
lines changed

7 files changed

+152
-10
lines changed

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@
2929
android:layout_marginLeft="@dimen/notification_panel_margin_left"
3030
>
3131

32+
<TextView
33+
android:id="@+id/carrier_label"
34+
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Network"
35+
android:layout_height="@dimen/carrier_label_height"
36+
android:layout_width="match_parent"
37+
android:layout_gravity="bottom"
38+
android:layout_marginBottom="@dimen/close_handle_height"
39+
android:gravity="center"
40+
android:visibility="invisible"
41+
/>
42+
3243
<FrameLayout
3344
android:layout_width="match_parent"
3445
android:layout_height="match_parent"

packages/SystemUI/res/values/dimens.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<dimen name="notification_panel_header_height">48dp</dimen>
134134

135135
<!-- Extra space above the panel -->
136-
<dimen name="notification_panel_padding_top">4dp</dimen>
136+
<dimen name="notification_panel_padding_top">0dp</dimen>
137137

138138
<!-- Extra space above the clock in the panel -->
139139
<dimen name="notification_panel_header_padding_top">0dp</dimen>
@@ -145,4 +145,7 @@
145145
<!-- Gravity for the notification panel -->
146146
<!-- 0x37 = fill_horizontal|top -->
147147
<integer name="notification_panel_layout_gravity">0x37</integer>
148+
149+
<!-- Height of the carrier/wifi name label -->
150+
<dimen name="carrier_label_height">24dp</dimen>
148151
</resources>

packages/SystemUI/res/values/styles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
<item name="android:textAllCaps">true</item>
6464
</style>
6565

66+
<style name="TextAppearance.StatusBar.Expanded.Network" parent="@style/TextAppearance.StatusBar.Expanded.Date">
67+
<item name="android:textColor">#999999</item>
68+
</style>
69+
6670
<style name="Animation" />
6771

6872
<style name="Animation.ShirtPocketPanel">

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.android.systemui.statusbar.phone;
1818

1919
import android.animation.Animator;
20+
import android.animation.Animator.AnimatorListener;
2021
import android.animation.AnimatorListenerAdapter;
2122
import android.animation.AnimatorSet;
2223
import android.animation.ObjectAnimator;
@@ -85,6 +86,7 @@
8586
import com.android.systemui.statusbar.policy.DateView;
8687
import com.android.systemui.statusbar.policy.IntruderAlertView;
8788
import com.android.systemui.statusbar.policy.LocationController;
89+
import com.android.systemui.statusbar.policy.OnSizeChangedListener;
8890
import com.android.systemui.statusbar.policy.NetworkController;
8991
import 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
}

packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ public NetworkController(Context context) {
237237
mBatteryStats = BatteryStatsService.getService();
238238
}
239239

240+
public boolean hasMobileDataFeature() {
241+
return mHasMobileDataFeature;
242+
}
243+
240244
public void addPhoneSignalIconView(ImageView v) {
241245
mPhoneSignalIconViews.add(v);
242246
}
@@ -1049,6 +1053,9 @@ else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxCon
10491053
+ Integer.toHexString(combinedSignalIconId)
10501054
+ "/" + getResourceName(combinedSignalIconId)
10511055
+ " combinedActivityIconId=0x" + Integer.toHexString(combinedActivityIconId)
1056+
+ " mobileLabel=" + mobileLabel
1057+
+ " wifiLabel=" + wifiLabel
1058+
+ " combinedLabel=" + combinedLabel
10521059
+ " mAirplaneMode=" + mAirplaneMode
10531060
+ " mDataActivity=" + mDataActivity
10541061
+ " mPhoneSignalIconId=0x" + Integer.toHexString(mPhoneSignalIconId)
@@ -1194,23 +1201,23 @@ else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxCon
11941201
N = mWifiLabelViews.size();
11951202
for (int i=0; i<N; i++) {
11961203
TextView v = mWifiLabelViews.get(i);
1204+
v.setText(wifiLabel);
11971205
if ("".equals(wifiLabel)) {
11981206
v.setVisibility(View.GONE);
11991207
} else {
12001208
v.setVisibility(View.VISIBLE);
1201-
v.setText(wifiLabel);
12021209
}
12031210
}
12041211

12051212
// mobile label
12061213
N = mMobileLabelViews.size();
12071214
for (int i=0; i<N; i++) {
12081215
TextView v = mMobileLabelViews.get(i);
1216+
v.setText(mobileLabel);
12091217
if ("".equals(mobileLabel)) {
12101218
v.setVisibility(View.GONE);
12111219
} else {
12121220
v.setVisibility(View.VISIBLE);
1213-
v.setText(mobileLabel);
12141221
}
12151222
}
12161223
}

packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
public class NotificationRowLayout
4646
extends LinearLayout
47-
implements SwipeHelper.Callback, ExpandHelper.Callback
47+
implements SwipeHelper.Callback, ExpandHelper.Callback
4848
{
4949
private static final String TAG = "NotificationRowLayout";
5050
private static final boolean DEBUG = false;
@@ -61,6 +61,8 @@ public class NotificationRowLayout
6161
HashMap<View, ValueAnimator> mDisappearingViews = new HashMap<View, ValueAnimator>();
6262

6363
private SwipeHelper mSwipeHelper;
64+
65+
private OnSizeChangedListener mOnSizeChangedListener;
6466

6567
// Flag set during notification removal animation to avoid causing too much work until
6668
// animation is done
@@ -101,6 +103,10 @@ public void setLongPressListener(View.OnLongClickListener listener) {
101103
mSwipeHelper.setLongPressListener(listener);
102104
}
103105

106+
public void setOnSizeChangedListener(OnSizeChangedListener l) {
107+
mOnSizeChangedListener = l;
108+
}
109+
104110
@Override
105111
public void onWindowFocusChanged(boolean hasWindowFocus) {
106112
super.onWindowFocusChanged(hasWindowFocus);
@@ -247,4 +253,11 @@ public void onDraw(android.graphics.Canvas c) {
247253
c.restore();
248254
}
249255
}
256+
257+
@Override
258+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
259+
if (mOnSizeChangedListener != null) {
260+
mOnSizeChangedListener.onSizeChanged(this, w, h, oldw, oldh);
261+
}
262+
}
250263
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.systemui.statusbar.policy;
18+
19+
import android.view.View;
20+
21+
public interface OnSizeChangedListener {
22+
void onSizeChanged(View view, int w, int h, int oldw, int oldh);
23+
}

0 commit comments

Comments
 (0)