diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index ba53b40935..5e99a6ca17 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java @@ -50,16 +50,15 @@ import static info.nightscout.utils.DateUtil.now; public class FillDialog extends DialogFragment implements OnClickListener { private static Logger log = LoggerFactory.getLogger(FillDialog.class); + private CheckBox pumpSiteChangeCheckbox; + private CheckBox insulinCartridgeChangeCheckbox; + + private NumberPicker editInsulin; + double amount1 = 0d; double amount2 = 0d; double amount3 = 0d; - CheckBox pumpSiteChangeCheckbox; - CheckBox insulinCartridgeChangeCheckbox; - - NumberPicker editInsulin; - - private LinearLayout notesLayout; private EditText notesEdit; final private TextWatcher textWatcher = new TextWatcher() { @@ -133,7 +132,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { preset3Button.setVisibility(View.GONE); } - notesLayout = view.findViewById(R.id.fill_notes_layout); + LinearLayout notesLayout = view.findViewById(R.id.fill_notes_layout); notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE); notesEdit = view.findViewById(R.id.fill_notes); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java index 6805aa38c3..ee3d6517ea 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java @@ -53,28 +53,22 @@ import static info.nightscout.utils.DateUtil.now; public class NewCarbsDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener { private static Logger log = LoggerFactory.getLogger(NewCarbsDialog.class); - private Button fav1Button; - private Button fav2Button; - private Button fav3Button; - - private LinearLayout notesLayout; - private EditText notesEdit; - private static final int FAV1_DEFAULT = 5; private static final int FAV2_DEFAULT = 10; private static final int FAV3_DEFAULT = 20; + private RadioButton startActivityTTCheckbox; private RadioButton startEatingSoonTTCheckbox; private RadioButton startHypoTTCheckbox; private boolean togglingTT; private NumberPicker editTime; - private LinearLayout durationLayout; private NumberPicker editDuration; private NumberPicker editCarbs; - private Integer maxCarbs; + private EditText notesEdit; + //one shot guards private boolean accepted; private boolean okClicked; @@ -128,11 +122,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); - maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value(); - - editCarbs = view.findViewById(R.id.newcarb_carbsamount); - editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); - startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt); startActivityTTCheckbox.setOnCheckedChangeListener(this); startEatingSoonTTCheckbox = view.findViewById(R.id.newcarbs_eating_soon_tt); @@ -143,25 +132,30 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C editTime = view.findViewById(R.id.newcarbs_time); editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher); - durationLayout = view.findViewById(R.id.newcarbs_duration_layout); + LinearLayout durationLayout = view.findViewById(R.id.newcarbs_duration_layout); durationLayout.setVisibility(MainApp.engineeringMode ? View.VISIBLE : View.GONE); editDuration = view.findViewById(R.id.new_carbs_duration); editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, textWatcher); - fav1Button = view.findViewById(R.id.newcarbs_plus1); + maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value(); + + editCarbs = view.findViewById(R.id.newcarb_carbsamount); + editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); + + Button fav1Button = view.findViewById(R.id.newcarbs_plus1); fav1Button.setOnClickListener(this); fav1Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT))); - fav2Button = view.findViewById(R.id.newcarbs_plus2); + Button fav2Button = view.findViewById(R.id.newcarbs_plus2); fav2Button.setOnClickListener(this); fav2Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT))); - fav3Button = view.findViewById(R.id.newcarbs_plus3); + Button fav3Button = view.findViewById(R.id.newcarbs_plus3); fav3Button.setOnClickListener(this); fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT))); - notesLayout = view.findViewById(R.id.newcarbs_notes_layout); + LinearLayout notesLayout = view.findViewById(R.id.newcarbs_notes_layout); notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE); notesEdit = view.findViewById(R.id.newcarbs_notes); @@ -336,7 +330,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C int timeOffset = editTime.getValue().intValue(); final long time = now() + timeOffset * 1000 * 60; if (timeOffset != 0) { - actions.add("Time: " + DateUtil.dateAndTimeString(time)); + actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)); } int duration = editDuration.getValue().intValue(); if (duration > 0) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java index 7c6ca70eb4..d886673da5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java @@ -55,16 +55,6 @@ import static info.nightscout.utils.DateUtil.now; public class NewInsulinDialog extends DialogFragment implements OnClickListener { private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class); - private LinearLayout editLayout; - private NumberPicker editTime; - private NumberPicker editInsulin; - private LinearLayout notesLayout; - private EditText notesEdit; - - private Button plus1Button; - private Button plus2Button; - private Button plus3Button; - public static final double PLUS1_DEFAULT = 0.5d; public static final double PLUS2_DEFAULT = 1d; public static final double PLUS3_DEFAULT = 2d; @@ -72,8 +62,13 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener private CheckBox startESMCheckbox; private CheckBox recordOnlyCheckbox; + private LinearLayout editLayout; + private NumberPicker editTime; + private NumberPicker editInsulin; private Double maxInsulin; + private EditText notesEdit; + //one shot guards private boolean accepted; private boolean okClicked; @@ -137,17 +132,17 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener editInsulin = view.findViewById(R.id.newinsulin_amount); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); - plus1Button = view.findViewById(R.id.newinsulin_plus05); + Button plus1Button = view.findViewById(R.id.newinsulin_plus05); plus1Button.setOnClickListener(this); plus1Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT))); - plus2Button = view.findViewById(R.id.newinsulin_plus10); + Button plus2Button = view.findViewById(R.id.newinsulin_plus10); plus2Button.setOnClickListener(this); plus2Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT))); - plus3Button = view.findViewById(R.id.newinsulin_plus20); + Button plus3Button = view.findViewById(R.id.newinsulin_plus20); plus3Button.setOnClickListener(this); plus3Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT))); - notesLayout = view.findViewById(R.id.newcarbs_notes_layout); + LinearLayout notesLayout = view.findViewById(R.id.newcarbs_notes_layout); notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE); notesEdit = view.findViewById(R.id.newcarbs_notes); @@ -234,7 +229,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener int timeOffset = editTime.getValue().intValue(); final long time = now() + timeOffset * 1000 * 60; if (timeOffset != 0) { - actions.add(MainApp.gs(R.string.time) + DateUtil.dateAndTimeString(time)); + actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)); } final String notes = notesEdit.getText().toString(); if (!notes.isEmpty()) { @@ -268,35 +263,33 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget); } - if (finalInsulinAfterConstraints == 0) { - return; - } - - DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); - detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS; - detailedBolusInfo.insulin = finalInsulinAfterConstraints; - detailedBolusInfo.context = context; - detailedBolusInfo.source = Source.USER; - detailedBolusInfo.notes = notes; - if (recordOnlyCheckbox.isChecked()) { - detailedBolusInfo.date = time; - TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo); - } else { - detailedBolusInfo.date = now(); - ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { - @Override - public void run() { - if (!result.success) { - Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); - i.putExtra("soundid", R.raw.boluserror); - i.putExtra("status", result.comment); - i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - MainApp.instance().startActivity(i); + if (finalInsulinAfterConstraints > 0) { + DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); + detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS; + detailedBolusInfo.insulin = finalInsulinAfterConstraints; + detailedBolusInfo.context = context; + detailedBolusInfo.source = Source.USER; + detailedBolusInfo.notes = notes; + if (recordOnlyCheckbox.isChecked()) { + detailedBolusInfo.date = time; + TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo); + } else { + detailedBolusInfo.date = now(); + ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { + @Override + public void run() { + if (!result.success) { + Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); + i.putExtra("soundid", R.raw.boluserror); + i.putExtra("status", result.comment); + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + MainApp.instance().startActivity(i); + } } - } - }); - FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus")); + }); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus")); + } } } });