From b488e30459f62a71320b341ee1a213f90db5b569 Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Sun, 8 Apr 2018 18:46:29 +0200 Subject: [PATCH] Use uploadError for pump alarms --- .../PumpInsight/history/HistoryIntentAdapter.java | 13 +------------ .../main/java/info/nightscout/utils/NSUpload.java | 6 +++++- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java index 1ddc4fd4b7..768c719040 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/history/HistoryIntentAdapter.java @@ -160,18 +160,7 @@ class HistoryIntentAdapter { if (SP.getBoolean("insight_automatic_careportal_events", false)) { Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME); String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE); - if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return; - try { - JSONObject data = new JSONObject(); - String enteredBy = SP.getString("careportal_enteredby", ""); - if (!enteredBy.equals("")) data.put("enteredBy", enteredBy); - data.put("created_at", DateUtil.toISOString(date)); - data.put("eventType", CareportalEvent.NOTE); - data.put("notes", MainApp.instance().getString(getAlertText(alertType))); - NSUpload.uploadCareportalEntryToNS(data); - } catch (JSONException e) { - e.printStackTrace(); - } + NSUpload.uploadError(MainApp.instance().getString(getAlertText(alertType)), date); } } diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java index 96d24af4d4..9b9b940ef9 100644 --- a/app/src/main/java/info/nightscout/utils/NSUpload.java +++ b/app/src/main/java/info/nightscout/utils/NSUpload.java @@ -406,6 +406,10 @@ public class NSUpload { } public static void uploadError(String error) { + uploadError(error, new Date()); + } + + public static void uploadError(String error, Date date) { Context context = MainApp.instance().getApplicationContext(); Bundle bundle = new Bundle(); bundle.putString("action", "dbAdd"); @@ -413,7 +417,7 @@ public class NSUpload { JSONObject data = new JSONObject(); try { data.put("eventType", "Announcement"); - data.put("created_at", DateUtil.toISOString(new Date())); + data.put("created_at", DateUtil.toISOString(date)); data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name))); data.put("notes", error); data.put("isAnnouncement", true); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a0f5def32d..d13e47c779 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -990,5 +990,5 @@ Waiting for time synchronization (%d sec) Disconnected (%d m) Automatic careportal events - Automatically upload insulin, cannula and battery changes to Nightscout + Automatically upload insulin, cannula and battery changes and pump alarms to Nightscout