allow multiple user notifications

This commit is contained in:
Milos Kozak 2020-04-02 19:04:22 +02:00
parent dbc199d00c
commit 7ab5bea93d
3 changed files with 15 additions and 2 deletions

View file

@ -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"))

View file

@ -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;

View file

@ -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
}
}