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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue