Merge branch 'dev' of git://github.com/MilosKozak/AndroidAps into dev

This commit is contained in:
Andreas Eggen 2018-04-23 08:26:48 +02:00
commit 511b9c6819
5 changed files with 33 additions and 12 deletions

View file

@ -27,6 +27,9 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.APSInterface;
@ -54,6 +57,7 @@ public class LoopPlugin extends PluginBase {
public static final String CHANNEL_ID = "AndroidAPS-Openloop";
long lastBgTriggeredRun = 0;
protected static LoopPlugin loopPlugin;
@ -133,11 +137,33 @@ public class LoopPlugin extends PluginBase {
}
}
/**
* This method is triggered once autosens calculation has completed, so the LoopPlugin
* has current data to work with. However, autosens calculation can be triggered by multiple
* sources and currently only a new BG should trigger a loop run. Hence we return early if
* the event causing the calculation is not EventNewBg.
*
* Callers of {@link info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin#runCalculation(String, long, boolean, Event)}
* are sources triggering a calculation which triggers this method upon completion.
*/
@Subscribe
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
if (ev.cause instanceof EventNewBG) {
invoke(ev.getClass().getSimpleName() + "(" + ev.cause.getClass().getSimpleName() + ")", true);
if (!(ev.cause instanceof EventNewBG)) {
// Autosens calculation not triggered by a new BG
return;
}
BgReading bgReading = DatabaseHelper.actualBg();
if (bgReading == null) {
// BG outdated
return;
}
if (bgReading.date <= lastBgTriggeredRun) {
// already looped with that value
return;
}
lastBgTriggeredRun = bgReading.date;
invoke("AutosenseCalculation for " + bgReading, true);
}
public long suspendedTo() {

View file

@ -135,7 +135,7 @@ public class NSClientPlugin extends PluginBase {
public void onStatusEvent(final EventNetworkChange ev) {
boolean wifiOnly = SP.getBoolean(R.string.key_ns_wifionly, false);
String allowedSSIDs = SP.getString(R.string.key_ns_wifi_ssids, "");
boolean allowRoaming = SP.getBoolean(R.string.key_ns_allowroaming, true);
boolean allowRoaming = SP.getBoolean(R.string.key_ns_allowroaming, true) && !wifiOnly;
boolean newAllowedState = true;

View file

@ -1174,7 +1174,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
extendedBolusView.setText(extendedBolusText);
}
if (extendedBolusText.equals(""))
extendedBolusView.setVisibility(View.INVISIBLE);
extendedBolusView.setVisibility(View.GONE);
else
extendedBolusView.setVisibility(View.VISIBLE);
}

View file

@ -163,19 +163,13 @@
android:id="@+id/overview_runningtemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal|bold" />
<TextView
android:layout_width="20dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/overview_basebasal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
@ -193,8 +187,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:paddingTop="5dp">
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"

View file

@ -90,6 +90,7 @@
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_wifionly"
android:disableDependentsState="true"
android:title="@string/ns_wifionly" />
<EditTextPreference
@ -100,6 +101,7 @@
<SwitchPreference
android:defaultValue="true"
android:dependency="@string/key_ns_wifionly"
android:key="@string/key_ns_allowroaming"
android:title="@string/ns_allowroaming" />