Skip to content

Commit dd4ef49

Browse files
committed
Persistent 'emergency calls' banner in the notification panel.
While carrier info (or SSID for devices without mobile data) will still be shown in a floating text view at the bottom of the notification shade, emergency-calls-only mode will now be shown in the notification panel header so that it cannot be obscured by notifications. Change-Id: I714b6801be2b9b631b86b51d229440445eff5e76
1 parent cdd0c59 commit dd4ef49

File tree

4 files changed

+69
-20
lines changed

4 files changed

+69
-20
lines changed

packages/SystemUI/res/layout/status_bar_expanded.xml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,34 @@
4040
android:visibility="invisible"
4141
/>
4242

43-
<FrameLayout
43+
<LinearLayout
4444
android:layout_width="match_parent"
4545
android:layout_height="match_parent"
4646
android:layout_marginBottom="@dimen/close_handle_underlap"
47+
android:orientation="vertical"
4748
>
4849

4950
<include layout="@layout/status_bar_expanded_header"
5051
android:layout_width="match_parent"
5152
android:layout_height="@dimen/notification_panel_header_height"
5253
/>
53-
54+
55+
<TextView
56+
android:id="@+id/emergency_calls_only"
57+
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Network.EmergencyOnly"
58+
android:layout_height="wrap_content"
59+
android:layout_width="match_parent"
60+
android:paddingBottom="4dp"
61+
android:gravity="center"
62+
android:visibility="gone"
63+
/>
64+
5465
<ScrollView
5566
android:id="@+id/scroll"
5667
android:layout_width="match_parent"
5768
android:layout_height="match_parent"
5869
android:fadingEdge="none"
59-
android:overScrollMode="ifContentScrolls"
60-
android:layout_marginTop="@dimen/notification_panel_header_height"
70+
android:overScrollMode="always"
6171
>
6272
<com.android.systemui.statusbar.policy.NotificationRowLayout
6373
android:id="@+id/latestItems"
@@ -66,7 +76,7 @@
6676
systemui:rowHeight="@dimen/notification_row_min_height"
6777
/>
6878
</ScrollView>
69-
</FrameLayout>
79+
</LinearLayout>
7080

7181
<com.android.systemui.statusbar.phone.CloseDragHandle android:id="@+id/close"
7282
android:layout_width="match_parent"

packages/SystemUI/res/values/styles.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
<item name="android:textColor">#999999</item>
6868
</style>
6969

70+
<style name="TextAppearance.StatusBar.Expanded.Network.EmergencyOnly">
71+
</style>
72+
7073
<style name="Animation" />
7174

7275
<style name="Animation.ShirtPocketPanel">

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public class PhoneStatusBar extends BaseStatusBar {
182182
private TextView mCarrierLabel;
183183
private boolean mCarrierLabelVisible = false;
184184
private int mCarrierLabelHeight;
185+
private TextView mEmergencyCallLabel;
185186

186187
// drag bar
187188
CloseDragHandle mCloseView;
@@ -409,14 +410,6 @@ public boolean onTouch(View v, MotionEvent event) {
409410
mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems);
410411
mPile.setLayoutTransitionsEnabled(false);
411412
mPile.setLongPressListener(getNotificationLongClicker());
412-
if (SHOW_CARRIER_LABEL) {
413-
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
414-
@Override
415-
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
416-
updateCarrierLabelVisibility(false);
417-
}
418-
});
419-
}
420413
mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
421414

422415
mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button);
@@ -429,9 +422,6 @@ public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
429422
mSettingsButton.setOnClickListener(mSettingsButtonListener);
430423
mRotationButton = (RotationToggle) mStatusBarWindow.findViewById(R.id.rotation_lock_button);
431424

432-
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
433-
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
434-
435425
mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll);
436426
mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns
437427

@@ -460,14 +450,36 @@ public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
460450
mNetworkController.addSignalCluster(signalCluster);
461451
signalCluster.setNetworkController(mNetworkController);
462452

453+
mEmergencyCallLabel = (TextView)mStatusBarWindow.findViewById(R.id.emergency_calls_only);
454+
if (mEmergencyCallLabel != null) {
455+
mNetworkController.addEmergencyLabelView(mEmergencyCallLabel);
456+
mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
457+
@Override
458+
public void onLayoutChange(View v, int left, int top, int right, int bottom,
459+
int oldLeft, int oldTop, int oldRight, int oldBottom) {
460+
updateCarrierLabelVisibility(false);
461+
}});
462+
}
463+
463464
if (SHOW_CARRIER_LABEL) {
465+
mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label);
466+
mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE);
467+
464468
// for mobile devices, we always show mobile connection info here (SPN/PLMN)
465469
// for other devices, we show whatever network is connected
466470
if (mNetworkController.hasMobileDataFeature()) {
467471
mNetworkController.addMobileLabelView(mCarrierLabel);
468472
} else {
469473
mNetworkController.addCombinedLabelView(mCarrierLabel);
470474
}
475+
476+
// set up the dynamic hide/show of the label
477+
mPile.setOnSizeChangedListener(new OnSizeChangedListener() {
478+
@Override
479+
public void onSizeChanged(View view, int w, int h, int oldw, int oldh) {
480+
updateCarrierLabelVisibility(false);
481+
}
482+
});
471483
}
472484

473485
// final ImageView wimaxRSSI =
@@ -919,9 +931,11 @@ protected void updateCarrierLabelVisibility(boolean force) {
919931
Slog.d(TAG, String.format("pileh=%d scrollh=%d carrierh=%d",
920932
mPile.getHeight(), mScrollView.getHeight(), mCarrierLabelHeight));
921933
}
922-
923-
final boolean makeVisible =
924-
mPile.getHeight() < (mScrollView.getHeight() - mCarrierLabelHeight);
934+
935+
final boolean emergencyCallsShownElsewhere = mEmergencyCallLabel != null;
936+
final boolean makeVisible =
937+
!(emergencyCallsShownElsewhere && mNetworkController.isEmergencyOnly())
938+
&& mPile.getHeight() < (mScrollView.getHeight() - mCarrierLabelHeight);
925939

926940
if (force || mCarrierLabelVisible != makeVisible) {
927941
mCarrierLabelVisible = makeVisible;

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public class NetworkController extends BroadcastReceiver {
145145
ArrayList<TextView> mCombinedLabelViews = new ArrayList<TextView>();
146146
ArrayList<TextView> mMobileLabelViews = new ArrayList<TextView>();
147147
ArrayList<TextView> mWifiLabelViews = new ArrayList<TextView>();
148+
ArrayList<TextView> mEmergencyLabelViews = new ArrayList<TextView>();
148149
ArrayList<SignalCluster> mSignalClusters = new ArrayList<SignalCluster>();
149150
int mLastPhoneSignalIconId = -1;
150151
int mLastDataDirectionIconId = -1;
@@ -245,6 +246,10 @@ public boolean hasMobileDataFeature() {
245246
return mHasMobileDataFeature;
246247
}
247248

249+
public boolean isEmergencyOnly() {
250+
return (mServiceState != null && mServiceState.isEmergencyOnly());
251+
}
252+
248253
public void addPhoneSignalIconView(ImageView v) {
249254
mPhoneSignalIconViews.add(v);
250255
}
@@ -284,6 +289,10 @@ public void addWifiLabelView(TextView v) {
284289
mWifiLabelViews.add(v);
285290
}
286291

292+
public void addEmergencyLabelView(TextView v) {
293+
mEmergencyLabelViews.add(v);
294+
}
295+
287296
public void addSignalCluster(SignalCluster cluster) {
288297
mSignalClusters.add(cluster);
289298
refreshSignalCluster(cluster);
@@ -917,7 +926,7 @@ void refreshViews() {
917926
String wifiLabel = "";
918927
String mobileLabel = "";
919928
int N;
920-
final boolean emergencyOnly = (mServiceState != null && mServiceState.isEmergencyOnly());
929+
final boolean emergencyOnly = isEmergencyOnly();
921930

922931
if (!mHasMobileDataFeature) {
923932
mDataSignalIconId = mPhoneSignalIconId = 0;
@@ -1079,6 +1088,7 @@ else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxCon
10791088
+ " combinedActivityIconId=0x" + Integer.toHexString(combinedActivityIconId)
10801089
+ " mobileLabel=" + mobileLabel
10811090
+ " wifiLabel=" + wifiLabel
1091+
+ " emergencyOnly=" + emergencyOnly
10821092
+ " combinedLabel=" + combinedLabel
10831093
+ " mAirplaneMode=" + mAirplaneMode
10841094
+ " mDataActivity=" + mDataActivity
@@ -1244,6 +1254,18 @@ else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxCon
12441254
v.setVisibility(View.VISIBLE);
12451255
}
12461256
}
1257+
1258+
// e-call label
1259+
N = mEmergencyLabelViews.size();
1260+
for (int i=0; i<N; i++) {
1261+
TextView v = mEmergencyLabelViews.get(i);
1262+
if (!emergencyOnly) {
1263+
v.setVisibility(View.GONE);
1264+
} else {
1265+
v.setText(mobileLabel); // comes from the telephony stack
1266+
v.setVisibility(View.VISIBLE);
1267+
}
1268+
}
12471269
}
12481270

12491271
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {

0 commit comments

Comments
 (0)