diff options
author | Diogo Ferreira <diogo@underdev.org> | 2016-10-03 19:19:00 +0100 |
---|---|---|
committer | Adrian DC <radian.dc@gmail.com> | 2016-12-03 22:37:25 +0100 |
commit | 9817512bf0d8fa16b0e237d324bd7cf13a110405 (patch) | |
tree | 2bb10e3349de3cb2ca9065df9701b9cd6da8d2bc | |
parent | fc14d357439f766e83bf31f235c97adf8eca6f0e (diff) | |
download | android_packages_apps_CellBroadcastReceiver-9817512bf0d8fa16b0e237d324bd7cf13a110405.tar.gz android_packages_apps_CellBroadcastReceiver-9817512bf0d8fa16b0e237d324bd7cf13a110405.tar.bz2 android_packages_apps_CellBroadcastReceiver-9817512bf0d8fa16b0e237d324bd7cf13a110405.zip |
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.
RM-290
Change-Id: Ifc5ef92bc97551d69102a915df447813cfa8395a
Ticket: FEIJAO-1615
5 files changed, 24 insertions, 4 deletions
diff --git a/res/layout/cell_broadcast_alert.xml b/res/layout/cell_broadcast_alert.xml index 2ac634bd..5108b2bd 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 8110e1e2..e941f7cc 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 13cf28e8..a5de6def 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 7db5fd2a..45b5f0a0 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 76d4b42b..eaf8bcba 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: |