diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java index 2bfbccd265..bb1d16a22d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/connector/Connector.java @@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver; import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory; import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers; import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem; +import info.nightscout.utils.SP; import sugar.free.sightparser.handling.ServiceConnectionCallback; import sugar.free.sightparser.handling.SightServiceConnector; import sugar.free.sightparser.handling.StatusCallback; @@ -493,15 +494,17 @@ public class Connector { @Subscribe public void onStatusEvent(final EventFeatureRunning ev) { - switch (ev.getFeature()) { - case WIZARD: - log("Wizard feature detected, preconnecting to pump"); - connectToPump(120 * 1000); - break; - case MAIN: - log("Main feature detected, preconnecting to pump"); - connectToPump(30 * 1000); - break; + if (SP.getBoolean("insight_preemptive_connect", true)) { + switch (ev.getFeature()) { + case WIZARD: + log("Wizard feature detected, preconnecting to pump"); + connectToPump(120 * 1000); + break; + case MAIN: + log("Main feature detected, preconnecting to pump"); + connectToPump(30 * 1000); + break; + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0787d6cc59..a92fc9bb5e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -904,5 +904,8 @@ %ds expires %s Keep-alive status Statistics + Connect preemptively + Automatically connect when AndroidAPS screens are opened, before any pump command is requested, to reduce connection delay + Not recommended due to battery drain diff --git a/app/src/main/res/xml/pref_insightpump.xml b/app/src/main/res/xml/pref_insightpump.xml index 9dc3c24d91..93d51f1318 100644 --- a/app/src/main/res/xml/pref_insightpump.xml +++ b/app/src/main/res/xml/pref_insightpump.xml @@ -7,7 +7,13 @@ + android:title="@string/insight_stay_always_connected" + android:summary="@string/not_recommended_due_to_battery_drain"/> +