commit
83fcc0723e
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -1035,4 +1035,13 @@
|
|||
<string name="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
|
||||
<string name="value_unavailable_short">n/a</string>
|
||||
<string name="ns_autobackfill_title">Autobackfill BG</string>
|
||||
<string name="wear_wizard_settings">Wizard Settings</string>
|
||||
<string translatable="false" name="key_wearwizard_bg">wearwizard_bg</string>
|
||||
<string translatable="false" name="key_wearwizard_trend">wearwizard_trend</string>
|
||||
<string translatable="false" name="key_wearwizard_cob">wearwizard_cob</string>
|
||||
<string translatable="false" name="key_wearwizard_bolusiob">wearwizard_bolusiob</string>
|
||||
<string translatable="false" name="key_wearwizard_basaliob">wearwizard_basaliob</string>
|
||||
<string name="wear_wizard_settings_summary">Calculations included in the Wizard result:</string>
|
||||
<string name="wear_display_settings">Display Settings</string>
|
||||
<string name="wear_general_settings">General Settings</string>
|
||||
</resources>
|
||||
|
|
|
@ -13,6 +13,46 @@
|
|||
android:summary="@string/wearcontrol_summary"
|
||||
android:title="@string/wearcontrol_title" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="wearplugin"
|
||||
android:title="@string/wear_wizard_settings"
|
||||
android:summary="@string/wear_wizard_settings_summary"
|
||||
android:dependency="wearcontrol">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/key_wearwizard_bg"
|
||||
android:title="@string/treatments_wizard_bg_label"
|
||||
android:defaultValue="true"
|
||||
android:dependency="wearcontrol"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/key_wearwizard_trend"
|
||||
android:title="@string/treatments_wizard_bgtrend_label"
|
||||
android:defaultValue="false"
|
||||
android:dependency="wearcontrol"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/key_wearwizard_cob"
|
||||
android:title="@string/treatments_wizard_cob_label"
|
||||
android:defaultValue="true"
|
||||
android:dependency="wearcontrol"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/key_wearwizard_bolusiob"
|
||||
android:title="@string/treatments_wizard_bolusiob_label"
|
||||
android:defaultValue="true"
|
||||
android:dependency="wearcontrol"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/key_wearwizard_basaliob"
|
||||
android:title="@string/treatments_wizard_basaliob_label"
|
||||
android:defaultValue="true"
|
||||
android:dependency="wearcontrol"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="wearplugin"
|
||||
android:title="@string/wear_display_settings">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="wear_detailediob"
|
||||
|
@ -30,18 +70,21 @@
|
|||
android:key="wear_showbgi"
|
||||
android:summary="@string/wear_showbgi_summary"
|
||||
android:title="@string/wear_showbgi_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="wear_notifySMB"
|
||||
android:summary="@string/wear_notifysmb_summary"
|
||||
android:title="@string/wear_notifysmb_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="wear_predictions"
|
||||
android:summary="@string/wear_predictions_summary"
|
||||
android:title="@string/wear_predictions_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="wearplugin"
|
||||
android:title="@string/wear_general_settings">
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="wear_notifySMB"
|
||||
android:summary="@string/wear_notifysmb_summary"
|
||||
android:title="@string/wear_notifysmb_title" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -46,8 +46,8 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
|
||||
Vector<String> menuitems = new Vector<String>();
|
||||
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");
|
||||
|
|
Loading…
Reference in a new issue