Pull the carrier name display in the windowshade out into its own view.
Change-Id: I76ea5e72288245b69273c76a470b54eaec890361
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
android:paddingRight="3dp"
|
android:paddingRight="3dp"
|
||||||
android:background="@drawable/shade_header_background"
|
android:background="@drawable/shade_header_background"
|
||||||
>
|
>
|
||||||
<LinearLayout
|
<com.android.systemui.statusbar.CarrierLabel
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -41,25 +41,10 @@
|
|||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingBottom="1dp"
|
android:paddingBottom="1dp"
|
||||||
android:orientation="vertical"
|
android:paddingLeft="4dp"
|
||||||
>
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
<TextView android:id="@+id/plmnLabel"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:layout_width="wrap_content"
|
/>
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:paddingLeft="4dp"
|
|
||||||
/>
|
|
||||||
<TextView android:id="@+id/spnLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:paddingLeft="4dp"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
<TextView android:id="@+id/clear_all_button"
|
<TextView android:id="@+id/clear_all_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2006 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.systemui.statusbar;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.provider.Telephony;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Slog;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This widget display an analogic clock with two hands for hours and
|
||||||
|
* minutes.
|
||||||
|
*/
|
||||||
|
public class CarrierLabel extends TextView {
|
||||||
|
private boolean mAttached;
|
||||||
|
|
||||||
|
public CarrierLabel(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarrierLabel(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CarrierLabel(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
updateNetworkName(false, null, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
|
||||||
|
if (!mAttached) {
|
||||||
|
mAttached = true;
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION);
|
||||||
|
getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
if (mAttached) {
|
||||||
|
getContext().unregisterReceiver(mIntentReceiver);
|
||||||
|
mAttached = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
|
||||||
|
updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
|
||||||
|
intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
|
||||||
|
intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
|
||||||
|
intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plmn) {
|
||||||
|
if (false) {
|
||||||
|
Slog.d("CarrierLabel", "updateNetworkName showSpn=" + showSpn + " spn=" + spn
|
||||||
|
+ " showPlmn=" + showPlmn + " plmn=" + plmn);
|
||||||
|
}
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
boolean something = false;
|
||||||
|
if (showPlmn && plmn != null) {
|
||||||
|
str.append(plmn);
|
||||||
|
something = true;
|
||||||
|
}
|
||||||
|
if (showSpn && spn != null) {
|
||||||
|
if (something) {
|
||||||
|
str.append(' ');
|
||||||
|
}
|
||||||
|
str.append(spn);
|
||||||
|
something = true;
|
||||||
|
}
|
||||||
|
if (something) {
|
||||||
|
setText(str.toString());
|
||||||
|
} else {
|
||||||
|
setText(com.android.internal.R.string.lockscreen_carrier_default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +43,6 @@ import android.os.Binder;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Telephony;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -138,8 +137,6 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
View mExpandedContents;
|
View mExpandedContents;
|
||||||
// top bar
|
// top bar
|
||||||
TextView mNoNotificationsTitle;
|
TextView mNoNotificationsTitle;
|
||||||
TextView mSpnLabel;
|
|
||||||
TextView mPlmnLabel;
|
|
||||||
TextView mClearButton;
|
TextView mClearButton;
|
||||||
// drag bar
|
// drag bar
|
||||||
CloseDragHandle mCloseView;
|
CloseDragHandle mCloseView;
|
||||||
@@ -246,8 +243,6 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
|
mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
|
||||||
mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button);
|
mClearButton = (TextView)expanded.findViewById(R.id.clear_all_button);
|
||||||
mClearButton.setOnClickListener(mClearButtonListener);
|
mClearButton.setOnClickListener(mClearButtonListener);
|
||||||
mSpnLabel = (TextView)expanded.findViewById(R.id.spnLabel);
|
|
||||||
mPlmnLabel = (TextView)expanded.findViewById(R.id.plmnLabel);
|
|
||||||
mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
|
mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
|
||||||
mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);
|
mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);
|
||||||
|
|
||||||
@@ -276,18 +271,11 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
setAreThereNotifications();
|
setAreThereNotifications();
|
||||||
mDateView.setVisibility(View.INVISIBLE);
|
mDateView.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
// before we register for broadcasts
|
|
||||||
mPlmnLabel.setText(com.android.internal.R.string.lockscreen_carrier_default);
|
|
||||||
mPlmnLabel.setVisibility(View.VISIBLE);
|
|
||||||
mSpnLabel.setText("");
|
|
||||||
mSpnLabel.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
// receive broadcasts
|
// receive broadcasts
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
filter.addAction(Telephony.Intents.SPN_STRINGS_UPDATED_ACTION);
|
|
||||||
context.registerReceiver(mBroadcastReceiver, filter);
|
context.registerReceiver(mBroadcastReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1372,45 +1360,12 @@ public class PhoneStatusBarService extends StatusBarService {
|
|||||||
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
|
|| Intent.ACTION_SCREEN_OFF.equals(action)) {
|
||||||
//collapse();
|
//collapse();
|
||||||
}
|
}
|
||||||
else if (Telephony.Intents.SPN_STRINGS_UPDATED_ACTION.equals(action)) {
|
|
||||||
updateNetworkName(intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_SPN, false),
|
|
||||||
intent.getStringExtra(Telephony.Intents.EXTRA_SPN),
|
|
||||||
intent.getBooleanExtra(Telephony.Intents.EXTRA_SHOW_PLMN, false),
|
|
||||||
intent.getStringExtra(Telephony.Intents.EXTRA_PLMN));
|
|
||||||
}
|
|
||||||
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
|
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
|
||||||
updateResources();
|
updateResources();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plmn) {
|
|
||||||
if (false) {
|
|
||||||
Slog.d(TAG, "updateNetworkName showSpn=" + showSpn + " spn=" + spn
|
|
||||||
+ " showPlmn=" + showPlmn + " plmn=" + plmn);
|
|
||||||
}
|
|
||||||
boolean something = false;
|
|
||||||
if (showPlmn) {
|
|
||||||
mPlmnLabel.setVisibility(View.VISIBLE);
|
|
||||||
if (plmn != null) {
|
|
||||||
mPlmnLabel.setText(plmn);
|
|
||||||
} else {
|
|
||||||
mPlmnLabel.setText(com.android.internal.R.string.lockscreen_carrier_default);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mPlmnLabel.setText("");
|
|
||||||
mPlmnLabel.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if (showSpn && spn != null) {
|
|
||||||
mSpnLabel.setText(spn);
|
|
||||||
mSpnLabel.setVisibility(View.VISIBLE);
|
|
||||||
something = true;
|
|
||||||
} else {
|
|
||||||
mSpnLabel.setText("");
|
|
||||||
mSpnLabel.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload some of our resources when the configuration changes.
|
* Reload some of our resources when the configuration changes.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user