From b1e3b45ce9f7ad75f5546775cb5ce80d6c7f2906 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 9 Sep 2017 15:34:00 +0200 Subject: [PATCH 1/3] Add temp target to Wizard dialog Also, store checkboxes' state as prefereces. (cherry picked from commit 6e1c66e) --- .../interfaces/TreatmentsInterface.java | 1 + .../ConfigBuilder/ConfigBuilderPlugin.java | 6 ++ .../Overview/Dialogs/WizardDialog.java | 56 ++++++++++++------- .../plugins/Overview/OverviewFragment.java | 10 ++-- .../plugins/Treatments/TreatmentsPlugin.java | 12 +++- .../plugins/Wear/ActionStringHandler.java | 5 +- .../info/nightscout/utils/BolusWizard.java | 35 ++++++------ .../res/layout/overview_wizard_dialog.xml | 38 +++++++++---- app/src/main/res/values/strings.xml | 7 +++ 9 files changed, 111 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java index 5e8b4e52e8..044b259ac9 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java @@ -52,6 +52,7 @@ public interface TreatmentsInterface { boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo); + TempTarget getTempTargetFromHistory(); TempTarget getTempTargetFromHistory(long time); Intervals getTempTargetsFromHistory(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 6bc0e1e807..8f6b47e2ff 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -890,6 +890,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain return newRecordCreated; } + @Override + @Nullable + public TempTarget getTempTargetFromHistory() { + return activeTreatments.getTempTargetFromHistory(System.currentTimeMillis()); + } + @Override @Nullable public TempTarget getTempTargetFromHistory(long time) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index bda03a8a27..bbfc688252 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -50,6 +50,7 @@ import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.Source; +import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; @@ -73,6 +74,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com TextView bgInsulin; TextView bgUnits; CheckBox bgCheckbox; + CheckBox ttCheckbox; TextView carbs; TextView carbsInsulin; TextView bolusIobInsulin; @@ -216,17 +218,21 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com cobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_cobinsulin); bgCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgcheckbox); + ttCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_ttcheckbox); + bgtrendCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgtrendcheckbox); + cobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_cobcheckbox); bolusIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bolusiobcheckbox); basalIobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_basaliobcheckbox); superbolusCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_sbcheckbox); - bgtrendCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_bgtrendcheckbox); - cobCheckbox = (CheckBox) view.findViewById(R.id.treatments_wizard_cobcheckbox); + loadCheckedStates(); + bgCheckbox.setOnCheckedChangeListener(this); + ttCheckbox.setOnCheckedChangeListener(this); + bgtrendCheckbox.setOnCheckedChangeListener(this); + cobCheckbox.setOnCheckedChangeListener(this); basalIobCheckbox.setOnCheckedChangeListener(this); bolusIobCheckbox.setOnCheckedChangeListener(this); superbolusCheckbox.setOnCheckedChangeListener(this); - bgtrendCheckbox.setOnCheckedChangeListener(this); - cobCheckbox.setOnCheckedChangeListener(this); profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile); profileSpinner.setOnItemSelectedListener(this); @@ -253,9 +259,29 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + saveCheckedStates(); + ttCheckbox.setEnabled(bgCheckbox.isChecked() && MainApp.getConfigBuilder().getTempTargetFromHistory() != null); calculateInsulin(); } + private void saveCheckedStates() { + SP.putBoolean(getString(R.string.key_wizard_include_bg), bgCheckbox.isChecked()); + SP.putBoolean(getString(R.string.key_wizard_include_tt), ttCheckbox.isChecked()); + SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked()); + SP.putBoolean(getString(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked()); + SP.putBoolean(getString(R.string.key_wizard_include_bolus_iob), bolusIobCheckbox.isChecked()); + SP.putBoolean(getString(R.string.key_wizard_include_basal_iob), basalIobCheckbox.isChecked()); + } + + private void loadCheckedStates() { + bgCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bg), true)); + ttCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_tt), false)); + bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false)); + cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false)); + bolusIobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bolus_iob), true)); + basalIobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_basal_iob), true)); + } + @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { calculateInsulin(); @@ -381,31 +407,17 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com BgReading lastBg = DatabaseHelper.actualBg(); if (lastBg != null) { - Double lastBgValue = lastBg.valueToUnits(units); - Double sens = profile.getIsf(); - Double targetBGLow = profile.getTargetLow(); - Double targetBGHigh = profile.getTargetHigh(); - Double bgDiff; - if (lastBgValue <= targetBGLow) { - bgDiff = lastBgValue - targetBGLow; - } else { - bgDiff = lastBgValue - targetBGHigh; - } - - bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + DecimalFormatter.to1Decimal(sens)); - bgInsulin.setText(DecimalFormatter.to2Decimal(bgDiff / sens) + "U"); editBg.removeTextChangedListener(textWatcher); //bgInput.setText(lastBg.valueToUnitsToString(units)); editBg.setValue(lastBg.valueToUnits(units)); editBg.addTextChangedListener(textWatcher); } else { - bg.setText(""); - bgInsulin.setText(""); editBg.removeTextChangedListener(textWatcher); //bgInput.setText(""); editBg.setValue(0d); editBg.addTextChangedListener(textWatcher); } + ttCheckbox.setEnabled(MainApp.getConfigBuilder().getTempTargetFromHistory() != null); // IOB calculation MainApp.getConfigBuilder().updateTotalIOBTreatments(); @@ -458,6 +470,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } c_bg = bgCheckbox.isChecked() ? c_bg : 0d; + TempTarget tempTarget = ttCheckbox.isChecked() ? MainApp.getConfigBuilder().getTempTargetFromHistory() : null; // COB Double c_cob = 0d; @@ -466,12 +479,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com try { c_cob = SafeParse.stringToDouble(ConfigBuilderPlugin.getActiveAPS().getLastAPSResult().json().getString("COB")); } catch (JSONException e) { + log.error("Unhandled exception", e); } } } BolusWizard wizard = new BolusWizard(); - wizard.doCalc(specificProfile, carbsAfterConstraint, c_cob, c_bg, corrAfterConstraint, bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked(), superbolusCheckbox.isChecked(), bgtrendCheckbox.isChecked()); + wizard.doCalc(specificProfile, tempTarget, carbsAfterConstraint, c_cob, c_bg, corrAfterConstraint, bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked(), superbolusCheckbox.isChecked(), bgtrendCheckbox.isChecked()); bg.setText(c_bg + " ISF: " + DecimalFormatter.to1Decimal(wizard.sens)); bgInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromBG) + "U"); @@ -522,6 +536,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com total.setText(getString(R.string.result) + ": " + insulinText + " " + carbsText); okButton.setVisibility(View.VISIBLE); } else { + // TODO this should also be run when loading the dialog as the OK button is initially visible + // but does nothing if neither carbs nor insulin is > 0 total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g"); okButton.setVisibility(View.INVISIBLE); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index d871bd4c40..363918a9b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -127,9 +127,6 @@ import info.nightscout.utils.Profiler; import info.nightscout.utils.Round; import info.nightscout.utils.SP; import info.nightscout.utils.ToastUtils; -//Added By Rumen for staledata alarm -import info.nightscout.androidaps.plugins.Overview.Notification; -import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener { private static Logger log = LoggerFactory.getLogger(OverviewFragment.class); @@ -637,12 +634,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, void onClickQuickwizard() { final BgReading actualBg = DatabaseHelper.actualBg(); final Profile profile = MainApp.getConfigBuilder().getProfile(); + final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(); QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive(); if (quickWizardEntry != null && actualBg != null) { quickWizardButton.setVisibility(View.VISIBLE); BolusWizard wizard = new BolusWizard(); - wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false); + wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false); final JSONObject boluscalcJSON = new JSONObject(); try { @@ -976,7 +974,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, } // temp target - TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis()); + TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(); if (tempTarget != null) { tempTargetView.setTextColor(Color.BLACK); tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); @@ -1117,7 +1115,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, quickWizardButton.setVisibility(View.VISIBLE); String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g"; BolusWizard wizard = new BolusWizard(); - wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false); + wizard.doCalc(profile, tempTarget, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false); text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U"; quickWizardButton.setText(text); if (wizard.calculatedTotalInsulin <= 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 0f5a6c582e..c7962cabc2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -272,7 +272,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public TemporaryBasal getRealTempBasalFromHistory(long time) { - return (TemporaryBasal) tempBasals.getValueByInterval(time); + return tempBasals.getValueByInterval(time); } @Override @@ -358,7 +358,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { @Override public ExtendedBolus getExtendedBolusFromHistory(long time) { - return (ExtendedBolus) extendedBoluses.getValueByInterval(time); + return extendedBoluses.getValueByInterval(time); } @Override @@ -464,10 +464,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { initializeTempTargetData(); } + @Nullable + @Override + public TempTarget getTempTargetFromHistory() { + return tempTargets.getValueByInterval(System.currentTimeMillis()); + } + @Nullable @Override public TempTarget getTempTargetFromHistory(long time) { - return (TempTarget) tempTargets.getValueByInterval(time); + return tempTargets.getValueByInterval(time); } @Override 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 e60e30d158..07d41a0d8a 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 @@ -202,9 +202,10 @@ public class ActionStringHandler { sendError("No recent BG to base calculation on!"); return; } + DecimalFormat format = new DecimalFormat("0.00"); BolusWizard bolusWizard = new BolusWizard(); - bolusWizard.doCalc(profile, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false); + bolusWizard.doCalc(profile, null, carbsAfterConstraints, 0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d, 0d, percentage, useBolusIOB, useBasalIOB, false, false); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin); if (insulinAfterConstraints - bolusWizard.calculatedTotalInsulin != 0) { @@ -470,7 +471,7 @@ public class ActionStringHandler { } //Check for Temp-Target: - TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis()); + TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(); if (tempTarget != null) { ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, profile.getUnits()); ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd()); diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java index f4eb4907ef..984454005c 100644 --- a/app/src/main/java/info/nightscout/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java @@ -1,12 +1,11 @@ package info.nightscout.utils; -import java.util.Date; - import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.GlucoseStatus; -import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.db.TempTarget; +import info.nightscout.androidaps.interfaces.TreatmentsInterface; /** * Created by mike on 11.10.2016. @@ -15,6 +14,7 @@ import info.nightscout.androidaps.data.Profile; public class BolusWizard { // Inputs Profile specificProfile = null; + TempTarget tempTarget; public Integer carbs = 0; Double bg = 0d; Double correction; @@ -33,9 +33,6 @@ public class BolusWizard { public Double targetBGHigh = 0d; public Double bgDiff = 0d; - IobTotal bolusIob; - IobTotal basalIob; - public Double insulinFromBG = 0d; public Double insulinFromCarbs = 0d; public Double insulingFromBolusIOB = 0d; @@ -50,23 +47,29 @@ public class BolusWizard { public Double totalBeforePercentageAdjustment = 0d; public Double carbsEquivalent = 0d; - public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) { - return doCalc(specificProfile, carbs, cob, bg, correction, 100d, includeBolusIOB, includeBasalIOB, superBolus, trend); + public Double doCalc(Profile specificProfile, TempTarget tempTarget, Integer carbs, Double cob, Double bg, Double correction, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) { + return doCalc(specificProfile, tempTarget, carbs, cob, bg, correction, 100d, includeBolusIOB, includeBasalIOB, superBolus, trend); } - public Double doCalc(Profile specificProfile, Integer carbs, Double cob, Double bg, Double correction, double percentageCorrection, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) { + public Double doCalc(Profile specificProfile, TempTarget tempTarget, Integer carbs, Double cob, Double bg, Double correction, double percentageCorrection, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) { this.specificProfile = specificProfile; + this.tempTarget = tempTarget; this.carbs = carbs; this.bg = bg; this.correction = correction; + this.includeBolusIOB = includeBolusIOB; + this.includeBasalIOB = includeBasalIOB; this.superBolus = superBolus; this.trend = trend; - // Insulin from BG sens = specificProfile.getIsf(); targetBGLow = specificProfile.getTargetLow(); targetBGHigh = specificProfile.getTargetHigh(); + if (tempTarget != null) { + targetBGLow = tempTarget.low; + targetBGHigh = tempTarget.high; + } if (bg <= targetBGLow) { bgDiff = bg - targetBGLow; } else { @@ -108,13 +111,13 @@ public class BolusWizard { } // Total - calculatedTotalInsulin = totalBeforePercentageAdjustment = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB; - - //percentage - if(totalBeforePercentageAdjustment > 0){ - calculatedTotalInsulin = totalBeforePercentageAdjustment*percentageCorrection/100d; - } + calculatedTotalInsulin = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB; + // Percentage adjustment + totalBeforePercentageAdjustment = calculatedTotalInsulin; + if (calculatedTotalInsulin > 0) { + calculatedTotalInsulin = calculatedTotalInsulin * percentageCorrection / 100d; + } if (calculatedTotalInsulin < 0) { carbsEquivalent = -calculatedTotalInsulin * ic; diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml index c7b764faba..a8aa4bdd4f 100644 --- a/app/src/main/res/layout/overview_wizard_dialog.xml +++ b/app/src/main/res/layout/overview_wizard_dialog.xml @@ -225,15 +225,29 @@ + + + + @@ -269,7 +283,7 @@ android:id="@+id/treatments_wizard_bgtrend" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:width="100dp" + android:width="94dp" android:textAppearance="?android:attr/textAppearanceSmall" /> @@ -306,7 +320,7 @@ android:id="@+id/treatments_wizard_cob" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:width="100dp" + android:width="94dp" android:textAppearance="?android:attr/textAppearanceSmall" /> @@ -412,7 +426,7 @@ android:id="@+id/treatments_wizard_carbs" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:width="100dp" + android:width="94dp" android:textAppearance="?android:attr/textAppearanceSmall" /> @@ -446,7 +460,7 @@ android:id="@+id/treatments_wizard_sb" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:width="100dp" + android:width="94dp" android:textAppearance="?android:attr/textAppearanceSmall" /> @@ -480,7 +494,7 @@ android:id="@+id/treatments_wizard_correction" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:width="100dp" + android:width="94dp" android:textAppearance="?android:attr/textAppearanceSmall" /> Insulin Carbs BG + TT Carbs Corr U @@ -701,5 +702,11 @@ ACTIVATE PROFILE Date INVALID + wizard_include_bg + wizard_include_tt + wizard_include_cob + wizard_include_trend_bg + wizard_include_bolus_iob + wizard_include_basal_iob From 627cb8e9b2bfec42b7ac61595fc19adffd564afe Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 9 Sep 2017 16:37:08 +0200 Subject: [PATCH 2/3] WizardDialog: don't persist state of tt checkbox, default to false. This assumes that a default is not useful, as it needs to be decided whether this is needed on each case (using tt when bolusing to start eating soon, but not using it when bolusing for the meal at the end of a tt). --- .../androidaps/plugins/Overview/Dialogs/WizardDialog.java | 2 -- app/src/main/res/layout/overview_wizard_dialog.xml | 2 +- app/src/main/res/values/strings.xml | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index bbfc688252..4b81737a0e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -266,7 +266,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com private void saveCheckedStates() { SP.putBoolean(getString(R.string.key_wizard_include_bg), bgCheckbox.isChecked()); - SP.putBoolean(getString(R.string.key_wizard_include_tt), ttCheckbox.isChecked()); SP.putBoolean(getString(R.string.key_wizard_include_cob), cobCheckbox.isChecked()); SP.putBoolean(getString(R.string.key_wizard_include_trend_bg), bgtrendCheckbox.isChecked()); SP.putBoolean(getString(R.string.key_wizard_include_bolus_iob), bolusIobCheckbox.isChecked()); @@ -275,7 +274,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com private void loadCheckedStates() { bgCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bg), true)); - ttCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_tt), false)); bgtrendCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_trend_bg), false)); cobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_cob), false)); bolusIobCheckbox.setChecked(SP.getBoolean(getString(R.string.key_wizard_include_bolus_iob), true)); diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml index a8aa4bdd4f..faaae6967d 100644 --- a/app/src/main/res/layout/overview_wizard_dialog.xml +++ b/app/src/main/res/layout/overview_wizard_dialog.xml @@ -234,7 +234,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="32dp" - android:checked="true" /> + android:checked="false" /> Date INVALID wizard_include_bg - wizard_include_tt wizard_include_cob wizard_include_trend_bg wizard_include_bolus_iob From 07b04b8abfad42a9e13553395b88b7d0069b45ec Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 12 Sep 2017 01:23:38 +0200 Subject: [PATCH 3/3] Use correct units for low/high from TT. --- app/src/main/java/info/nightscout/utils/BolusWizard.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java index 984454005c..ec5c0ec02b 100644 --- a/app/src/main/java/info/nightscout/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java @@ -67,8 +67,8 @@ public class BolusWizard { targetBGLow = specificProfile.getTargetLow(); targetBGHigh = specificProfile.getTargetHigh(); if (tempTarget != null) { - targetBGLow = tempTarget.low; - targetBGHigh = tempTarget.high; + targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits()); + targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits()); } if (bg <= targetBGLow) { bgDiff = bg - targetBGLow;