careportal dialog number picker
This commit is contained in:
parent
f58f70bdca
commit
a8338b2dd1
|
@ -169,14 +169,14 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(manager, "NewNSTreatmentDialog");
|
||||
break;
|
||||
case R.id.actions_temptarget:
|
||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow temptarget = CareportalFragment.temptarget;
|
||||
temptarget.executeTempTarget = true;
|
||||
newTTDialog.setOptions(temptarget);
|
||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
newTTDialog.show(manager, "NewNSTreatmentDialog");
|
||||
break;
|
||||
case R.id.actions_extendedbolus:
|
||||
|
|
|
@ -100,66 +100,66 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
switch (id) {
|
||||
case R.id.careportal_bgcheck:
|
||||
newDialog.setOptions(bgcheck);
|
||||
newDialog.setOptions(bgcheck, R.string.careportal_bgcheck);
|
||||
break;
|
||||
case R.id.careportal_announcement:
|
||||
newDialog.setOptions(announcement);
|
||||
newDialog.setOptions(announcement, R.string.careportal_announcement);
|
||||
break;
|
||||
case R.id.careportal_cgmsensorinsert:
|
||||
newDialog.setOptions(sensorchange);
|
||||
newDialog.setOptions(sensorchange, R.string.careportal_cgmsensorinsert);
|
||||
break;
|
||||
case R.id.careportal_cgmsensorstart:
|
||||
newDialog.setOptions(sensorstart);
|
||||
newDialog.setOptions(sensorstart, R.string.careportal_cgmsensorstart);
|
||||
break;
|
||||
case R.id.careportal_combobolus:
|
||||
newDialog.setOptions(combobolus);
|
||||
newDialog.setOptions(combobolus, R.string.careportal_combobolus);
|
||||
break;
|
||||
case R.id.careportal_correctionbolus:
|
||||
newDialog.setOptions(correctionbolus);
|
||||
newDialog.setOptions(correctionbolus, R.string.careportal_correctionbolus);
|
||||
break;
|
||||
case R.id.careportal_carbscorrection:
|
||||
newDialog.setOptions(carbcorrection);
|
||||
newDialog.setOptions(carbcorrection, R.string.careportal_carbscorrection);
|
||||
break;
|
||||
case R.id.careportal_exercise:
|
||||
newDialog.setOptions(exercise);
|
||||
newDialog.setOptions(exercise, R.string.careportal_exercise);
|
||||
break;
|
||||
case R.id.careportal_insulincartridgechange:
|
||||
newDialog.setOptions(insulinchange);
|
||||
newDialog.setOptions(insulinchange, R.string.careportal_insulincartridgechange);
|
||||
break;
|
||||
case R.id.careportal_pumpbatterychange:
|
||||
newDialog.setOptions(pumpbatterychange);
|
||||
newDialog.setOptions(pumpbatterychange, R.string.careportal_pumpbatterychange);
|
||||
break;
|
||||
case R.id.careportal_mealbolus:
|
||||
newDialog.setOptions(mealbolus);
|
||||
newDialog.setOptions(mealbolus, R.string.careportal_mealbolus);
|
||||
break;
|
||||
case R.id.careportal_note:
|
||||
newDialog.setOptions(note);
|
||||
newDialog.setOptions(note, R.string.careportal_note);
|
||||
break;
|
||||
case R.id.careportal_profileswitch:
|
||||
profileswitch.executeProfileSwitch = false;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
break;
|
||||
case R.id.careportal_pumpsitechange:
|
||||
newDialog.setOptions(sitechange);
|
||||
newDialog.setOptions(sitechange, R.string.careportal_pumpsitechange);
|
||||
break;
|
||||
case R.id.careportal_question:
|
||||
newDialog.setOptions(question);
|
||||
newDialog.setOptions(question, R.string.careportal_question);
|
||||
break;
|
||||
case R.id.careportal_snackbolus:
|
||||
newDialog.setOptions(snackbolus);
|
||||
newDialog.setOptions(snackbolus, R.string.careportal_snackbolus);
|
||||
break;
|
||||
case R.id.careportal_tempbasalstart:
|
||||
newDialog.setOptions(tempbasalstart);
|
||||
newDialog.setOptions(tempbasalstart, R.string.careportal_tempbasalstart);
|
||||
break;
|
||||
case R.id.careportal_tempbasalend:
|
||||
newDialog.setOptions(tempbasalend);
|
||||
newDialog.setOptions(tempbasalend, R.string.careportal_tempbasalend);
|
||||
break;
|
||||
case R.id.careportal_openapsoffline:
|
||||
newDialog.setOptions(openapsoffline);
|
||||
newDialog.setOptions(openapsoffline, R.string.careportal_openapsoffline);
|
||||
break;
|
||||
case R.id.careportal_temporarytarget:
|
||||
temptarget.executeTempTarget = false;
|
||||
newDialog.setOptions(temptarget);
|
||||
newDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
break;
|
||||
default:
|
||||
newDialog = null;
|
||||
|
|
|
@ -15,12 +15,10 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -44,6 +42,8 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
|
@ -52,12 +52,10 @@ import info.nightscout.androidaps.events.EventNewBasalProfile;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.PlusMinusEditText;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.Translator;
|
||||
|
@ -68,53 +66,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
private Activity context;
|
||||
|
||||
private static OptionsToShow options;
|
||||
private static String event;
|
||||
|
||||
Profile profile;
|
||||
ProfileStore profileStore;
|
||||
String units;
|
||||
|
||||
RelativeLayout layoutBg;
|
||||
TextView eventTypeText;
|
||||
LinearLayout layoutBg;
|
||||
LinearLayout layoutBgSource;
|
||||
RelativeLayout layoutInsulin;
|
||||
RelativeLayout layoutCarbs;
|
||||
RelativeLayout layoutSplit;
|
||||
RelativeLayout layoutDuration;
|
||||
RelativeLayout layoutPercent;
|
||||
RelativeLayout layoutAbsolute;
|
||||
RelativeLayout layoutCarbTime;
|
||||
RelativeLayout layoutProfile;
|
||||
LinearLayout layoutInsulin;
|
||||
LinearLayout layoutCarbs;
|
||||
LinearLayout layoutSplit;
|
||||
LinearLayout layoutDuration;
|
||||
LinearLayout layoutPercent;
|
||||
LinearLayout layoutAbsolute;
|
||||
LinearLayout layoutCarbTime;
|
||||
LinearLayout layoutProfile;
|
||||
LinearLayout layoutTempTarget;
|
||||
Button dateButton;
|
||||
Button timeButton;
|
||||
Button okButton;
|
||||
Button cancelButton;
|
||||
TextView dateButton;
|
||||
TextView timeButton;
|
||||
|
||||
TextView bgUnitsView;
|
||||
RadioButton meterRadioButton;
|
||||
RadioButton sensorRadioButton;
|
||||
RadioButton otherRadioButton;
|
||||
EditText notesEdit;
|
||||
EditText bgInputEdit;
|
||||
EditText insulinEdit;
|
||||
EditText carbsEdit;
|
||||
EditText percentEdit;
|
||||
EditText absoluteEdit;
|
||||
EditText durationeEdit;
|
||||
EditText carbTimeEdit;
|
||||
EditText splitEdit;
|
||||
Spinner profileSpinner;
|
||||
EditText low;
|
||||
EditText high;
|
||||
Spinner reasonSpinner;
|
||||
|
||||
PlusMinusEditText editBg;
|
||||
PlusMinusEditText editCarbs;
|
||||
PlusMinusEditText editInsulin;
|
||||
PlusMinusEditText editSplit;
|
||||
PlusMinusEditText editDuration;
|
||||
PlusMinusEditText editPercent;
|
||||
PlusMinusEditText editAbsolute;
|
||||
PlusMinusEditText editCarbTime;
|
||||
NumberPicker editBg;
|
||||
NumberPicker editCarbs;
|
||||
NumberPicker editInsulin;
|
||||
NumberPicker editSplit;
|
||||
NumberPicker editDuration;
|
||||
NumberPicker editPercent;
|
||||
NumberPicker editAbsolute;
|
||||
NumberPicker editCarbTime;
|
||||
NumberPicker editTemptarget;
|
||||
|
||||
Date eventTime;
|
||||
|
||||
|
@ -122,8 +111,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
private static HandlerThread sHandlerThread;
|
||||
|
||||
|
||||
public void setOptions(OptionsToShow options) {
|
||||
public void setOptions(OptionsToShow options, int event) {
|
||||
this.options = options;
|
||||
this.event = MainApp.sResources.getString(event);
|
||||
}
|
||||
|
||||
public NewNSTreatmentDialog() {
|
||||
|
@ -154,88 +144,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
||||
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
||||
|
||||
layoutBg = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
|
||||
layoutBg = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bg_layout);
|
||||
layoutBgSource = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout);
|
||||
layoutInsulin = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
|
||||
layoutCarbs = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
|
||||
layoutSplit = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
|
||||
layoutDuration = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
|
||||
layoutPercent = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
||||
layoutAbsolute = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
||||
layoutCarbTime = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
|
||||
layoutProfile = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
|
||||
layoutInsulin = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
|
||||
layoutCarbs = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
|
||||
layoutSplit = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
|
||||
layoutDuration = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
|
||||
layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
|
||||
layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
|
||||
layoutCarbTime = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
|
||||
layoutProfile = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
|
||||
layoutTempTarget = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout);
|
||||
|
||||
eventTypeText = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtype);
|
||||
eventTypeText.setText(event);
|
||||
bgUnitsView = (TextView) view.findViewById(R.id.careportal_newnstreatment_bgunits);
|
||||
meterRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_meter);
|
||||
sensorRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_sensor);
|
||||
otherRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_other);
|
||||
profileSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_profile);
|
||||
|
||||
bgInputEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||
insulinEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||
carbsEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||
percentEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||
percentEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.VISIBLE);
|
||||
layoutAbsolute.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
absoluteEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||
absoluteEdit.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.GONE);
|
||||
layoutAbsolute.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
durationeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||
carbTimeEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||
notesEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_notes);
|
||||
splitEdit = (EditText) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||
|
||||
reasonSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_temptarget_reason);
|
||||
low = (EditText) view.findViewById(R.id.careportal_temptarget_low);
|
||||
high = (EditText) view.findViewById(R.id.careportal_temptarget_high);
|
||||
|
||||
eventTime = new Date();
|
||||
dateButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
||||
timeButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
||||
dateButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventdate);
|
||||
timeButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtime);
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
dateButton.setOnClickListener(this);
|
||||
timeButton.setOnClickListener(this);
|
||||
|
||||
okButton = (Button) view.findViewById(R.id.ok);
|
||||
okButton.setOnClickListener(this);
|
||||
cancelButton = (Button) view.findViewById(R.id.cancel);
|
||||
cancelButton.setOnClickListener(this);
|
||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||
|
||||
// profile
|
||||
profile = MainApp.getConfigBuilder().getProfile();
|
||||
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||
profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||
ArrayList<CharSequence> profileList;
|
||||
units = profile.getUnits();
|
||||
profileList = profileStore.getProfileList();
|
||||
|
@ -260,25 +206,20 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
// bg
|
||||
bgUnitsView.setText(units);
|
||||
|
||||
// Set BG if not old
|
||||
// BgReading lastBg = MainApp.getDbHelper().lastBg();
|
||||
// Double lastBgValue = 0d;
|
||||
// if (lastBg != null) {
|
||||
// lastBgValue = lastBg.valueToUnits(units);
|
||||
// sensorRadioButton.setChecked(true);
|
||||
// } else {
|
||||
// meterRadioButton.setChecked(true);
|
||||
// }
|
||||
|
||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
||||
if (profile == null)
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
else if (profile.getUnits().equals(Constants.MMOL))
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
else
|
||||
editBg = new PlusMinusEditText(view, R.id.careportal_newnstreatment_bginput, R.id.careportal_newnstreatment_bg_plus, R.id.careportal_newnstreatment_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
bgInputEdit.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
|
||||
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
|
||||
if (profile == null) {
|
||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else if (profile.getUnits().equals(Constants.MMOL)) {
|
||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||
} else {
|
||||
editBg.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
editTemptarget.setParams(bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||
}
|
||||
editBg.addTextChangedListener(new TextWatcher() {
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
|
@ -289,6 +230,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
||||
sensorRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
|
@ -298,21 +240,63 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
});
|
||||
|
||||
Integer maxCarbs = MainApp.getConfigBuilder().applyCarbsConstraints(Constants.carbsOnlyForCheckLimit);
|
||||
editCarbs = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbsinput, R.id.careportal_newnstreatment_carbs_plus, R.id.careportal_newnstreatment_carbs_minus, 0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
|
||||
editInsulin = new PlusMinusEditText(view, R.id.careportal_newnstreatment_insulininput, R.id.careportal_newnstreatment_insulin_plus, R.id.careportal_newnstreatment_insulin_minus, 0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
||||
|
||||
editSplit = new PlusMinusEditText(view, R.id.careportal_newnstreatment_splitinput, R.id.careportal_newnstreatment_split_plus, R.id.careportal_newnstreatment_split_minus, 100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
|
||||
editDuration = new PlusMinusEditText(view, R.id.careportal_newnstreatment_durationinput, R.id.careportal_newnstreatment_duration_plus, R.id.careportal_newnstreatment_duration_minus, 0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
|
||||
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true);
|
||||
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||
editDuration.setParams(0d, 0d, 24 * 60d, 10d, new DecimalFormat("0"), false);
|
||||
|
||||
Integer maxPercent = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalPercentOnlyForCheckLimit);
|
||||
editPercent = new PlusMinusEditText(view, R.id.careportal_newnstreatment_percentinput, R.id.careportal_newnstreatment_percent_plus, R.id.careportal_newnstreatment_percent_minus, 0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
|
||||
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||
editPercent.setParams(0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true);
|
||||
editPercent.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.VISIBLE);
|
||||
layoutAbsolute.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
Double maxAbsolute = MainApp.getConfigBuilder().applyBasalConstraints(Constants.basalAbsoluteOnlyForCheckLimit);
|
||||
editAbsolute = new PlusMinusEditText(view, R.id.careportal_newnstreatment_absoluteinput, R.id.careportal_newnstreatment_absolute_plus, R.id.careportal_newnstreatment_absolute_minus, 0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
|
||||
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true);
|
||||
editAbsolute.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start,
|
||||
int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start,
|
||||
int before, int count) {
|
||||
layoutPercent.setVisibility(View.GONE);
|
||||
layoutAbsolute.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
|
||||
editCarbTime = new PlusMinusEditText(view, R.id.careportal_newnstreatment_carbtimeinput, R.id.careportal_newnstreatment_carbtime_plus, R.id.careportal_newnstreatment_carbtime_minus, 0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
|
||||
showOrHide(layoutBg, options.bg);
|
||||
showOrHide(layoutBgSource, options.bg);
|
||||
|
@ -329,13 +313,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (getDialog() != null)
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
@ -353,7 +330,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
dpd.show(context.getFragmentManager(), "Datepickerdialog");
|
||||
break;
|
||||
case R.id.careportal_newnstreatment_eventtime:
|
||||
android.text.format.DateFormat df = new android.text.format.DateFormat();
|
||||
TimePickerDialog tpd = TimePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.HOUR_OF_DAY),
|
||||
|
@ -417,8 +393,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
data.put("eventType", "Sensor Start");
|
||||
break;
|
||||
case R.id.careportal_combobolus:
|
||||
data.put("splitNow", SafeParse.stringToDouble(splitEdit.getText().toString()));
|
||||
data.put("splitExt", 100 - SafeParse.stringToDouble(splitEdit.getText().toString()));
|
||||
data.put("splitNow", SafeParse.stringToDouble(editSplit.getText()));
|
||||
data.put("splitExt", 100 - SafeParse.stringToDouble(editSplit.getText()));
|
||||
data.put("eventType", CareportalEvent.COMBOBOLUS);
|
||||
break;
|
||||
case R.id.careportal_correctionbolus:
|
||||
|
@ -468,42 +444,42 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
||||
if (!reasonSpinner.getSelectedItem().toString().equals(""))
|
||||
data.put("reason", reasonSpinner.getSelectedItem().toString());
|
||||
if (SafeParse.stringToDouble(low.getText().toString()) != 0d)
|
||||
data.put("targetBottom", SafeParse.stringToDouble(low.getText().toString()));
|
||||
if (SafeParse.stringToDouble(high.getText().toString()) != 0d)
|
||||
data.put("targetTop", SafeParse.stringToDouble(high.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editTemptarget.getText()) != 0d) {
|
||||
data.put("targetBottom", SafeParse.stringToDouble(editTemptarget.getText()));
|
||||
data.put("targetTop", SafeParse.stringToDouble(editTemptarget.getText()));
|
||||
}
|
||||
allowZeroDuration = true;
|
||||
break;
|
||||
}
|
||||
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) {
|
||||
data.put("glucose", SafeParse.stringToDouble(bgInputEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editBg.getText()) != 0d) {
|
||||
data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
|
||||
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
|
||||
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
|
||||
if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual");
|
||||
}
|
||||
if (SafeParse.stringToDouble(carbsEdit.getText().toString()) != 0d)
|
||||
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d)
|
||||
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString()));
|
||||
if (allowZeroDuration || SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d)
|
||||
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editCarbs.getText()) != 0d)
|
||||
data.put("carbs", SafeParse.stringToDouble(editCarbs.getText()));
|
||||
if (SafeParse.stringToDouble(editInsulin.getText()) != 0d)
|
||||
data.put("insulin", SafeParse.stringToDouble(editInsulin.getText()));
|
||||
if (allowZeroDuration || SafeParse.stringToDouble(editDuration.getText()) != 0d)
|
||||
data.put("duration", SafeParse.stringToDouble(editDuration.getText()));
|
||||
if (layoutPercent.getVisibility() != View.GONE)
|
||||
data.put("percent", SafeParse.stringToDouble(percentEdit.getText().toString()));
|
||||
data.put("percent", SafeParse.stringToDouble(editPercent.getText()));
|
||||
if (layoutAbsolute.getVisibility() != View.GONE)
|
||||
data.put("absolute", SafeParse.stringToDouble(absoluteEdit.getText().toString()));
|
||||
data.put("absolute", SafeParse.stringToDouble(editAbsolute.getText()));
|
||||
if (options.profile && profileSpinner.getSelectedItem() != null)
|
||||
data.put("profile", profileSpinner.getSelectedItem().toString());
|
||||
if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d)
|
||||
data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString()));
|
||||
if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
|
||||
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
||||
if (!notesEdit.getText().toString().equals(""))
|
||||
data.put("notes", notesEdit.getText().toString());
|
||||
data.put("units", units);
|
||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
if (options.eventType == R.id.careportal_combobolus) {
|
||||
Double enteredInsulin = SafeParse.stringToDouble(insulinEdit.getText().toString());
|
||||
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
data.put("enteredinsulin", enteredInsulin);
|
||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(splitEdit.getText().toString()) / 100);
|
||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(splitEdit.getText().toString())) / 100 / SafeParse.stringToDouble(durationeEdit.getText().toString()) * 60);
|
||||
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100);
|
||||
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -1038,7 +1038,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
return true;
|
||||
}
|
||||
|
@ -1053,7 +1053,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow temptarget = CareportalFragment.temptarget;
|
||||
temptarget.executeTempTarget = true;
|
||||
newTTDialog.setOptions(temptarget);
|
||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
||||
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@ public class LocalProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -102,7 +102,7 @@ public class SimpleProfileFragment extends Fragment {
|
|||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
|
||||
profileswitch.executeProfileSwitch = true;
|
||||
newDialog.setOptions(profileswitch);
|
||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,47 +9,43 @@
|
|||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="@string/overview_calibration_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="10dp"
|
||||
android:text="@string/overview_calibration_bg_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
<TextView
|
||||
android:id="@+id/overview_calibration_units"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_calibration_units"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp" />
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/overview_calibration_bg"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp" />
|
||||
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -11,7 +11,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
|
Loading…
Reference in a new issue