diff --git a/app/src/main/java/com/geeksville/mesh/DataPacket.kt b/app/src/main/java/com/geeksville/mesh/DataPacket.kt index 690816b6..94c6d6f6 100644 --- a/app/src/main/java/com/geeksville/mesh/DataPacket.kt +++ b/app/src/main/java/com/geeksville/mesh/DataPacket.kt @@ -85,6 +85,13 @@ data class DataPacket( null } + val alert: String? + get() = if (dataType == Portnums.PortNum.ALERT_APP_VALUE) { + bytes?.decodeToString() + } else { + null + } + constructor(to: String?, channel: Int, waypoint: MeshProtos.Waypoint) : this( to = to, bytes = waypoint.toByteArray(), diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index e0f2be6c..17ff1257 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -305,7 +305,7 @@ class MeshService : Service(), Logging { serviceNotifications.showAlertNotification( contactKey, getSenderName(dataPacket), - dataPacket.text ?: getString(R.string.critical_alert) + dataPacket.alert ?: getString(R.string.critical_alert) ) } diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt index 0930a516..97ede82d 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotifications.kt @@ -44,10 +44,12 @@ class MeshServiceNotifications( private val context: Context ) { - val notificationLightColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - context.getColor(R.color.colorPrimary) - } else { - Color.GREEN + val notificationLightColor by lazy { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + context.getColor(R.color.colorPrimary) + } else { + Color.GREEN + } } companion object { @@ -361,7 +363,7 @@ class MeshServiceNotifications( with(alertNotificationBuilder) { setContentIntent(openMessageIntent(contactKey)) priority = NotificationCompat.PRIORITY_HIGH - setCategory(Notification.CATEGORY_MESSAGE) + setCategory(Notification.CATEGORY_ALARM) setAutoCancel(true) setStyle( NotificationCompat.MessagingStyle(person)