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.Actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
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.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
|
@ -179,6 +181,9 @@ public class ActionStringHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("wizard".equals(act[0])) {
|
} else if ("wizard".equals(act[0])) {
|
||||||
|
sendError("Update APP on Watch!");
|
||||||
|
return;
|
||||||
|
} else if ("wizard2".equals(act[0])) {
|
||||||
////////////////////////////////////////////// WIZARD
|
////////////////////////////////////////////// WIZARD
|
||||||
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
|
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
|
||||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbsBeforeConstraints)).value();
|
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbsBeforeConstraints)).value();
|
||||||
|
@ -188,10 +193,12 @@ public class ActionStringHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useBG = Boolean.parseBoolean(act[2]);
|
boolean useBG = SP.getBoolean(R.string.key_wearwizard_bg, true);
|
||||||
boolean useBolusIOB = Boolean.parseBoolean(act[3]);
|
boolean useBolusIOB = SP.getBoolean(R.string.key_wearwizard_bolusiob, true);
|
||||||
boolean useBasalIOB = Boolean.parseBoolean(act[4]);
|
boolean useBasalIOB = SP.getBoolean(R.string.key_wearwizard_basaliob, true);
|
||||||
int percentage = Integer.parseInt(act[5]);
|
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();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
@ -205,9 +212,16 @@ public class ActionStringHandler {
|
||||||
return;
|
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 format = new DecimalFormat("0.00");
|
||||||
|
DecimalFormat formatInt = new DecimalFormat("0");
|
||||||
BolusWizard bolusWizard = new BolusWizard();
|
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();
|
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(bolusWizard.calculatedTotalInsulin)).value();
|
||||||
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
|
if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) {
|
||||||
|
@ -232,11 +246,15 @@ public class ActionStringHandler {
|
||||||
rMessage += "\n_____________";
|
rMessage += "\n_____________";
|
||||||
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
|
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
|
||||||
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
|
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 (useBG) rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
|
||||||
if (useBolusIOB)
|
if (useBolusIOB)
|
||||||
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
|
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
|
||||||
if (useBasalIOB)
|
if (useBasalIOB)
|
||||||
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
|
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
|
||||||
|
if (useTrend)
|
||||||
|
rMessage += "\nFrom 15' trend: " + format.format(bolusWizard.insulinFromTrend) + "U";
|
||||||
if (percentage != 100) {
|
if (percentage != 100) {
|
||||||
rMessage += "\nPercentage: " + format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
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="openapsama_current_basal_safety_multiplier">Current basal safety multiplier</string>
|
||||||
<string name="value_unavailable_short">n/a</string>
|
<string name="value_unavailable_short">n/a</string>
|
||||||
<string name="ns_autobackfill_title">Autobackfill BG</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>
|
</resources>
|
||||||
|
|
|
@ -13,35 +13,78 @@
|
||||||
android:summary="@string/wearcontrol_summary"
|
android:summary="@string/wearcontrol_summary"
|
||||||
android:title="@string/wearcontrol_title" />
|
android:title="@string/wearcontrol_title" />
|
||||||
|
|
||||||
<SwitchPreference
|
<PreferenceCategory
|
||||||
android:defaultValue="true"
|
android:key="wearplugin"
|
||||||
android:key="wear_detailediob"
|
android:title="@string/wear_wizard_settings"
|
||||||
android:summary="@string/wear_detailedIOB_summary"
|
android:summary="@string/wear_wizard_settings_summary"
|
||||||
android:title="@string/wear_detailedIOB_title" />
|
android:dependency="wearcontrol">
|
||||||
|
|
||||||
<SwitchPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:key="@string/key_wearwizard_bg"
|
||||||
android:key="wear_detailed_delta"
|
android:title="@string/treatments_wizard_bg_label"
|
||||||
android:summary="@string/wear_detailed_delta_summary"
|
android:defaultValue="true"
|
||||||
android:title="@string/wear_detailed_delta_title" />
|
android:dependency="wearcontrol"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:key="@string/key_wearwizard_trend"
|
||||||
android:key="wear_showbgi"
|
android:title="@string/treatments_wizard_bgtrend_label"
|
||||||
android:summary="@string/wear_showbgi_summary"
|
android:defaultValue="false"
|
||||||
android:title="@string/wear_showbgi_title" />
|
android:dependency="wearcontrol"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:key="@string/key_wearwizard_cob"
|
||||||
android:key="wear_notifySMB"
|
android:title="@string/treatments_wizard_cob_label"
|
||||||
android:summary="@string/wear_notifysmb_summary"
|
android:defaultValue="true"
|
||||||
android:title="@string/wear_notifysmb_title" />
|
android:dependency="wearcontrol"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:key="@string/key_wearwizard_bolusiob"
|
||||||
android:key="wear_predictions"
|
android:title="@string/treatments_wizard_bolusiob_label"
|
||||||
android:summary="@string/wear_predictions_summary"
|
android:defaultValue="true"
|
||||||
android:title="@string/wear_predictions_title" />
|
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"
|
||||||
|
android:summary="@string/wear_detailedIOB_summary"
|
||||||
|
android:title="@string/wear_detailedIOB_title" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="wear_detailed_delta"
|
||||||
|
android:summary="@string/wear_detailed_delta_summary"
|
||||||
|
android:title="@string/wear_detailed_delta_title" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="wear_showbgi"
|
||||||
|
android:summary="@string/wear_showbgi_summary"
|
||||||
|
android:title="@string/wear_showbgi_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>
|
</PreferenceScreen>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -32,9 +32,6 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
PlusMinusEditText editCarbs;
|
PlusMinusEditText editCarbs;
|
||||||
PlusMinusEditText editPercentage;
|
PlusMinusEditText editPercentage;
|
||||||
|
|
||||||
boolean useBG;
|
|
||||||
boolean includeBolusIOB;
|
|
||||||
boolean includeBasalIOB;
|
|
||||||
boolean hasPercentage;
|
boolean hasPercentage;
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +60,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount(int arg0) {
|
public int getColumnCount(int arg0) {
|
||||||
return hasPercentage?6:5;
|
return hasPercentage?3:2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,79 +83,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
||||||
setLabelToPlusMinusView(view, "carbs");
|
setLabelToPlusMinusView(view, "carbs");
|
||||||
container.addView(view);
|
container.addView(view);
|
||||||
return view;
|
return view;
|
||||||
} else if(col == 1){
|
} else if(col == 1 && hasPercentage){
|
||||||
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){
|
|
||||||
final View view = getInflatedPlusMinusView(container);
|
final View view = getInflatedPlusMinusView(container);
|
||||||
if (editPercentage == null) {
|
if (editPercentage == null) {
|
||||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
|
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());
|
if (editPercentage != null) percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||||
|
|
||||||
String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
||||||
+ " " + useBG
|
|
||||||
+ " " + includeBolusIOB
|
|
||||||
+ " " + includeBasalIOB
|
|
||||||
+ " " + percentage;
|
+ " " + percentage;
|
||||||
ListenerService.initiateAction(WizardActivity.this, actionstring);
|
ListenerService.initiateAction(WizardActivity.this, actionstring);
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class MainMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
Vector<String> menuitems = new Vector<String>();
|
Vector<String> menuitems = new Vector<String>();
|
||||||
menuitems.add("TempT");
|
menuitems.add("TempT");
|
||||||
menuitems.add("Bolus");
|
|
||||||
if(showWizard) menuitems.add("Wizard");
|
if(showWizard) menuitems.add("Wizard");
|
||||||
|
menuitems.add("Bolus");
|
||||||
menuitems.add("Settings");
|
menuitems.add("Settings");
|
||||||
menuitems.add("Status");
|
menuitems.add("Status");
|
||||||
if (showPrimeFill) menuitems.add("Prime/Fill");
|
if (showPrimeFill) menuitems.add("Prime/Fill");
|
||||||
|
|
Loading…
Reference in a new issue