From 4fc935f0bdba1036c749468dd72da12e3f2edaf5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 27 Jun 2017 19:14:32 +0200 Subject: [PATCH] bolus dialog numberpickers --- .../Overview/Dialogs/CalibrationDialog.java | 6 +- .../Overview/Dialogs/NewTreatmentDialog.java | 19 +-- .../layout/overview_newtreatment_dialog.xml | 158 +++++------------- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 53 insertions(+), 134 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java index 83b341b03c..96ec8f2ba4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java @@ -62,10 +62,10 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg); - if (units.equals(Constants.MMOL)) + if (units.equals(Constants.MMOL)) bgNumber.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false); else - bgNumber.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false); + bgNumber.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false); unitsView = (TextView) view.findViewById(R.id.overview_calibration_units); unitsView.setText(units); @@ -77,7 +77,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis public void onClick(View view) { switch (view.getId()) { case R.id.ok: - final Double bg = SafeParse.stringToDouble(bgNumber.getText().toString()); + final Double bg = SafeParse.stringToDouble(bgNumber.getText()); XdripCalibrations.confirmAndSendCalibration(bg, context); dismiss(); Answers.getInstance().logCustom(new CustomEvent("Calibration")); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java index e9a63c89db..0eb8d93720 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java @@ -29,13 +29,14 @@ import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.utils.NumberPicker; import info.nightscout.utils.PlusMinusEditText; import info.nightscout.utils.SafeParse; public class NewTreatmentDialog extends DialogFragment implements OnClickListener { - PlusMinusEditText editCarbs; - PlusMinusEditText editInsulin; + NumberPicker editCarbs; + NumberPicker editInsulin; Handler mHandler; public static HandlerThread mHandlerThread; @@ -60,19 +61,15 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit); Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit); - editCarbs = new PlusMinusEditText(view, R.id.treatments_newtreatment_carbsamount, R.id.treatments_newtreatment_carbsamount_plus, R.id.treatments_newtreatment_carbsamount_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false); - editInsulin = new PlusMinusEditText(view, R.id.treatments_newtreatment_insulinamount, R.id.treatments_newtreatment_insulinamount_plus, R.id.treatments_newtreatment_insulinamount_minus, 0d, 0d, maxInsulin, MainApp.getConfigBuilder().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false); + editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount); + editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount); + + editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false); + editInsulin.setParams(0d, 0d, maxInsulin, MainApp.getConfigBuilder().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false); return view; } - @Override - public void onResume() { - super.onResume(); - if (getDialog() != null) - getDialog().getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - } - @Override public void onClick(View view) { switch (view.getId()) { diff --git a/app/src/main/res/layout/overview_newtreatment_dialog.xml b/app/src/main/res/layout/overview_newtreatment_dialog.xml index 3ad0b8ebf2..cc7557ab80 100644 --- a/app/src/main/res/layout/overview_newtreatment_dialog.xml +++ b/app/src/main/res/layout/overview_newtreatment_dialog.xml @@ -12,135 +12,57 @@ android:layout_height="match_parent"> - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + - + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 242ca62650..0da74e858f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -39,8 +39,8 @@ Ins: IOB: Total IOB: - Insulin amount - Carbs amount + Insulin + Carbs BG Carbs Corr