numberpicker in wizard dialog
This commit is contained in:
parent
4fc935f0bd
commit
c3876c730b
3 changed files with 99 additions and 243 deletions
|
@ -60,6 +60,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.NumberPicker;
|
||||||
import info.nightscout.utils.OKDialog;
|
import info.nightscout.utils.OKDialog;
|
||||||
import info.nightscout.utils.PlusMinusEditText;
|
import info.nightscout.utils.PlusMinusEditText;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -69,10 +70,7 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
|
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
|
private static Logger log = LoggerFactory.getLogger(WizardDialog.class);
|
||||||
|
|
||||||
Button wizardDialogDeliverButton;
|
Button okButton;
|
||||||
TextView correctionInput;
|
|
||||||
TextView carbsInput;
|
|
||||||
TextView bgInput;
|
|
||||||
TextView bg;
|
TextView bg;
|
||||||
TextView bgInsulin;
|
TextView bgInsulin;
|
||||||
TextView bgUnits;
|
TextView bgUnits;
|
||||||
|
@ -85,8 +83,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
CheckBox basalIobCheckbox;
|
CheckBox basalIobCheckbox;
|
||||||
TextView correctionInsulin;
|
TextView correctionInsulin;
|
||||||
TextView total;
|
TextView total;
|
||||||
TextView totalInsulin;
|
|
||||||
EditText carbTimeEdit;
|
|
||||||
Spinner profileSpinner;
|
Spinner profileSpinner;
|
||||||
CheckBox superbolusCheckbox;
|
CheckBox superbolusCheckbox;
|
||||||
TextView superbolus;
|
TextView superbolus;
|
||||||
|
@ -99,10 +95,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
TextView cob;
|
TextView cob;
|
||||||
TextView cobInsulin;
|
TextView cobInsulin;
|
||||||
|
|
||||||
PlusMinusEditText editBg;
|
NumberPicker editBg;
|
||||||
PlusMinusEditText editCarbs;
|
NumberPicker editCarbs;
|
||||||
PlusMinusEditText editCorr;
|
NumberPicker editCorr;
|
||||||
PlusMinusEditText editCarbTime;
|
NumberPicker editCarbTime;
|
||||||
|
|
||||||
Integer calculatedCarbs = 0;
|
Integer calculatedCarbs = 0;
|
||||||
Double calculatedTotalInsulin = 0d;
|
Double calculatedTotalInsulin = 0d;
|
||||||
|
@ -129,9 +125,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onPause();
|
||||||
if (getDialog() != null)
|
|
||||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,8 +189,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
wizardDialogDeliverButton = (Button) view.findViewById(R.id.treatments_wizard_deliverButton);
|
okButton = (Button) view.findViewById(R.id.ok);
|
||||||
wizardDialogDeliverButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
|
|
||||||
bg = (TextView) view.findViewById(R.id.treatments_wizard_bg);
|
bg = (TextView) view.findViewById(R.id.treatments_wizard_bg);
|
||||||
bgInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bginsulin);
|
bgInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bginsulin);
|
||||||
|
@ -207,8 +202,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
basalIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_basaliobinsulin);
|
basalIobInsulin = (TextView) view.findViewById(R.id.treatments_wizard_basaliobinsulin);
|
||||||
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
|
correctionInsulin = (TextView) view.findViewById(R.id.treatments_wizard_correctioninsulin);
|
||||||
total = (TextView) view.findViewById(R.id.treatments_wizard_total);
|
total = (TextView) view.findViewById(R.id.treatments_wizard_total);
|
||||||
totalInsulin = (TextView) view.findViewById(R.id.treatments_wizard_totalinsulin);
|
|
||||||
carbTimeEdit = (EditText) view.findViewById(R.id.treatments_wizard_carbtimeinput);
|
|
||||||
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
|
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
|
||||||
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
|
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
|
||||||
|
|
||||||
|
@ -236,22 +229,20 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
|
profileSpinner = (Spinner) view.findViewById(R.id.treatments_wizard_profile);
|
||||||
profileSpinner.setOnItemSelectedListener(this);
|
profileSpinner.setOnItemSelectedListener(this);
|
||||||
|
|
||||||
correctionInput = (TextView) view.findViewById(R.id.treatments_wizard_correctioninput);
|
editCarbTime = (NumberPicker) view.findViewById(R.id.treatments_wizard_carbtimeinput);
|
||||||
carbsInput = (TextView) view.findViewById(R.id.treatments_wizard_carbsinput);
|
editCorr = (NumberPicker) view.findViewById(R.id.treatments_wizard_correctioninput);
|
||||||
bgInput = (TextView) view.findViewById(R.id.treatments_wizard_bginput);
|
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_wizard_carbsinput);
|
||||||
correctionInput.addTextChangedListener(textWatcher);
|
editBg = (NumberPicker) view.findViewById(R.id.treatments_wizard_bginput);
|
||||||
carbsInput.addTextChangedListener(textWatcher);
|
|
||||||
bgInput.addTextChangedListener(textWatcher);
|
|
||||||
|
|
||||||
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
|
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
|
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
|
||||||
Double maxCorrection = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
|
Double maxCorrection = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
|
||||||
|
|
||||||
editBg = new PlusMinusEditText(view, R.id.treatments_wizard_bginput, R.id.treatments_wizard_bginput_plus, R.id.treatments_wizard_bginput_minus, 0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
||||||
editCarbs = new PlusMinusEditText(view, R.id.treatments_wizard_carbsinput, R.id.treatments_wizard_carbsinput_plus, R.id.treatments_wizard_carbsinput_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||||
editCorr = new PlusMinusEditText(view, R.id.treatments_wizard_correctioninput, R.id.treatments_wizard_correctioninput_plus, R.id.treatments_wizard_correctioninput_minus, 0d, -maxCorrection, maxCorrection, 0.05d, new DecimalFormat("0.00"), false);
|
editCorr.setParams(0d, -maxCorrection, maxCorrection, 0.05d, new DecimalFormat("0.00"), false, textWatcher);
|
||||||
editCarbTime = new PlusMinusEditText(view, R.id.treatments_wizard_carbtimeinput, R.id.treatments_wizard_carbtime_plus, R.id.treatments_wizard_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||||
initDialog();
|
initDialog();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
@ -265,19 +256,19 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
wizardDialogDeliverButton.setVisibility(View.VISIBLE);
|
okButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
|
ToastUtils.showToastInUiThread(context, MainApp.sResources.getString(R.string.noprofileselected));
|
||||||
wizardDialogDeliverButton.setVisibility(View.GONE);
|
okButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.treatments_wizard_deliverButton:
|
case R.id.ok:
|
||||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||||
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
String confirmMessage = getString(R.string.entertreatmentquestion);
|
String confirmMessage = getString(R.string.entertreatmentquestion);
|
||||||
|
@ -299,8 +290,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||||
final Double bg = SafeParse.stringToDouble(bgInput.getText().toString());
|
final Double bg = SafeParse.stringToDouble(editBg.getText());
|
||||||
final int carbTime = SafeParse.stringToInt(carbTimeEdit.getText().toString());
|
final int carbTime = SafeParse.stringToInt(editCarbTime.getText());
|
||||||
final boolean useSuperBolus = superbolusCheckbox.isChecked();
|
final boolean useSuperBolus = superbolusCheckbox.isChecked();
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
@ -350,6 +341,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case R.id.cancel:
|
||||||
|
dismiss();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,17 +390,17 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + DecimalFormatter.to1Decimal(sens));
|
bg.setText(lastBg.valueToUnitsToString(units) + " ISF: " + DecimalFormatter.to1Decimal(sens));
|
||||||
bgInsulin.setText(DecimalFormatter.to2Decimal(bgDiff / sens) + "U");
|
bgInsulin.setText(DecimalFormatter.to2Decimal(bgDiff / sens) + "U");
|
||||||
bgInput.removeTextChangedListener(textWatcher);
|
editBg.removeTextChangedListener(textWatcher);
|
||||||
//bgInput.setText(lastBg.valueToUnitsToString(units));
|
//bgInput.setText(lastBg.valueToUnitsToString(units));
|
||||||
editBg.setValue(lastBg.valueToUnits(units));
|
editBg.setValue(lastBg.valueToUnits(units));
|
||||||
bgInput.addTextChangedListener(textWatcher);
|
editBg.addTextChangedListener(textWatcher);
|
||||||
} else {
|
} else {
|
||||||
bg.setText("");
|
bg.setText("");
|
||||||
bgInsulin.setText("");
|
bgInsulin.setText("");
|
||||||
bgInput.removeTextChangedListener(textWatcher);
|
editBg.removeTextChangedListener(textWatcher);
|
||||||
//bgInput.setText("");
|
//bgInput.setText("");
|
||||||
editBg.setValue(0d);
|
editBg.setValue(0d);
|
||||||
bgInput.addTextChangedListener(textWatcher);
|
editBg.addTextChangedListener(textWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
|
@ -418,9 +412,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
||||||
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
||||||
|
|
||||||
totalInsulin.setText("");
|
|
||||||
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
|
|
||||||
|
|
||||||
// COB only if AMA is selected
|
// COB only if AMA is selected
|
||||||
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
|
if (ConfigBuilderPlugin.getActiveAPS() instanceof OpenAPSAMAPlugin && ConfigBuilderPlugin.getActiveAPS().getLastAPSResult() != null && ConfigBuilderPlugin.getActiveAPS().getLastAPSRun().after(new Date(System.currentTimeMillis() - 11 * 60 * 1000L))) {
|
||||||
cobLayout.setVisibility(View.VISIBLE);
|
cobLayout.setVisibility(View.VISIBLE);
|
||||||
|
@ -429,6 +420,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
cobLayout.setVisibility(View.GONE);
|
cobLayout.setVisibility(View.GONE);
|
||||||
cobAvailable = false;
|
cobAvailable = false;
|
||||||
}
|
}
|
||||||
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateInsulin() {
|
private void calculateInsulin() {
|
||||||
|
@ -439,23 +431,23 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
|
Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
|
||||||
|
|
||||||
// Entered values
|
// Entered values
|
||||||
Double c_bg = SafeParse.stringToDouble(bgInput.getText().toString());
|
Double c_bg = SafeParse.stringToDouble(editBg.getText());
|
||||||
Integer c_carbs = SafeParse.stringToInt(carbsInput.getText().toString());
|
Integer c_carbs = SafeParse.stringToInt(editCarbs.getText());
|
||||||
Double c_correction = SafeParse.stringToDouble(correctionInput.getText().toString());
|
Double c_correction = SafeParse.stringToDouble(editCorr.getText());
|
||||||
Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction);
|
Double corrAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(c_correction);
|
||||||
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
|
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
|
||||||
correctionInput.removeTextChangedListener(textWatcher);
|
editCorr.removeTextChangedListener(textWatcher);
|
||||||
correctionInput.setText("");
|
editCorr.setValue(0d);
|
||||||
correctionInput.addTextChangedListener(textWatcher);
|
editCorr.addTextChangedListener(textWatcher);
|
||||||
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Integer carbsAfterConstraint = MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs);
|
Integer carbsAfterConstraint = MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs);
|
||||||
if (c_carbs - carbsAfterConstraint != 0) {
|
if (c_carbs - carbsAfterConstraint != 0) {
|
||||||
carbsInput.removeTextChangedListener(textWatcher);
|
editCarbs.removeTextChangedListener(textWatcher);
|
||||||
carbsInput.setText("");
|
editCarbs.setValue(0d);
|
||||||
carbsInput.addTextChangedListener(textWatcher);
|
editCarbs.addTextChangedListener(textWatcher);
|
||||||
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
//wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.carbsconstraintapplied));
|
||||||
return;
|
return;
|
||||||
|
@ -489,14 +481,6 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
correctionInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCorrection) + "U");
|
correctionInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCorrection) + "U");
|
||||||
calculatedTotalInsulin = wizard.calculatedTotalInsulin;
|
calculatedTotalInsulin = wizard.calculatedTotalInsulin;
|
||||||
|
|
||||||
if (calculatedTotalInsulin <= 0) {
|
|
||||||
total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
|
|
||||||
totalInsulin.setText("");
|
|
||||||
} else {
|
|
||||||
total.setText("");
|
|
||||||
totalInsulin.setText(DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U");
|
|
||||||
}
|
|
||||||
|
|
||||||
calculatedCarbs = carbsAfterConstraint;
|
calculatedCarbs = carbsAfterConstraint;
|
||||||
|
|
||||||
// Superbolus
|
// Superbolus
|
||||||
|
@ -531,10 +515,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
||||||
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
|
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.to2Decimal(calculatedTotalInsulin) + "U") : "";
|
||||||
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
||||||
wizardDialogDeliverButton.setText(getString(R.string.send) + " " + insulinText + " " + carbsText);
|
total.setText(getString(R.string.send) + " " + insulinText + " " + carbsText);
|
||||||
wizardDialogDeliverButton.setVisibility(Button.VISIBLE);
|
okButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
wizardDialogDeliverButton.setVisibility(Button.INVISIBLE);
|
total.setText(getString(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
|
||||||
|
okButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
boluscalcJSON = new JSONObject();
|
boluscalcJSON = new JSONObject();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.utils;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -120,6 +121,19 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
||||||
plusButton.setOnClickListener(this);
|
plusButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeTextChangedListener(TextWatcher textWatcher) {
|
||||||
|
editText.removeTextChangedListener(textWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTextChangedListener(TextWatcher textWatcher) {
|
||||||
|
editText.addTextChangedListener(textWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParams(Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero, TextWatcher textWatcher) {
|
||||||
|
setParams(initValue, minValue, maxValue, step, formater, allowZero);
|
||||||
|
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) {
|
||||||
this.value = initValue;
|
this.value = initValue;
|
||||||
this.minValue = minValue;
|
this.minValue = minValue;
|
||||||
|
|
|
@ -26,38 +26,13 @@
|
||||||
android:width="120dp"
|
android:width="120dp"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/treatments_wizard_bg_label"
|
android:text="@string/treatments_wizard_bg_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<info.nightscout.utils.NumberPicker
|
||||||
android:id="@+id/treatments_wizard_bginput_minus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_minus"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/treatments_wizard_bginput"
|
android:id="@+id/treatments_wizard_bginput"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="130dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp" />
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/treatments_wizard_bginput_plus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_add"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/treatments_wizard_bgunits"
|
android:id="@+id/treatments_wizard_bgunits"
|
||||||
|
@ -84,40 +59,15 @@
|
||||||
android:width="120dp"
|
android:width="120dp"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/treatments_wizard_carbs_label"
|
android:text="@string/treatments_wizard_carbs_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<info.nightscout.utils.NumberPicker
|
||||||
android:id="@+id/treatments_wizard_carbsinput_minus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_minus"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/treatments_wizard_carbsinput"
|
android:id="@+id/treatments_wizard_carbsinput"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="130dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal" />
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:minWidth="200dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:text=""
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/treatments_wizard_carbsinput_plus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_add"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -143,40 +93,14 @@
|
||||||
android:width="120dp"
|
android:width="120dp"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/treatments_wizard_correction_label"
|
android:text="@string/treatments_wizard_correction_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<info.nightscout.utils.NumberPicker
|
||||||
android:id="@+id/treatments_wizard_correctioninput_minus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_minus"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/treatments_wizard_correctioninput"
|
android:id="@+id/treatments_wizard_correctioninput"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="130dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal" />
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:inputType="numberSigned|numberDecimal"
|
|
||||||
android:minWidth="200dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:text=""
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/treatments_wizard_correctioninput_plus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_add"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -194,50 +118,23 @@
|
||||||
android:id="@+id/treatments_wizard_carbtime_layout"
|
android:id="@+id/treatments_wizard_carbtime_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
android:width="120dp"
|
android:width="120dp"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/careportal_newnstreatment_carbtime_label"
|
android:text="@string/careportal_newnstreatment_carbtime_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<ImageView
|
<info.nightscout.utils.NumberPicker
|
||||||
android:id="@+id/treatments_wizard_carbtime_minus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_minus"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/treatments_wizard_carbtimeinput"
|
android:id="@+id/treatments_wizard_carbtimeinput"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="130dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal" />
|
||||||
android:layout_weight="0.5"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:inputType="numberDecimal"
|
|
||||||
android:minWidth="200dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:text=""
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/treatments_wizard_carbtime_plus"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/circle"
|
|
||||||
android:backgroundTint="#ffffff"
|
|
||||||
android:src="@drawable/ic_action_add"
|
|
||||||
android:tint="#ffffff" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -263,7 +160,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/careportal_newnstreatment_profile_label"
|
android:text="@string/careportal_newnstreatment_profile_label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/treatments_wizard_profile"
|
android:id="@+id/treatments_wizard_profile"
|
||||||
|
@ -284,32 +182,31 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:padding="10dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/treatments_wizard_deliverButton"
|
|
||||||
style="?android:attr/buttonStyle"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_gravity="center"
|
||||||
android:padding="10dp"
|
android:orientation="horizontal">
|
||||||
android:text="SEND TO PUMP"
|
|
||||||
android:textAllCaps="false"
|
<TextView
|
||||||
android:textSize="20sp" />
|
android:id="@+id/treatments_wizard_total"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/background_darkgray"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:text="2.35U 28g"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/mdtp_done_button" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginTop="-20dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
|
@ -589,45 +486,5 @@
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:width="32dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:width="80dp"
|
|
||||||
android:height="30dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:text="@string/treatments_wizard_total_label"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="@color/accent_material_light"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/treatments_wizard_total"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:width="100dp"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/treatments_wizard_totalinsulin"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:width="50dp"
|
|
||||||
android:gravity="center_vertical|end"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:textColor="@color/accent_material_light"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
Loading…
Reference in a new issue