From 74bb05a654f8881a43bcd1344cffd39b94f49da4 Mon Sep 17 00:00:00 2001 From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com> Date: Thu, 3 Aug 2017 17:14:14 +0300 Subject: [PATCH] added staledataalarm --- .../plugins/Overview/Notification.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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 6b15a9e17d..31783523c4 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 @@ -111,9 +111,9 @@ public class Notification { return true; if (level == ANNOUNCEMENT) return true; - if (level == NORMAL && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false)) + if (level == NORMAL && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_staledata, false)) return true; - if (level == URGENT && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_urgent_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_urgent_high, false)) + if (level == URGENT && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_urgent_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_urgent_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_urgent_staledata, false)) return true; return false; } @@ -141,4 +141,19 @@ public class Notification { return true; return false; } + + boolean isAlarmForStaleData(){ + BgReading bgReading = MainApp.getDbHelper().lastBg(); + if (bgReading == null) + return false; + long bgReadingAgo = System.currentTimeMillis() - bgReading.date; + int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60)); + //Integer staleDataThreshold = NSSettingsStatus.getInstance().getIntegerOrNull("alarmTimeagoWarnMins"); + //if (staleDataThreshold == null) + // return false; + if(bgReadingAgoMin > SP.getInt(R.string.key_nsalarm_staledatavalue,16)){ + return true; + } + return false; + } }