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 01/35] 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; + } } From 450634418e5a02528ce55c6a9a6b6bbd62b1f07a Mon Sep 17 00:00:00 2001 From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com> Date: Thu, 3 Aug 2017 18:47:51 +0300 Subject: [PATCH 02/35] added isAlarmForStaleData() From 232590e7075ab5b103cde759066aa1651e1a7fb8 Mon Sep 17 00:00:00 2001 From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com> Date: Thu, 3 Aug 2017 18:48:45 +0300 Subject: [PATCH 03/35] Added staleData --- .../plugins/NSClientInternal/data/NSSettingsStatus.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java index 4980b342e9..f7a2de3144 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java @@ -188,6 +188,11 @@ public class NSSettingsStatus { return result; } } + if (settingsO.has("alarmTimeagoWarnMins") && what == "alarmTimeagoWarnMins"){ + JSONObject tObject = settingsO.getJSONObject("alarmTimeagoWarnMins"); + Double result = tObject.getDouble(what); + return result; + } } } catch (JSONException e) { e.printStackTrace(); @@ -271,7 +276,6 @@ public class NSSettingsStatus { , warnBattP: sbx.extendedSettings.warnBattP || 30 , urgentBattP: sbx.extendedSettings.urgentBattP || 20 , enableAlerts: sbx.extendedSettings.enableAlerts || false - */ public double extendedPumpSettings(String setting) { From 529d267b9d37a78665ee855e82e16c6a2c035cb4 Mon Sep 17 00:00:00 2001 From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com> Date: Fri, 4 Aug 2017 12:29:48 +0300 Subject: [PATCH 04/35] Added check for staleData and notification with every loop --- app/src/main/res/layout/overview_fragment.xml | 2304 +++++++++++++---- 1 file changed, 1842 insertions(+), 462 deletions(-) diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 6432f0a998..0708ac5005 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -1,462 +1,1842 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -