Insight: preemptive connection preference option

This commit is contained in:
Jamorham 2018-02-21 12:23:19 +00:00
parent 2f1efc7d06
commit 67b397b417
No known key found for this signature in database
GPG key ID: 0BC5C3E0AAD64DF9
3 changed files with 22 additions and 10 deletions

View file

@ -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,6 +494,7 @@ public class Connector {
@Subscribe
public void onStatusEvent(final EventFeatureRunning ev) {
if (SP.getBoolean("insight_preemptive_connect", true)) {
switch (ev.getFeature()) {
case WIZARD:
log("Wizard feature detected, preconnecting to pump");
@ -505,3 +507,4 @@ public class Connector {
}
}
}
}

View file

@ -904,5 +904,8 @@
<string name="insight_keepalive_format_string">%ds expires %s</string>
<string name="insight_keep_alive_status">Keep-alive status</string>
<string name="statistics">Statistics</string>
<string name="connect_preemptively">Connect preemptively</string>
<string name="automatically_connect_when">Automatically connect when AndroidAPS screens are opened, before any pump command is requested, to reduce connection delay</string>
<string name="not_recommended_due_to_battery_drain">Not recommended due to battery drain</string>
</resources>

View file

@ -7,7 +7,13 @@
<SwitchPreference
android:defaultValue="false"
android:key="insight_always_connected"
android:title="@string/insight_stay_always_connected" />
android:title="@string/insight_stay_always_connected"
android:summary="@string/not_recommended_due_to_battery_drain"/>
<SwitchPreference
android:defaultValue="true"
android:key="insight_preemptive_connect"
android:title="@string/connect_preemptively"
android:summary="@string/automatically_connect_when"/>
<SwitchPreference
android:defaultValue="false"
android:key="insight_real_tbr_cancel"