diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java index e57b068620..10dfd5dce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/InsulinOrefCurves/InsulinOrefBasePlugin.java @@ -7,6 +7,8 @@ import info.nightscout.androidaps.data.Iob; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.interfaces.InsulinInterface; import info.nightscout.androidaps.interfaces.PluginBase; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; /** * Created by adrian on 13.08.2017. @@ -16,6 +18,8 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf public static double MIN_DIA = 5; + long lastWarned = 0; + @Override public int getType() { return INSULIN; @@ -44,7 +48,16 @@ public abstract class InsulinOrefBasePlugin implements PluginBase, InsulinInterf @Override public double getDia() { double dia = getUserDefinedDia(); - return Math.max(MIN_DIA, dia); + if(dia >= MIN_DIA){ + return dia; + } else { + if((System.currentTimeMillis() - lastWarned) > 60*1000) { + lastWarned = System.currentTimeMillis(); + Notification notification = new Notification(Notification.SHORT_DIA, String.format(MainApp.sResources.getString(R.string.dia_too_short), dia, MIN_DIA), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + return MIN_DIA; + } } public double getUserDefinedDia() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index 9f35599b36..d3db3c2902 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -47,6 +47,8 @@ public class Notification { public static final int NSANNOUNCEMENT = 18; public static final int NSALARM = 19; public static final int NSURGENTALARM = 20; + public static final int SHORT_DIA = 21; + public int id; public Date date;