From fc85deb62d74fa36efabe5f9b514c05fc6f55eae Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 10 May 2017 01:18:27 +0200 Subject: [PATCH] move evaluation of always_use_shortavg setting to the OAPS plugins For the overview and the watch we still may use the standard delta, even if this setting is enabled. (Also good to check that it is the same as in xDrip e.g.) --- .../info/nightscout/androidaps/data/GlucoseStatus.java | 2 +- .../plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java | 9 ++++++++- .../plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java index ad9b0acecf..c4caf2f1af 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/data/GlucoseStatus.java @@ -131,7 +131,7 @@ public class GlucoseStatus { status.short_avgdelta = average(short_deltas); - if (prefs.getBoolean("always_use_shortavg", false) || last_deltas.isEmpty()) { + if (last_deltas.isEmpty()) { status.delta = status.short_avgdelta; } else { status.delta = average(last_deltas); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index e2c7f20284..5b69b61728 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; +import android.preference.PreferenceManager; + import com.eclipsesource.v8.JavaVoidCallback; import com.eclipsesource.v8.V8; import com.eclipsesource.v8.V8Array; @@ -243,7 +245,12 @@ public class DetermineBasalAdapterAMAJS { mGlucoseStatus = new V8Object(mV8rt); mGlucoseStatus.add("glucose", glucoseStatus.glucose); - mGlucoseStatus.add("delta", glucoseStatus.delta); + + if(PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean("always_use_shortavg", false)){ + mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta); + } else { + mGlucoseStatus.add("delta", glucoseStatus.delta); + } mGlucoseStatus.add("short_avgdelta", glucoseStatus.short_avgdelta); mGlucoseStatus.add("long_avgdelta", glucoseStatus.long_avgdelta); mV8rt.add(PARAM_glucoseStatus, mGlucoseStatus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java index 75f87021c5..d51864aea3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.OpenAPSMA; +import android.preference.PreferenceManager; + import com.eclipsesource.v8.JavaVoidCallback; import com.eclipsesource.v8.V8; import com.eclipsesource.v8.V8Array; @@ -13,6 +15,7 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.MealData; @@ -251,7 +254,11 @@ public class DetermineBasalAdapterMAJS { mIobData.add("hightempinsulin", iobData.hightempinsulin); mGlucoseStatus.add("glucose", glucoseStatus.glucose); - mGlucoseStatus.add("delta", glucoseStatus.delta); + if(PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean("always_use_shortavg", false)){ + mGlucoseStatus.add("delta", glucoseStatus.short_avgdelta); + } else { + mGlucoseStatus.add("delta", glucoseStatus.delta); + } mGlucoseStatus.add("avgdelta", glucoseStatus.avgdelta); mMealData.add("carbs", mealData.carbs);