diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
index aca5100fb6..d64ee24a30 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java
@@ -31,6 +31,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
@@ -179,6 +181,9 @@ public class ActionStringHandler {
}
} else if ("wizard".equals(act[0])) {
+ sendError("Update APP on Watch!");
+ return;
+ } else if ("wizard2".equals(act[0])) {
////////////////////////////////////////////// WIZARD
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbsBeforeConstraints)).value();
@@ -188,10 +193,12 @@ public class ActionStringHandler {
return;
}
- boolean useBG = Boolean.parseBoolean(act[2]);
- boolean useBolusIOB = Boolean.parseBoolean(act[3]);
- boolean useBasalIOB = Boolean.parseBoolean(act[4]);
- int percentage = Integer.parseInt(act[5]);
+ boolean useBG = SP.getBoolean(R.string.key_wearwizard_bg, true);
+ boolean useBolusIOB = SP.getBoolean(R.string.key_wearwizard_bolusiob, true);
+ boolean useBasalIOB = SP.getBoolean(R.string.key_wearwizard_basaliob, true);
+ boolean useCOB = SP.getBoolean(R.string.key_wearwizard_cob, true);
+ boolean useTrend = SP.getBoolean(R.string.key_wearwizard_trend, false);
+ int percentage = Integer.parseInt(act[2]);
Profile profile = MainApp.getConfigBuilder().getProfile();
if (profile == null) {
@@ -205,9 +212,16 @@ public class ActionStringHandler {
return;
}
+ CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "Wizard wear");
+ if (useCOB && (cobInfo == null || cobInfo.displayCob == null)) {
+ sendError("Unknown COB! BG reading missing or recent app restart?");
+ return;
+ }
+
DecimalFormat format = new DecimalFormat("0.00");
+ DecimalFormat formatInt = new DecimalFormat("0");
BolusWizard bolusWizard = new BolusWizard();
- bolusWizard.doCalc(profile, null, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false);
+ bolusWizard.doCalc(profile, null, carbsAfterConstraints, useCOB?cobInfo.displayCob:0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, useTrend);
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(bolusWizard.calculatedTotalInsulin)).value();
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
@@ -232,11 +246,15 @@ public class ActionStringHandler {
rMessage += "\n_____________";
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
+ if (useCOB)
+ rMessage += "\nFrom" + formatInt.format(cobInfo.displayCob) + "g COB : " + format.format(bolusWizard.insulinFromCOB) + "U";
if (useBG) rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
if (useBolusIOB)
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
if (useBasalIOB)
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
+ if (useTrend)
+ rMessage += "\nFrom 15' trend: " + format.format(bolusWizard.insulinFromTrend) + "U";
if (percentage != 100) {
rMessage += "\nPercentage: " + format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 84acd8205c..f26e89a8e9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1035,4 +1035,13 @@
Current basal safety multiplier
n/a
Autobackfill BG
+ Wizard Settings
+ wearwizard_bg
+ wearwizard_trend
+ wearwizard_cob
+ wearwizard_bolusiob
+ wearwizard_basaliob
+ Calculations included in the Wizard result:
+ Display Settings
+ General Settings
diff --git a/app/src/main/res/xml/pref_wear.xml b/app/src/main/res/xml/pref_wear.xml
index 0dce661482..46cbfd7e22 100644
--- a/app/src/main/res/xml/pref_wear.xml
+++ b/app/src/main/res/xml/pref_wear.xml
@@ -13,35 +13,78 @@
android:summary="@string/wearcontrol_summary"
android:title="@string/wearcontrol_title" />
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
index 7701b17d25..5c16063bb2 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java
@@ -32,9 +32,6 @@ public class WizardActivity extends ViewSelectorActivity {
PlusMinusEditText editCarbs;
PlusMinusEditText editPercentage;
- boolean useBG;
- boolean includeBolusIOB;
- boolean includeBasalIOB;
boolean hasPercentage;
@@ -63,7 +60,7 @@ public class WizardActivity extends ViewSelectorActivity {
private class MyGridViewPagerAdapter extends GridPagerAdapter {
@Override
public int getColumnCount(int arg0) {
- return hasPercentage?6:5;
+ return hasPercentage?3:2;
}
@Override
@@ -86,79 +83,7 @@ public class WizardActivity extends ViewSelectorActivity {
setLabelToPlusMinusView(view, "carbs");
container.addView(view);
return view;
- } else if(col == 1){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("include BG?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(useBG){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- useBG = !useBG;
- if(useBG){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 2){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("Bolus IOB?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(includeBolusIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- includeBolusIOB = !includeBolusIOB;
- if(includeBolusIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 3){
- final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false);
- final TextView textView = (TextView) view.findViewById(R.id.label);
- textView.setText("Basal IOB?");
-
- final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton);
- if(includeBasalIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- togglebutton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- includeBasalIOB = !includeBasalIOB;
- if(includeBasalIOB){
- togglebutton.setImageResource(R.drawable.ic_toggle_on);
- } else {
- togglebutton.setImageResource(R.drawable.ic_toggle_off);
- }
- }
- });
- container.addView(view);
- return view;
- } else if(col == 4 && hasPercentage){
+ } else if(col == 1 && hasPercentage){
final View view = getInflatedPlusMinusView(container);
if (editPercentage == null) {
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
@@ -184,10 +109,7 @@ public class WizardActivity extends ViewSelectorActivity {
if (editPercentage != null) percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
- String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
- + " " + useBG
- + " " + includeBolusIOB
- + " " + includeBasalIOB
+ String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
+ " " + percentage;
ListenerService.initiateAction(WizardActivity.this, actionstring);
finish();
diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
index 34dce7dd11..da627f93ab 100644
--- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
+++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java
@@ -46,8 +46,8 @@ public class MainMenuActivity extends MenuListActivity {
Vector menuitems = new Vector();
menuitems.add("TempT");
- menuitems.add("Bolus");
if(showWizard) menuitems.add("Wizard");
+ menuitems.add("Bolus");
menuitems.add("Settings");
menuitems.add("Status");
if (showPrimeFill) menuitems.add("Prime/Fill");