Insight: preemptive connection preference option
This commit is contained in:
parent
2f1efc7d06
commit
67b397b417
3 changed files with 22 additions and 10 deletions
|
@ -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.history.LiveHistory;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import sugar.free.sightparser.handling.ServiceConnectionCallback;
|
import sugar.free.sightparser.handling.ServiceConnectionCallback;
|
||||||
import sugar.free.sightparser.handling.SightServiceConnector;
|
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||||
import sugar.free.sightparser.handling.StatusCallback;
|
import sugar.free.sightparser.handling.StatusCallback;
|
||||||
|
@ -493,6 +494,7 @@ public class Connector {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventFeatureRunning ev) {
|
public void onStatusEvent(final EventFeatureRunning ev) {
|
||||||
|
if (SP.getBoolean("insight_preemptive_connect", true)) {
|
||||||
switch (ev.getFeature()) {
|
switch (ev.getFeature()) {
|
||||||
case WIZARD:
|
case WIZARD:
|
||||||
log("Wizard feature detected, preconnecting to pump");
|
log("Wizard feature detected, preconnecting to pump");
|
||||||
|
@ -505,3 +507,4 @@ public class Connector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -904,5 +904,8 @@
|
||||||
<string name="insight_keepalive_format_string">%ds expires %s</string>
|
<string name="insight_keepalive_format_string">%ds expires %s</string>
|
||||||
<string name="insight_keep_alive_status">Keep-alive status</string>
|
<string name="insight_keep_alive_status">Keep-alive status</string>
|
||||||
<string name="statistics">Statistics</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>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,13 @@
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_always_connected"
|
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
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_real_tbr_cancel"
|
android:key="insight_real_tbr_cancel"
|
||||||
|
|
Loading…
Reference in a new issue