From f8075927f2d79b712bb4d5b3926d2fd9065c50d4 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 13 Feb 2018 00:34:24 +0100 Subject: [PATCH] Make new behaviour configurable, default on. --- .../plugins/Overview/Dialogs/ErrorHelperActivity.java | 6 +++++- .../main/java/info/nightscout/utils/LocalAlertUtils.java | 8 ++++++-- app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_nsclientinternal.xml | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java index e11c57ba35..90cf9aecd5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/ErrorHelperActivity.java @@ -3,7 +3,9 @@ package info.nightscout.androidaps.plugins.Overview.Dialogs; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import info.nightscout.androidaps.R; import info.nightscout.utils.NSUpload; +import info.nightscout.utils.SP; public class ErrorHelperActivity extends AppCompatActivity { public ErrorHelperActivity() { @@ -20,6 +22,8 @@ public class ErrorHelperActivity extends AppCompatActivity { errorDialog.setTitle(getIntent().getStringExtra("title")); errorDialog.show(this.getSupportFragmentManager(), "Error"); - NSUpload.uploadError(getIntent().getStringExtra("status")); + if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { + NSUpload.uploadError(getIntent().getStringExtra("status")); + } } } diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java index 2d41ed0ca8..10bfa52013 100644 --- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java +++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java @@ -43,7 +43,9 @@ public class LocalAlertUtils { n.soundId = R.raw.alarm; SP.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold()); MainApp.bus().post(new EventNewNotification(n)); - NSUpload.uploadError(n.text); + if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { + NSUpload.uploadError(n.text); + } } } @@ -93,7 +95,9 @@ public class LocalAlertUtils { n.soundId = R.raw.alarm; SP.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold()); MainApp.bus().post(new EventNewNotification(n)); - NSUpload.uploadError(n.text); + if (SP.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { + NSUpload.uploadError(n.text); + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f035818105..5b8038ab52 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -929,5 +929,8 @@ Let current temp basal run Mute History browser + ns_create_announcements_from_errors + Create announcements from errors + Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments) diff --git a/app/src/main/res/xml/pref_nsclientinternal.xml b/app/src/main/res/xml/pref_nsclientinternal.xml index 5f401d6c0e..bbfb9e6a2c 100644 --- a/app/src/main/res/xml/pref_nsclientinternal.xml +++ b/app/src/main/res/xml/pref_nsclientinternal.xml @@ -27,6 +27,12 @@ android:key="@string/key_ns_logappstartedevent" android:title="@string/ns_logappstartedevent" /> + +