From 9b6e97e1f2d0b0cfc1fb0684c5297ad48f21e204 Mon Sep 17 00:00:00 2001 From: swissalpine Date: Fri, 3 Jan 2020 06:56:27 +0100 Subject: [PATCH 01/20] Fix for mixed up bage_warn, bage_urgent for Combo in Statuslights Fixes the small bug mentioned in https://github.com/MilosKozak/AndroidAPS/issues/2320 --- .../androidaps/plugins/general/overview/StatuslightHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java index 15d9f11a2b..1aa978a17b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java @@ -41,7 +41,7 @@ class StatuslightHandler { R.string.key_statuslights_bat_warning, 22.0, batteryView, "BAT", batteryLevel); } else { - applyStatuslight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 504, 240); + applyStatuslight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 504, 744); } } From 0326f854dbcdc0352d7d1c8745f86a7e5a425794 Mon Sep 17 00:00:00 2001 From: swissalpine Date: Sun, 5 Jan 2020 15:51:27 +0100 Subject: [PATCH 02/20] Adjust handleAge too --- .../plugins/general/overview/StatuslightHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java index 1aa978a17b..4588b2f256 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java @@ -41,7 +41,7 @@ class StatuslightHandler { R.string.key_statuslights_bat_warning, 22.0, batteryView, "BAT", batteryLevel); } else { - applyStatuslight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 504, 744); + applyStatuslight("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT", 224, 336); } } @@ -116,7 +116,7 @@ class StatuslightHandler { batteryView, "BAT ", pump.getBatteryLevel()); } else { handleAge("bage", CareportalEvent.PUMPBATTERYCHANGE, batteryView, "BAT ", - 336, 240); + 224, 336); } } From a58a6540f2b27d9bbe7e28fc2c4024b4464fd22a Mon Sep 17 00:00:00 2001 From: swissalpine Date: Sun, 5 Jan 2020 16:12:50 +0100 Subject: [PATCH 03/20] Last inverted function void handleAge() --- .../androidaps/plugins/general/overview/StatuslightHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java index 4588b2f256..557ffd8d73 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatuslightHandler.java @@ -121,7 +121,7 @@ class StatuslightHandler { } void handleAge(String nsSettingPlugin, String eventName, TextView view, String text, - int defaultUrgentThreshold, int defaultWarnThreshold) { + int defaultWarnThreshold, int defaultUrgentThreshold) { NSSettingsStatus nsSettings = new NSSettingsStatus().getInstance(); if (view != null) { From b1a376e68a10737953daf2882e152e9a204fdf40 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 15 Jan 2020 22:42:42 +0100 Subject: [PATCH 04/20] Fix displying OAPS Offline intervals --- .../androidaps/db/DatabaseHelper.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index a8812335d2..dd93397ac3 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.plugins.bus.RxBus; -import info.nightscout.androidaps.data.OverlappingIntervals; +import info.nightscout.androidaps.data.NonOverlappingIntervals; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.events.EventCareportalEventChange; @@ -1440,7 +1440,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { where.ge("date", mills).and().isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); - preprocessOpenAPSOfflineEvents(careportalEvents); + careportalEvents = preprocessOpenAPSOfflineEvents(careportalEvents); return careportalEvents; } catch (SQLException e) { log.error("Unhandled exception", e); @@ -1457,7 +1457,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { where.between("date", start, end).and().isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); - preprocessOpenAPSOfflineEvents(careportalEvents); + careportalEvents = preprocessOpenAPSOfflineEvents(careportalEvents); return careportalEvents; } catch (SQLException e) { log.error("Unhandled exception", e); @@ -1465,14 +1465,16 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return new ArrayList<>(); } - public void preprocessOpenAPSOfflineEvents(List list) { - OverlappingIntervals offlineEvents = new OverlappingIntervals(); + public List preprocessOpenAPSOfflineEvents(List list) { + NonOverlappingIntervals offlineEvents = new NonOverlappingIntervals(); + List other = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { CareportalEvent event = list.get(i); - if (!event.eventType.equals(CareportalEvent.OPENAPSOFFLINE)) continue; - offlineEvents.add(event); + if (event.eventType.equals(CareportalEvent.OPENAPSOFFLINE)) offlineEvents.add(event); + else other.add(event); } - + other.addAll(offlineEvents.getList()); + return other; } public List getCareportalEventsFromTime(long mills, String type, boolean ascending) { @@ -1484,7 +1486,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { where.ge("date", mills).and().eq("eventType", type).and().isNotNull("json"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); - preprocessOpenAPSOfflineEvents(careportalEvents); + careportalEvents = preprocessOpenAPSOfflineEvents(careportalEvents); return careportalEvents; } catch (SQLException e) { log.error("Unhandled exception", e); @@ -1501,7 +1503,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { where.isNotNull("json").and().isNotNull("eventType"); PreparedQuery preparedQuery = queryBuilder.prepare(); careportalEvents = getDaoCareportalEvents().query(preparedQuery); - preprocessOpenAPSOfflineEvents(careportalEvents); + careportalEvents = preprocessOpenAPSOfflineEvents(careportalEvents); return careportalEvents; } catch (SQLException e) { log.error("Unhandled exception", e); From 31edddc5cf1935ceae70f887bc9df2cc972caa0d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 15 Jan 2020 22:53:40 +0100 Subject: [PATCH 05/20] removed icon in bolusprogress dialog --- app/src/main/res/layout/dialog_bolusprogress.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/res/layout/dialog_bolusprogress.xml b/app/src/main/res/layout/dialog_bolusprogress.xml index b8e8377827..d794199c89 100644 --- a/app/src/main/res/layout/dialog_bolusprogress.xml +++ b/app/src/main/res/layout/dialog_bolusprogress.xml @@ -14,11 +14,6 @@ android:orientation="horizontal" android:padding="5dp"> - - Date: Thu, 16 Jan 2020 12:45:55 +0100 Subject: [PATCH 06/20] Fix scaling of the activity graph --- .../plugins/general/overview/graphData/GraphData.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java index a3dc3c4212..dec943365c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.java @@ -371,7 +371,8 @@ public class GraphData { actArrayHist.add(new ScaledDataPoint(time, act, actScale)); else actArrayPred.add(new ScaledDataPoint(time, act, actScale)); - if (act > maxIAValue) maxIAValue = act; + + maxIAValue = Math.max(maxIAValue, Math.abs(act)); } ScaledDataPoint[] actData = new ScaledDataPoint[actArrayHist.size()]; From 8f024598490f9e4e649247fc87a767c4b7916997 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 16 Jan 2020 15:46:53 +0100 Subject: [PATCH 07/20] #2369 Set event time for second event plus 1s too --- .../main/java/info/nightscout/androidaps/dialogs/FillDialog.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index 3eb4b0e379..f6ffbe6a2f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -131,6 +131,7 @@ class FillDialog : DialogFragmentWithDate() { } if (insulinChange) { // add a second for case of both checked + careportalEvent.date = eventTime + 1000 careportalEvent.json = generateJson(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes).toString() careportalEvent.eventType = CareportalEvent.INSULINCHANGE NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) @@ -160,4 +161,4 @@ class FillDialog : DialogFragmentWithDate() { return data } -} \ No newline at end of file +} From a1c7aae7947e4ebad5823b1d51de73f6d5f9cbd1 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Thu, 16 Jan 2020 20:39:25 +0100 Subject: [PATCH 08/20] Refactor: dedup, method abstraction level. --- .../androidaps/dialogs/FillDialog.kt | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index f6ffbe6a2f..273d0b800d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -102,41 +102,15 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, MainApp.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), Runnable { if (insulinAfterConstraints > 0) { - val detailedBolusInfo = DetailedBolusInfo() - detailedBolusInfo.insulin = insulinAfterConstraints - detailedBolusInfo.context = context - detailedBolusInfo.source = Source.USER - detailedBolusInfo.isValid = false // do not count it in IOB (for pump history) - detailedBolusInfo.notes = notes - ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { - override fun run() { - if (!result.success) { - val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java) - i.putExtra("soundid", R.raw.boluserror) - i.putExtra("status", result.comment) - i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)) - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - MainApp.instance().startActivity(i) - } - } - }) + requestPrimeBolus(insulinAfterConstraints, notes) } - val careportalEvent = CareportalEvent() - careportalEvent.date = eventTime - careportalEvent.source = Source.USER if (siteChange) { - careportalEvent.json = generateJson(CareportalEvent.SITECHANGE, eventTime, notes).toString() - careportalEvent.eventType = CareportalEvent.SITECHANGE - NSUpload.uploadEvent(CareportalEvent.SITECHANGE, eventTime, notes) + generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked - careportalEvent.date = eventTime + 1000 - careportalEvent.json = generateJson(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes).toString() - careportalEvent.eventType = CareportalEvent.INSULINCHANGE - NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) + generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } - MainApp.getDbHelper().createOrUpdate(careportalEvent) }, null) } } else { @@ -148,7 +122,38 @@ class FillDialog : DialogFragmentWithDate() { return true } - fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject { + private fun requestPrimeBolus(insulin: Double, notes: String) { + val detailedBolusInfo = DetailedBolusInfo() + detailedBolusInfo.insulin = insulin + detailedBolusInfo.context = context + detailedBolusInfo.source = Source.USER + detailedBolusInfo.isValid = false // do not count it in IOB (for pump history) + detailedBolusInfo.notes = notes + ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { + override fun run() { + if (!result.success) { + val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java) + i.putExtra("soundid", R.raw.boluserror) + i.putExtra("status", result.comment) + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)) + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + MainApp.instance().startActivity(i) + } + } + }) + } + + private fun generateCareportalEvent(eventType: String, time: Long, notes: String) { + val careportalEvent = CareportalEvent() + careportalEvent.source = Source.USER + careportalEvent.date = time + careportalEvent.json = generateJson(eventType, time, notes).toString() + careportalEvent.eventType = eventType + MainApp.getDbHelper().createOrUpdate(careportalEvent) + NSUpload.uploadEvent(eventType, time, notes) + } + + private fun generateJson(careportalEvent: String, time: Long, notes: String): JSONObject { val data = JSONObject() try { data.put("eventType", careportalEvent) From b264e480be9328e9404c79ccfbcca33a7549dde2 Mon Sep 17 00:00:00 2001 From: Sebastian Lenz Date: Fri, 17 Jan 2020 00:20:36 +0100 Subject: [PATCH 09/20] fix danar history layout --- app/src/main/res/layout/danar_historyactivity.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/danar_historyactivity.xml b/app/src/main/res/layout/danar_historyactivity.xml index 2693384c10..ea371daedb 100644 --- a/app/src/main/res/layout/danar_historyactivity.xml +++ b/app/src/main/res/layout/danar_historyactivity.xml @@ -77,7 +77,8 @@