Skip to content

Commit 059537e

Browse files
cwrenAndroid (Google) Code Review
authored andcommitted
Merge "Back from the dead: Carrier name, background dimming." into jb-dev
2 parents 8a71888 + 3d32a24 commit 059537e

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;
@@ -86,6 +87,7 @@
8687
import com.android.systemui.statusbar.policy.DateView;
8788
import com.android.systemui.statusbar.policy.IntruderAlertView;
8889
import com.android.systemui.statusbar.policy.LocationController;
90+
import com.android.systemui.statusbar.policy.OnSizeChangedListener;
8991
import com.android.systemui.statusbar.policy.NetworkController;
9092
import 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
}

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)