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 a857153c73..8e46884b48 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 @@ -59,8 +59,7 @@ public class Notification { public Date validTo = new Date(0); public NSAlarm nsAlarm = null; - public Integer soundId = null; - + public Integer soundId = null; public Notification() { } @@ -154,8 +153,9 @@ public class Notification { return false; } - static boolean isAlarmForStaleData(){ - if(SP.getLong("snoozedTo", 0L) != 0L){ + public static boolean isAlarmForStaleData(){ + long snoozedTo = SP.getLong("snoozedTo", 0L); + if(snoozedTo != 0L){ if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) { //log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds"); return false; @@ -167,15 +167,16 @@ public class Notification { long bgReadingAgo = System.currentTimeMillis() - bgReading.date; int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60)); // Added for testing - //bgReadingAgoMin = 20; - log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin); + // bgReadingAgoMin = 20; + boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts(); + //log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin); + //log.debug("Stale alarm snoozed to: "+(System.currentTimeMillis() - snoozedTo)/60000L); Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins"); - boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts(); - log.debug("OpenAPS Alerts enabled: "+openAPSEnabledAlerts); - // if no thresshold from Ns get it loccally + //log.debug("OpenAPS Alerts enabled: "+openAPSEnabledAlerts); + // if no thresshold from Ns get it loccally if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D); - // No threshold of OpenAPS Alarm so using the one for BG - // Added OpenAPSEnabledAlerts to alarm check + // No threshold of OpenAPS Alarm so using the one for BG + // Added OpenAPSEnabledAlerts to alarm check if((bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false))||(bgReadingAgoMin > threshold && openAPSEnabledAlerts)){ return true; }