From 7ab5bea93df7195db0f36034456861486d757bf3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 2 Apr 2020 19:04:22 +0200 Subject: [PATCH] allow multiple user notifications --- .../general/automation/actions/ActionNotification.kt | 3 ++- .../general/overview/notifications/Notification.java | 2 +- .../notifications/NotificationUserMessage.kt | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt index 8260f341e2..76152b8861 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionNotification.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuil import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification +import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationUserMessage import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -30,7 +31,7 @@ class ActionNotification(injector: HasAndroidInjector) : Action(injector) { @DrawableRes override fun icon(): Int = R.drawable.ic_notifications override fun doAction(callback: Callback) { - val notification = Notification(Notification.USERMESSAGE, text.value, Notification.URGENT) + val notification = NotificationUserMessage(text.value) rxBus.send(EventNewNotification(notification)) NSUpload.uploadError(text.value) rxBus.send(EventRefreshOverview("ActionNotification")) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java index 85effcb113..3089ca1a7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java @@ -64,11 +64,11 @@ public class Notification { public static final int DST_IN_24H = 50; public static final int DISKFULL = 51; public static final int OLDVERSION = 52; - public static final int USERMESSAGE = 53; public static final int OVER_24H_TIME_CHANGE_REQUESTED = 54; public static final int INVALID_VERSION = 55; public static final int PERMISSION_SYSTEM_WINDOW = 56; + public static final int USERMESSAGE = 1000; public int id; public long date; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt new file mode 100644 index 0000000000..3d198dfc0b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationUserMessage.kt @@ -0,0 +1,12 @@ +package info.nightscout.androidaps.plugins.general.overview.notifications + +class NotificationUserMessage (text :String): Notification() { + + init { + var hash = text.hashCode() + if (hash < USERMESSAGE) hash += USERMESSAGE + id = hash + this.text = text + level = URGENT + } +} \ No newline at end of file