Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow using PLMN and SPN text as part of Custom Carrier text - by Bri…

…an Larsen (Chezebel)

   When the 'Custom carrier label' option is used this change supports
   the following special character sequences:
    - $n = replaced with a newline when displayed
    - $d = replaced with the 'default' carrier text when displayed
    - $p = replaced with the 'plmn' text when displayed
    - $s = replaced with the 'spn' text when displayed

    Here is an example. Let's assume that the plmn text is "TW Mobile" and
you enter
    this string in the custom text field:
      My DHD$n$p
    The the on the Status Bar it will show up on 2 lines like this:
      My DHD
      TW Mobile

    Note that when using a lockscreen that displays custom text any '$n' is
converted
    to a space instead of a newline in order to function in the same way as
other
    carrier text on that screen, such as the Default text. So the above
example would
    look like this on 1 line:
      My DHD TW Mobile
  • Loading branch information...
commit 4d952877b22b3d2b90245ef8798ca991e5145e6b 1 parent ef1804e
Davor Bertovic LorDClockaN authored
51 packages/SystemUI/src/com/android/systemui/statusbar/phone/CarrierLabel.java
View
@@ -96,28 +96,41 @@ void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plm
customLabel = Settings.System.getString(mContext.getContentResolver(),
Settings.System.CUSTOM_CARRIER_LABEL);
- if (customLabel == null) {
-
- StringBuilder str = new StringBuilder();
- boolean something = false;
- if (showPlmn && plmn != null) {
- str.append(plmn);
- something = true;
- }
- if (showSpn && spn != null) {
- if (something) {
- str.append('\n');
- }
- str.append(spn);
- something = true;
- }
+ StringBuilder str = new StringBuilder();
+ boolean something = false;
+ if (showPlmn && plmn != null) {
+ str.append(plmn);
+ something = true;
+ }
+ if (showSpn && spn != null) {
if (something) {
- setText(str.toString());
- } else {
- setText(com.android.internal.R.string.lockscreen_carrier_default);
+ str.append('\n');
}
+ str.append(spn);
+ something = true;
+ }
+ if (!something) {
+ str.append(com.android.internal.R.string.lockscreen_carrier_default);
+ }
+
+ if (customLabel == null) {
+ setText(str.toString());
} else {
- setText(customLabel);
+ // If the custom carrier label contains any "$x" items then we must
+ // replace those with the proper text.
+ // - $n = new line
+ // - $d = default carrier text
+ // - $p = plmn carrier text
+ // - $s = spn carrier text
+ //
+
+ // For the default carrier text we will use str, which we created above.
+ String customStr = customLabel;
+ customStr = customStr.replaceAll("\\$n", "\n");
+ customStr = customStr.replaceAll("\\$d", (str != null) ? str.toString() : "");
+ customStr = customStr.replaceAll("\\$p", (plmn != null) ? plmn : "");
+ customStr = customStr.replaceAll("\\$s", (spn != null) ? spn : "");
+ setText(customStr);
}
}
48 policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
View
@@ -278,7 +278,7 @@ void setOwnerInfo(CharSequence string) {
/**
* Sets the carrier help text message, if view is present. Carrier help text
* messages are typically for help dealing with SIMS and connectivity.
- *
+ *
* @param resId resource id of the message
*/
public void setCarrierHelpText(int resId) {
@@ -293,7 +293,7 @@ private CharSequence getText(int resId) {
/**
* Unlock help message. This is typically for help with unlock widgets, e.g.
* "wrong password" or "try again."
- *
+ *
* @param textResId
* @param lockIcon
*/
@@ -379,7 +379,7 @@ void resetStatusInfo() {
* Update the status lines based on these rules: AlarmStatus: Alarm state
* always gets it's own line. Status1 is shared between help, battery status
* and generic unlock instructions, prioritized in that order.
- *
+ *
* @param showStatusLines status lines are shown if true
*/
void updateStatusLines(boolean showStatusLines) {
@@ -478,7 +478,7 @@ private void updateCalendar() {
for (EventBundle e : mCalendarEvents) {
String title = e.title + (e.dayString.isEmpty() ? " " : ", ");
String details = e.dayString
- + ((e.allDay) ? "" : " " + DateFormat.format(
+ + ((e.allDay) ? " all-day " : " at " + DateFormat.format(
DateFormat.is24HourFormat(getContext()) ? "kk:mm"
: "hh:mm a", e.begin).toString())
+ (!e.location.isEmpty() ? " (" + e.location + ")" : "");
@@ -655,7 +655,7 @@ private Context getContext() {
/**
* Update carrier text, carrier help and emergency button to match the
* current status based on SIM state.
- *
+ *
* @param simState
*/
private void updateCarrierStateWithSimStatus(State simState) {
@@ -729,10 +729,25 @@ private void updateCarrierStateWithSimStatus(State simState) {
customLabel = Settings.System.getString(getContext().getContentResolver(),
Settings.System.CUSTOM_CARRIER_LABEL);
- if (customLabel == null)
+ if (customLabel == null) {
setCarrierText(carrierText);
- else
- setCarrierText(customLabel);
+ } else {
+ // If the custom carrier label contains any "$x" items then we must
+ // replace those with the proper text.
+ // - $n = new line
+ // - $d = default carrier text
+ // - $p = plmn carrier text
+ // - $s = spn carrier text
+ //
+
+ // For the default carrier text we will use carrierText, which we created above.
+ String customStr = customLabel;
+ customStr = customStr.replaceAll("\\$n", "\n");
+ customStr = customStr.replaceAll("\\$d", (carrierText != null) ? carrierText.toString() : "");
+ customStr = customStr.replaceAll("\\$p", (mPlmn != null) ? mPlmn.toString() : "");
+ customStr = customStr.replaceAll("\\$s", (mSpn != null) ? mSpn.toString() : "");
+ setCarrierText(customStr);
+ }
setCarrierHelpText(carrierHelpTextId);
updateEmergencyCallButtonState(mPhoneState);
@@ -886,7 +901,7 @@ public void onClick(View v) {
/**
* Performs concentenation of PLMN/SPN
- *
+ *
* @param plmn
* @param spn
* @return
@@ -1010,9 +1025,9 @@ private void getCalendarEvents(ContentResolver resolver, String sources,
}, selection, null,
CalendarContract.Instances.START_DAY + " ASC, "
+ CalendarContract.Instances.START_MINUTE + " ASC");
-
+
int events = eventCur.getCount();
-
+
if (events > 0) {
eventCur.moveToFirst();
do {
@@ -1031,25 +1046,20 @@ private void getCalendarEvents(ContentResolver resolver, String sources,
public Calendar begin;
public String location;
public String dayString;
- public boolean allDay = false;
+ public boolean allDay;
public int color;
EventBundle(String s, long b, String l, Calendar now, boolean a, int c) {
title = s;
begin = Calendar.getInstance();
- if (a) {
- begin.setTimeInMillis(b - begin.get(Calendar.ZONE_OFFSET) - begin.get(Calendar.DST_OFFSET));
- allDay = true;
- } else {
- begin.setTimeInMillis(b);
- }
+ begin.setTimeInMillis(b);
location = (l == null) ? "" : l;
int beginDay = begin.get(Calendar.DAY_OF_YEAR);
int today = now.get(Calendar.DAY_OF_YEAR);
if (beginDay == today) { // today
dayString = "";
} else if (today + 1 == beginDay || (today >= 365 && beginDay == 1)) { // tomorrow
- dayString = getContext().getString(R.string.lockscreen_calendar_tomorrow);
+ dayString = "Tomorrow";
} else { // another day of week
dayString = begin.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT,
Locale.getDefault());
Please sign in to comment.
Something went wrong with that request. Please try again.