summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiogo Ferreira <diogo@underdev.org>2016-10-03 18:19:00 (GMT)
committerDiogo Ferreira <diogo@underdev.org>2016-10-03 18:22:42 (GMT)
commit60fd85ca6a06b9fdcc2ffcf120a692d90aa1d1ec (patch)
tree379f75f88b5d16a4f051a9f95a9af8b1209c9496
parentab8ccee6e94937b20c215d176263d1285ecbe0c8 (diff)
downloadandroid_packages_apps_CellBroadcastReceiver-60fd85ca6a06b9fdcc2ffcf120a692d90aa1d1ec.zip
android_packages_apps_CellBroadcastReceiver-60fd85ca6a06b9fdcc2ffcf120a692d90aa1d1ec.tar.gz
android_packages_apps_CellBroadcastReceiver-60fd85ca6a06b9fdcc2ffcf120a692d90aa1d1ec.tar.bz2
CellBroadcastReceiver: Show timestamp / appropriate title in the LatAm region
In this region, broadcasts on the 4370 are emergency alerts. 4370 is also the channel used for presidential alerts on the US, so piggy back on that code and change the string for LatAm. Additionally, the timestamp is mandatory in some government requirements, this patch adds that as well. Change-Id: Ifc5ef92bc97551d69102a915df447813cfa8395a Ticket: FEIJAO-1615
-rw-r--r--res/layout/cell_broadcast_alert.xml7
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertFullScreen.java12
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java2
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastListItem.java2
-rw-r--r--src/com/android/cellbroadcastreceiver/CellBroadcastResources.java5
5 files changed, 24 insertions, 4 deletions
diff --git a/res/layout/cell_broadcast_alert.xml b/res/layout/cell_broadcast_alert.xml
index 2ac634b..5108b2b 100644
--- a/res/layout/cell_broadcast_alert.xml
+++ b/res/layout/cell_broadcast_alert.xml
@@ -29,6 +29,7 @@
<LinearLayout android:id="@+id/topPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
android:orientation="vertical">
<View android:id="@+id/titleDividerTop"
android:layout_width="match_parent"
@@ -55,6 +56,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
+ <TextView android:id="@+id/timestamp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="13sp"
+ android:visibility="gone"
+ />
<View android:id="@+id/titleDivider"
android:layout_width="match_parent"
android:layout_height="2dip"
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertFullScreen.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertFullScreen.java
index 8110e1e..e941f7c 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertFullScreen.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertFullScreen.java
@@ -43,7 +43,9 @@ import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
+import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
+import java.text.SimpleDateFormat;
/**
* Full-screen emergency alert with flashing warning icon.
@@ -370,8 +372,16 @@ public class CellBroadcastAlertFullScreen extends Activity {
/** Update alert text when a new emergency alert arrives. */
private void updateAlertText(CellBroadcastMessage message) {
- int titleId = CellBroadcastResources.getDialogTitleResource(message);
+ int titleId = CellBroadcastResources.getDialogTitleResource(this, message);
setTitle(titleId);
+ if (getResources().getBoolean(R.bool.enable_colombia_channels)) {
+ SimpleDateFormat formatter = new SimpleDateFormat("hh:mm:ss dd/MM/yyyy");
+ String timestampStr = formatter.format(new Date(message.getDeliveryTime()));
+
+ TextView timestampView = (TextView) findViewById(R.id.timestamp);
+ timestampView.setVisibility(View.VISIBLE);
+ timestampView.setText(timestampStr);
+ }
((TextView) findViewById(R.id.alertTitle)).setText(titleId);
((TextView) findViewById(R.id.message)).setText(message.getMessageBody());
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
index 13cf28e..a5de6de 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastAlertService.java
@@ -466,7 +466,7 @@ public class CellBroadcastAlertService extends Service {
* @param message the alert to display
*/
private void addToNotificationBar(CellBroadcastMessage message) {
- int channelTitleId = CellBroadcastResources.getDialogTitleResource(message);
+ int channelTitleId = CellBroadcastResources.getDialogTitleResource(this, message);
CharSequence channelName = getText(channelTitleId);
String messageBody = message.getMessageBody();
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastListItem.java b/src/com/android/cellbroadcastreceiver/CellBroadcastListItem.java
index 7db5fd2..45b5f0a 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastListItem.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastListItem.java
@@ -69,7 +69,7 @@ public class CellBroadcastListItem extends RelativeLayout {
setBackground(background);
- mChannelView.setText(CellBroadcastResources.getDialogTitleResource(message));
+ mChannelView.setText(CellBroadcastResources.getDialogTitleResource(getContext(), message));
mDateView.setText(message.getDateString(getContext()));
mMessageView.setText(formatMessage(message));
}
diff --git a/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java b/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
index 76d4b42..eaf8bcb 100644
--- a/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
+++ b/src/com/android/cellbroadcastreceiver/CellBroadcastResources.java
@@ -236,7 +236,7 @@ public class CellBroadcastResources {
}
}
- public static int getDialogTitleResource(CellBroadcastMessage cbm) {
+ public static int getDialogTitleResource(Context context, CellBroadcastMessage cbm) {
// ETWS warning types
SmsCbEtwsInfo etwsInfo = cbm.getEtwsWarningInfo();
if (etwsInfo != null) {
@@ -264,6 +264,9 @@ public class CellBroadcastResources {
if (cmasInfo != null) {
switch (cmasInfo.getMessageClass()) {
case SmsCbCmasInfo.CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT:
+ if (context.getResources().getBoolean(R.bool.enable_colombia_channels)) {
+ return R.string.etws_other_emergency_type;
+ }
return R.string.cmas_presidential_level_alert;
case SmsCbCmasInfo.CMAS_CLASS_EXTREME_THREAT: