Merge pull request #1879 from MilosKozak/psfix
ProfileSwitch validation
This commit is contained in:
commit
29c8740e08
|
@ -31,7 +31,7 @@ public class Constants {
|
||||||
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
|
public static final long remoteBolusMinDistance = 15 * 60 * 1000L;
|
||||||
|
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 30;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
public static final int CPP_MIN_TIMESHIFT = -6;
|
public static final int CPP_MIN_TIMESHIFT = -6;
|
||||||
public static final int CPP_MAX_TIMESHIFT = 23;
|
public static final int CPP_MAX_TIMESHIFT = 23;
|
||||||
|
|
|
@ -103,7 +103,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
||||||
editInsulin = view.findViewById(R.id.fill_insulinamount);
|
editInsulin = view.findViewById(R.id.fill_insulinamount);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
|
|
||||||
Button preset1Button = view.findViewById(R.id.fill_preset_button1);
|
Button preset1Button = view.findViewById(R.id.fill_preset_button1);
|
||||||
|
|
|
@ -42,12 +42,12 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxExtendedBolusAllowed().value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxExtendedBolusAllowed().value();
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
|
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
double extendedDurationStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusDurationStep;
|
double extendedDurationStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusDurationStep;
|
||||||
double extendedMaxDuration = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusMaxDuration;
|
double extendedMaxDuration = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusMaxDuration;
|
||||||
editDuration = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_duration);
|
editDuration = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_duration);
|
||||||
editDuration.setParams(extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false);
|
editDuration.setParams(extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
|
|
|
@ -66,17 +66,17 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
||||||
basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
||||||
double maxTempPercent = pumpDescription.maxTempPercent;
|
double maxTempPercent = pumpDescription.maxTempPercent;
|
||||||
double tempPercentStep = pumpDescription.tempPercentStep;
|
double tempPercentStep = pumpDescription.tempPercentStep;
|
||||||
basalPercent.setParams(100d, 0d, maxTempPercent, tempPercentStep, new DecimalFormat("0"), true);
|
basalPercent.setParams(100d, 0d, maxTempPercent, tempPercentStep, new DecimalFormat("0"), true, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
Double currentBasal = profile != null ? profile.getBasal() : 0d;
|
Double currentBasal = profile != null ? profile.getBasal() : 0d;
|
||||||
basalAbsolute = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
|
basalAbsolute = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalabsoluteinput);
|
||||||
basalAbsolute.setParams(currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true);
|
basalAbsolute.setParams(currentBasal, 0d, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, new DecimalFormat("0.00"), true, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
double tempDurationStep = pumpDescription.tempDurationStep;
|
double tempDurationStep = pumpDescription.tempDurationStep;
|
||||||
double tempMaxDuration = pumpDescription.tempMaxDuration;
|
double tempMaxDuration = pumpDescription.tempMaxDuration;
|
||||||
duration = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_duration);
|
duration = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_duration);
|
||||||
duration.setParams(tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false);
|
duration.setParams(tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
if ((pumpDescription.tempBasalStyle & PumpDescription.PERCENT) == PumpDescription.PERCENT && (pumpDescription.tempBasalStyle & PumpDescription.ABSOLUTE) == PumpDescription.ABSOLUTE) {
|
if ((pumpDescription.tempBasalStyle & PumpDescription.PERCENT) == PumpDescription.PERCENT && (pumpDescription.tempBasalStyle & PumpDescription.ABSOLUTE) == PumpDescription.ABSOLUTE) {
|
||||||
// Both allowed
|
// Both allowed
|
||||||
|
|
|
@ -266,14 +266,14 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, bgTextWatcher);
|
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
||||||
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
||||||
} else if (units.equals(Constants.MMOL)) {
|
} else if (units.equals(Constants.MMOL)) {
|
||||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, bgTextWatcher);
|
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
||||||
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
||||||
} else {
|
} else {
|
||||||
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, bgTextWatcher);
|
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
||||||
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
}
|
}
|
||||||
|
|
||||||
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
@ -287,16 +287,16 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
|
|
||||||
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||||
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
|
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok));
|
||||||
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||||
editDuration.setParams(0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
|
editDuration.setParams(0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
TextWatcher percentTextWatcher = new TextWatcher() {
|
TextWatcher percentTextWatcher = new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -320,7 +320,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
maxPercent = MainApp.getConstraintChecker().getMaxBasalPercentAllowed(profile).value();
|
maxPercent = MainApp.getConstraintChecker().getMaxBasalPercentAllowed(profile).value();
|
||||||
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||||
editPercent.setParams(0d, -100d, (double) maxPercent, 5d, new DecimalFormat("0"), true, percentTextWatcher);
|
editPercent.setParams(0d, -100d, (double) maxPercent, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok), percentTextWatcher);
|
||||||
|
|
||||||
TextWatcher absoluteTextWatcher = new TextWatcher() {
|
TextWatcher absoluteTextWatcher = new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -344,16 +344,16 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
maxAbsolute = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
maxAbsolute = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||||
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, absoluteTextWatcher);
|
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, view.findViewById(R.id.ok), absoluteTextWatcher);
|
||||||
|
|
||||||
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage);
|
editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage);
|
||||||
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false);
|
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
||||||
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
|
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
ProfileSwitch ps = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
ProfileSwitch ps = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
||||||
if (ps != null && ps.isCPP) {
|
if (ps != null && ps.isCPP) {
|
||||||
|
|
|
@ -66,9 +66,9 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
|
||||||
bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg);
|
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);
|
bgNumber.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
||||||
else
|
else
|
||||||
bgNumber.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
bgNumber.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
|
unitsView = (TextView) view.findViewById(R.id.overview_calibration_units);
|
||||||
unitsView.setText(units);
|
unitsView.setText(units);
|
||||||
|
|
|
@ -130,15 +130,15 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
startHypoTTCheckbox = view.findViewById(R.id.newcarbs_hypo_tt);
|
startHypoTTCheckbox = view.findViewById(R.id.newcarbs_hypo_tt);
|
||||||
|
|
||||||
editTime = view.findViewById(R.id.newcarbs_time);
|
editTime = view.findViewById(R.id.newcarbs_time);
|
||||||
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
editDuration = view.findViewById(R.id.new_carbs_duration);
|
editDuration = view.findViewById(R.id.new_carbs_duration);
|
||||||
editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, textWatcher);
|
editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
|
|
||||||
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
Button fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
Button fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
||||||
fav1Button.setOnClickListener(this);
|
fav1Button.setOnClickListener(this);
|
||||||
|
|
|
@ -126,12 +126,12 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
editLayout = view.findViewById(R.id.newinsulin_time_layout);
|
editLayout = view.findViewById(R.id.newinsulin_time_layout);
|
||||||
editLayout.setVisibility(View.GONE);
|
editLayout.setVisibility(View.GONE);
|
||||||
editTime = view.findViewById(R.id.newinsulin_time);
|
editTime = view.findViewById(R.id.newinsulin_time);
|
||||||
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
|
|
||||||
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
Button plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
Button plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
||||||
plus1Button.setOnClickListener(this);
|
plus1Button.setOnClickListener(this);
|
||||||
|
|
|
@ -101,8 +101,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount);
|
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount);
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||||
|
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
|
|
||||||
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only);
|
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only);
|
||||||
|
|
||||||
|
|
|
@ -238,11 +238,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
Double maxCorrection = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
Double maxCorrection = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
|
|
||||||
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
||||||
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, view.findViewById(R.id.ok), textWatcher);
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
initDialog();
|
initDialog();
|
||||||
|
|
||||||
setCancelable(true);
|
setCancelable(true);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
|
PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription();
|
||||||
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
View layout = inflater.inflate(R.layout.localprofile_fragment, container, false);
|
||||||
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia);
|
||||||
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, layout.findViewById(R.id.localprofile_save), textWatch);
|
||||||
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
mgdlView = (RadioButton) layout.findViewById(R.id.localprofile_mgdl);
|
||||||
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
||||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
|
@ -124,7 +124,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
||||||
LocalProfilePlugin.getPlugin().loadSettings();
|
LocalProfilePlugin.getPlugin().loadSettings();
|
||||||
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
mgdlView.setChecked(LocalProfilePlugin.getPlugin().mgdl);
|
||||||
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
mmolView.setChecked(LocalProfilePlugin.getPlugin().mmol);
|
||||||
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, textWatch);
|
diaView.setParams(LocalProfilePlugin.getPlugin().dia, 5d, 12d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.localprofile_save), textWatch);
|
||||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.gs(R.string.nsprofileview_ic_label) + ":", LocalProfilePlugin.getPlugin().ic, null, 0.5, 50d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.gs(R.string.nsprofileview_isf_label) + ":", LocalProfilePlugin.getPlugin().isf, null, 0.5, 500d, 0.1d, new DecimalFormat("0.0"), save);
|
||||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.gs(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), LocalProfilePlugin.getPlugin().basal, null, pumpDescription.basalMinimumRate, 10, 0.01d, new DecimalFormat("0.00"), save);
|
||||||
|
|
|
@ -97,10 +97,10 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
+ "\npumpUnits:" + pump.units
|
+ "\npumpUnits:" + pump.units
|
||||||
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
||||||
|
|
||||||
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false);
|
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false, findViewById(R.id.ok));
|
||||||
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false);
|
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false, findViewById(R.id.ok));
|
||||||
shutdown.setParams((double) pump.shutdownHour, 0d, 24d, 1d, new DecimalFormat("1"), true);
|
shutdown.setParams((double) pump.shutdownHour, 0d, 24d, 1d, new DecimalFormat("1"), true, findViewById(R.id.ok));
|
||||||
lowReservoir.setParams((double) pump.lowReservoirRate, 10d, 60d, 10d, new DecimalFormat("10"), false);
|
lowReservoir.setParams((double) pump.lowReservoirRate, 10d, 60d, 10d, new DecimalFormat("10"), false, findViewById(R.id.ok));
|
||||||
switch (pump.beepAndAlarm) {
|
switch (pump.beepAndAlarm) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
pumpAlarmSound.setChecked(true);
|
pumpAlarmSound.setChecked(true);
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -34,7 +33,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
View.OnTouchListener, View.OnClickListener {
|
View.OnTouchListener, View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NumberPicker.class);
|
private static Logger log = LoggerFactory.getLogger(NumberPicker.class);
|
||||||
|
|
||||||
TextView editText;
|
EditText editText;
|
||||||
Button minusButton;
|
Button minusButton;
|
||||||
Button plusButton;
|
Button plusButton;
|
||||||
|
|
||||||
|
@ -46,6 +45,8 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
boolean allowZero = false;
|
boolean allowZero = false;
|
||||||
TextWatcher textWatcher = null;
|
TextWatcher textWatcher = null;
|
||||||
|
|
||||||
|
Button okButton = null;
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private ScheduledExecutorService mUpdater;
|
private ScheduledExecutorService mUpdater;
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
|
|
||||||
private final int doubleLimit = 5;
|
private final int doubleLimit = 5;
|
||||||
|
|
||||||
public UpdateCounterTask(boolean inc) {
|
UpdateCounterTask(boolean inc) {
|
||||||
mInc = inc;
|
mInc = inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,39 +86,32 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
public NumberPicker(Context context, AttributeSet attrs) {
|
public NumberPicker(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
this.initialize(context, attrs);
|
this.initialize(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NumberPicker(Context context, AttributeSet attrs, int defStyleAttr) {
|
private void initialize(Context context) {
|
||||||
super(context, attrs, defStyleAttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initialize(Context context, AttributeSet attrs) {
|
|
||||||
// set layout view
|
// set layout view
|
||||||
LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true);
|
LayoutInflater.from(context).inflate(R.layout.number_picker_layout, this, true);
|
||||||
|
|
||||||
// init ui components
|
// init ui components
|
||||||
minusButton = (Button) findViewById(R.id.decrement);
|
minusButton = findViewById(R.id.decrement);
|
||||||
minusButton.setId(View.generateViewId());
|
minusButton.setId(View.generateViewId());
|
||||||
plusButton = (Button) findViewById(R.id.increment);
|
plusButton = findViewById(R.id.increment);
|
||||||
plusButton.setId(View.generateViewId());
|
plusButton.setId(View.generateViewId());
|
||||||
editText = (EditText) findViewById(R.id.display);
|
editText = findViewById(R.id.display);
|
||||||
editText.setId(View.generateViewId());
|
editText.setId(View.generateViewId());
|
||||||
|
|
||||||
mHandler = new Handler() {
|
mHandler = new Handler(msg -> {
|
||||||
@Override
|
switch (msg.what) {
|
||||||
public void handleMessage(Message msg) {
|
case MSG_INC:
|
||||||
switch (msg.what) {
|
inc(msg.arg1);
|
||||||
case MSG_INC:
|
return true;
|
||||||
inc(msg.arg1);
|
case MSG_DEC:
|
||||||
return;
|
dec(msg.arg1);
|
||||||
case MSG_DEC:
|
return true;
|
||||||
dec(msg.arg1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
super.handleMessage(msg);
|
|
||||||
}
|
}
|
||||||
};
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
minusButton.setOnTouchListener(this);
|
minusButton.setOnTouchListener(this);
|
||||||
minusButton.setOnKeyListener(this);
|
minusButton.setOnKeyListener(this);
|
||||||
|
@ -139,6 +133,13 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
value = SafeParse.stringToDouble(editText.getText().toString());
|
value = SafeParse.stringToDouble(editText.getText().toString());
|
||||||
|
if (okButton != null) {
|
||||||
|
if (value > maxValue || value < minValue)
|
||||||
|
okButton.setVisibility(INVISIBLE);
|
||||||
|
else
|
||||||
|
okButton.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -146,24 +147,42 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
public void setTextWatcher(TextWatcher textWatcher) {
|
public void setTextWatcher(TextWatcher textWatcher) {
|
||||||
this.textWatcher = textWatcher;
|
this.textWatcher = textWatcher;
|
||||||
editText.addTextChangedListener(textWatcher);
|
editText.addTextChangedListener(textWatcher);
|
||||||
|
editText.setOnFocusChangeListener((v, hasFocus) -> {
|
||||||
|
if (!hasFocus) {
|
||||||
|
value = SafeParse.stringToDouble(editText.getText().toString());
|
||||||
|
if (value > maxValue) {
|
||||||
|
value = maxValue;
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit));
|
||||||
|
updateEditText();
|
||||||
|
okButton.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
if (value < minValue) {
|
||||||
|
value = minValue;
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.youareonallowedlimit));
|
||||||
|
updateEditText();
|
||||||
|
okButton.setVisibility(VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, TextWatcher textWatcher) {
|
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, Button okButton, TextWatcher textWatcher) {
|
||||||
if (this.textWatcher != null) {
|
if (this.textWatcher != null) {
|
||||||
editText.removeTextChangedListener(this.textWatcher);
|
editText.removeTextChangedListener(this.textWatcher);
|
||||||
}
|
}
|
||||||
setParams(initValue, minValue, maxValue, step, formater, allowZero);
|
setParams(initValue, minValue, maxValue, step, formater, allowZero, okButton);
|
||||||
this.textWatcher = textWatcher;
|
this.textWatcher = textWatcher;
|
||||||
editText.addTextChangedListener(textWatcher);
|
editText.addTextChangedListener(textWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) {
|
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, Button okButton) {
|
||||||
this.value = initValue;
|
this.value = initValue;
|
||||||
this.minValue = minValue;
|
this.minValue = minValue;
|
||||||
this.maxValue = maxValue;
|
this.maxValue = maxValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.formater = formater;
|
this.formater = formater;
|
||||||
this.allowZero = allowZero;
|
this.allowZero = allowZero;
|
||||||
|
this.okButton = okButton;
|
||||||
|
|
||||||
editText.setKeyListener(DigitsKeyListener.getInstance(minValue < 0, step != Math.rint(step)));
|
editText.setKeyListener(DigitsKeyListener.getInstance(minValue < 0, step != Math.rint(step)));
|
||||||
|
|
||||||
|
|
|
@ -244,8 +244,8 @@ public class TimeListEdit {
|
||||||
if (i == 0) next = ONEHOURINSECONDS;
|
if (i == 0) next = ONEHOURINSECONDS;
|
||||||
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
|
fillSpinner(timeSpinner, secondFromMidnight(i), previous, next);
|
||||||
|
|
||||||
editText1.setParams(value1(i), min, max, step, formatter, false);
|
editText1.setParams(value1(i), min, max, step, formatter, false, view.findViewById(R.id.localprofile_save));
|
||||||
editText2.setParams(value2(i), min, max, step, formatter, false);
|
editText2.setParams(value2(i), min, max, step, formatter, false, view.findViewById(R.id.localprofile_save));
|
||||||
|
|
||||||
if (data2 == null) {
|
if (data2 == null) {
|
||||||
editText2.setVisibility(View.GONE);
|
editText2.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in a new issue