careportal dialog number picker

This commit is contained in:
Milos Kozak 2017-06-29 01:37:58 +02:00
parent f58f70bdca
commit a8338b2dd1
10 changed files with 357 additions and 799 deletions

View file

@ -169,14 +169,14 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch; final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(manager, "NewNSTreatmentDialog"); newDialog.show(manager, "NewNSTreatmentDialog");
break; break;
case R.id.actions_temptarget: case R.id.actions_temptarget:
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
final OptionsToShow temptarget = CareportalFragment.temptarget; final OptionsToShow temptarget = CareportalFragment.temptarget;
temptarget.executeTempTarget = true; temptarget.executeTempTarget = true;
newTTDialog.setOptions(temptarget); newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
newTTDialog.show(manager, "NewNSTreatmentDialog"); newTTDialog.show(manager, "NewNSTreatmentDialog");
break; break;
case R.id.actions_extendedbolus: case R.id.actions_extendedbolus:

View file

@ -100,66 +100,66 @@ public class CareportalFragment extends Fragment implements View.OnClickListener
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
switch (id) { switch (id) {
case R.id.careportal_bgcheck: case R.id.careportal_bgcheck:
newDialog.setOptions(bgcheck); newDialog.setOptions(bgcheck, R.string.careportal_bgcheck);
break; break;
case R.id.careportal_announcement: case R.id.careportal_announcement:
newDialog.setOptions(announcement); newDialog.setOptions(announcement, R.string.careportal_announcement);
break; break;
case R.id.careportal_cgmsensorinsert: case R.id.careportal_cgmsensorinsert:
newDialog.setOptions(sensorchange); newDialog.setOptions(sensorchange, R.string.careportal_cgmsensorinsert);
break; break;
case R.id.careportal_cgmsensorstart: case R.id.careportal_cgmsensorstart:
newDialog.setOptions(sensorstart); newDialog.setOptions(sensorstart, R.string.careportal_cgmsensorstart);
break; break;
case R.id.careportal_combobolus: case R.id.careportal_combobolus:
newDialog.setOptions(combobolus); newDialog.setOptions(combobolus, R.string.careportal_combobolus);
break; break;
case R.id.careportal_correctionbolus: case R.id.careportal_correctionbolus:
newDialog.setOptions(correctionbolus); newDialog.setOptions(correctionbolus, R.string.careportal_correctionbolus);
break; break;
case R.id.careportal_carbscorrection: case R.id.careportal_carbscorrection:
newDialog.setOptions(carbcorrection); newDialog.setOptions(carbcorrection, R.string.careportal_carbscorrection);
break; break;
case R.id.careportal_exercise: case R.id.careportal_exercise:
newDialog.setOptions(exercise); newDialog.setOptions(exercise, R.string.careportal_exercise);
break; break;
case R.id.careportal_insulincartridgechange: case R.id.careportal_insulincartridgechange:
newDialog.setOptions(insulinchange); newDialog.setOptions(insulinchange, R.string.careportal_insulincartridgechange);
break; break;
case R.id.careportal_pumpbatterychange: case R.id.careportal_pumpbatterychange:
newDialog.setOptions(pumpbatterychange); newDialog.setOptions(pumpbatterychange, R.string.careportal_pumpbatterychange);
break; break;
case R.id.careportal_mealbolus: case R.id.careportal_mealbolus:
newDialog.setOptions(mealbolus); newDialog.setOptions(mealbolus, R.string.careportal_mealbolus);
break; break;
case R.id.careportal_note: case R.id.careportal_note:
newDialog.setOptions(note); newDialog.setOptions(note, R.string.careportal_note);
break; break;
case R.id.careportal_profileswitch: case R.id.careportal_profileswitch:
profileswitch.executeProfileSwitch = false; profileswitch.executeProfileSwitch = false;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
break; break;
case R.id.careportal_pumpsitechange: case R.id.careportal_pumpsitechange:
newDialog.setOptions(sitechange); newDialog.setOptions(sitechange, R.string.careportal_pumpsitechange);
break; break;
case R.id.careportal_question: case R.id.careportal_question:
newDialog.setOptions(question); newDialog.setOptions(question, R.string.careportal_question);
break; break;
case R.id.careportal_snackbolus: case R.id.careportal_snackbolus:
newDialog.setOptions(snackbolus); newDialog.setOptions(snackbolus, R.string.careportal_snackbolus);
break; break;
case R.id.careportal_tempbasalstart: case R.id.careportal_tempbasalstart:
newDialog.setOptions(tempbasalstart); newDialog.setOptions(tempbasalstart, R.string.careportal_tempbasalstart);
break; break;
case R.id.careportal_tempbasalend: case R.id.careportal_tempbasalend:
newDialog.setOptions(tempbasalend); newDialog.setOptions(tempbasalend, R.string.careportal_tempbasalend);
break; break;
case R.id.careportal_openapsoffline: case R.id.careportal_openapsoffline:
newDialog.setOptions(openapsoffline); newDialog.setOptions(openapsoffline, R.string.careportal_openapsoffline);
break; break;
case R.id.careportal_temporarytarget: case R.id.careportal_temporarytarget:
temptarget.executeTempTarget = false; temptarget.executeTempTarget = false;
newDialog.setOptions(temptarget); newDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
break; break;
default: default:
newDialog = null; newDialog = null;

View file

@ -15,12 +15,10 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -44,6 +42,8 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; 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.CareportalEvent;
import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.db.Source; 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.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow; import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; 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.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.utils.PlusMinusEditText; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
import info.nightscout.utils.Translator; import info.nightscout.utils.Translator;
@ -68,53 +66,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
private Activity context; private Activity context;
private static OptionsToShow options; private static OptionsToShow options;
private static String event;
Profile profile; Profile profile;
ProfileStore profileStore; ProfileStore profileStore;
String units; String units;
RelativeLayout layoutBg; TextView eventTypeText;
LinearLayout layoutBg;
LinearLayout layoutBgSource; LinearLayout layoutBgSource;
RelativeLayout layoutInsulin; LinearLayout layoutInsulin;
RelativeLayout layoutCarbs; LinearLayout layoutCarbs;
RelativeLayout layoutSplit; LinearLayout layoutSplit;
RelativeLayout layoutDuration; LinearLayout layoutDuration;
RelativeLayout layoutPercent; LinearLayout layoutPercent;
RelativeLayout layoutAbsolute; LinearLayout layoutAbsolute;
RelativeLayout layoutCarbTime; LinearLayout layoutCarbTime;
RelativeLayout layoutProfile; LinearLayout layoutProfile;
LinearLayout layoutTempTarget; LinearLayout layoutTempTarget;
Button dateButton; TextView dateButton;
Button timeButton; TextView timeButton;
Button okButton;
Button cancelButton;
TextView bgUnitsView; TextView bgUnitsView;
RadioButton meterRadioButton; RadioButton meterRadioButton;
RadioButton sensorRadioButton; RadioButton sensorRadioButton;
RadioButton otherRadioButton; RadioButton otherRadioButton;
EditText notesEdit; EditText notesEdit;
EditText bgInputEdit;
EditText insulinEdit;
EditText carbsEdit;
EditText percentEdit;
EditText absoluteEdit;
EditText durationeEdit;
EditText carbTimeEdit;
EditText splitEdit;
Spinner profileSpinner; Spinner profileSpinner;
EditText low;
EditText high;
Spinner reasonSpinner; Spinner reasonSpinner;
PlusMinusEditText editBg; NumberPicker editBg;
PlusMinusEditText editCarbs; NumberPicker editCarbs;
PlusMinusEditText editInsulin; NumberPicker editInsulin;
PlusMinusEditText editSplit; NumberPicker editSplit;
PlusMinusEditText editDuration; NumberPicker editDuration;
PlusMinusEditText editPercent; NumberPicker editPercent;
PlusMinusEditText editAbsolute; NumberPicker editAbsolute;
PlusMinusEditText editCarbTime; NumberPicker editCarbTime;
NumberPicker editTemptarget;
Date eventTime; Date eventTime;
@ -122,8 +111,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
private static HandlerThread sHandlerThread; private static HandlerThread sHandlerThread;
public void setOptions(OptionsToShow options) { public void setOptions(OptionsToShow options, int event) {
this.options = options; this.options = options;
this.event = MainApp.sResources.getString(event);
} }
public NewNSTreatmentDialog() { public NewNSTreatmentDialog() {
@ -154,88 +144,44 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
setStyle(DialogFragment.STYLE_NORMAL, getTheme()); setStyle(DialogFragment.STYLE_NORMAL, getTheme());
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false); 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); layoutBgSource = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout);
layoutInsulin = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout); layoutInsulin = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_insulin_layout);
layoutCarbs = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout); layoutCarbs = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbs_layout);
layoutSplit = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout); layoutSplit = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_split_layout);
layoutDuration = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout); layoutDuration = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_duration_layout);
layoutPercent = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout); layoutPercent = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_percent_layout);
layoutAbsolute = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout); layoutAbsolute = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_absolute_layout);
layoutCarbTime = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout); layoutCarbTime = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout);
layoutProfile = (RelativeLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout); layoutProfile = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_profile_layout);
layoutTempTarget = (LinearLayout) view.findViewById(R.id.careportal_newnstreatment_temptarget_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); bgUnitsView = (TextView) view.findViewById(R.id.careportal_newnstreatment_bgunits);
meterRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_meter); meterRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_meter);
sensorRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_sensor); sensorRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_sensor);
otherRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_other); otherRadioButton = (RadioButton) view.findViewById(R.id.careportal_newnstreatment_other);
profileSpinner = (Spinner) view.findViewById(R.id.careportal_newnstreatment_profile); 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); 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); 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(); eventTime = new Date();
dateButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventdate); dateButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventdate);
timeButton = (Button) view.findViewById(R.id.careportal_newnstreatment_eventtime); timeButton = (TextView) view.findViewById(R.id.careportal_newnstreatment_eventtime);
dateButton.setText(DateUtil.dateString(eventTime)); dateButton.setText(DateUtil.dateString(eventTime));
timeButton.setText(DateUtil.timeString(eventTime)); timeButton.setText(DateUtil.timeString(eventTime));
dateButton.setOnClickListener(this); dateButton.setOnClickListener(this);
timeButton.setOnClickListener(this); timeButton.setOnClickListener(this);
okButton = (Button) view.findViewById(R.id.ok); view.findViewById(R.id.ok).setOnClickListener(this);
okButton.setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this);
cancelButton = (Button) view.findViewById(R.id.cancel);
cancelButton.setOnClickListener(this);
// profile // profile
profile = MainApp.getConfigBuilder().getProfile(); profile = MainApp.getConfigBuilder().getProfile();
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile(); profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
ArrayList<CharSequence> profileList; ArrayList<CharSequence> profileList;
units = profile.getUnits(); units = profile.getUnits();
profileList = profileStore.getProfileList(); profileList = profileStore.getProfileList();
@ -260,25 +206,20 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
// bg // bg
bgUnitsView.setText(units); 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); Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
if (profile == null) editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
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); editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
else if (profile.getUnits().equals(Constants.MMOL)) 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, 30d, 0.1d, new DecimalFormat("0.0"), false); editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
else editTemptarget.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false);
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); } else if (profile.getUnits().equals(Constants.MMOL)) {
bgInputEdit.addTextChangedListener(new TextWatcher() { 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) { public void afterTextChanged(Editable s) {
} }
@ -289,6 +230,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true); if (sensorRadioButton.isChecked()) meterRadioButton.setChecked(true);
} }
}); });
sensorRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { sensorRadioButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 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); 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); 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); editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
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.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); 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); 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(layoutBg, options.bg);
showOrHide(layoutBgSource, options.bg); showOrHide(layoutBgSource, options.bg);
@ -329,13 +313,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
return view; return view;
} }
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@ -353,7 +330,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
dpd.show(context.getFragmentManager(), "Datepickerdialog"); dpd.show(context.getFragmentManager(), "Datepickerdialog");
break; break;
case R.id.careportal_newnstreatment_eventtime: case R.id.careportal_newnstreatment_eventtime:
android.text.format.DateFormat df = new android.text.format.DateFormat();
TimePickerDialog tpd = TimePickerDialog.newInstance( TimePickerDialog tpd = TimePickerDialog.newInstance(
this, this,
calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.HOUR_OF_DAY),
@ -417,8 +393,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
data.put("eventType", "Sensor Start"); data.put("eventType", "Sensor Start");
break; break;
case R.id.careportal_combobolus: case R.id.careportal_combobolus:
data.put("splitNow", SafeParse.stringToDouble(splitEdit.getText().toString())); data.put("splitNow", SafeParse.stringToDouble(editSplit.getText()));
data.put("splitExt", 100 - SafeParse.stringToDouble(splitEdit.getText().toString())); data.put("splitExt", 100 - SafeParse.stringToDouble(editSplit.getText()));
data.put("eventType", CareportalEvent.COMBOBOLUS); data.put("eventType", CareportalEvent.COMBOBOLUS);
break; break;
case R.id.careportal_correctionbolus: case R.id.careportal_correctionbolus:
@ -468,42 +444,42 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
data.put("eventType", CareportalEvent.TEMPORARYTARGET); data.put("eventType", CareportalEvent.TEMPORARYTARGET);
if (!reasonSpinner.getSelectedItem().toString().equals("")) if (!reasonSpinner.getSelectedItem().toString().equals(""))
data.put("reason", reasonSpinner.getSelectedItem().toString()); data.put("reason", reasonSpinner.getSelectedItem().toString());
if (SafeParse.stringToDouble(low.getText().toString()) != 0d) if (SafeParse.stringToDouble(editTemptarget.getText()) != 0d) {
data.put("targetBottom", SafeParse.stringToDouble(low.getText().toString())); data.put("targetBottom", SafeParse.stringToDouble(editTemptarget.getText()));
if (SafeParse.stringToDouble(high.getText().toString()) != 0d) data.put("targetTop", SafeParse.stringToDouble(editTemptarget.getText()));
data.put("targetTop", SafeParse.stringToDouble(high.getText().toString())); }
allowZeroDuration = true; allowZeroDuration = true;
break; break;
} }
if (SafeParse.stringToDouble(bgInputEdit.getText().toString()) != 0d) { if (SafeParse.stringToDouble(editBg.getText()) != 0d) {
data.put("glucose", SafeParse.stringToDouble(bgInputEdit.getText().toString())); data.put("glucose", SafeParse.stringToDouble(editBg.getText()));
if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger"); if (meterRadioButton.isChecked()) data.put("glucoseType", "Finger");
if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor"); if (sensorRadioButton.isChecked()) data.put("glucoseType", "Sensor");
if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual"); if (otherRadioButton.isChecked()) data.put("glucoseType", "Manual");
} }
if (SafeParse.stringToDouble(carbsEdit.getText().toString()) != 0d) if (SafeParse.stringToDouble(editCarbs.getText()) != 0d)
data.put("carbs", SafeParse.stringToDouble(carbsEdit.getText().toString())); data.put("carbs", SafeParse.stringToDouble(editCarbs.getText()));
if (SafeParse.stringToDouble(insulinEdit.getText().toString()) != 0d) if (SafeParse.stringToDouble(editInsulin.getText()) != 0d)
data.put("insulin", SafeParse.stringToDouble(insulinEdit.getText().toString())); data.put("insulin", SafeParse.stringToDouble(editInsulin.getText()));
if (allowZeroDuration || SafeParse.stringToDouble(durationeEdit.getText().toString()) != 0d) if (allowZeroDuration || SafeParse.stringToDouble(editDuration.getText()) != 0d)
data.put("duration", SafeParse.stringToDouble(durationeEdit.getText().toString())); data.put("duration", SafeParse.stringToDouble(editDuration.getText()));
if (layoutPercent.getVisibility() != View.GONE) 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) 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) if (options.profile && profileSpinner.getSelectedItem() != null)
data.put("profile", profileSpinner.getSelectedItem().toString()); data.put("profile", profileSpinner.getSelectedItem().toString());
if (SafeParse.stringToDouble(carbTimeEdit.getText().toString()) != 0d) if (SafeParse.stringToDouble(editCarbTime.getText()) != 0d)
data.put("preBolus", SafeParse.stringToDouble(carbTimeEdit.getText().toString())); data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
if (!notesEdit.getText().toString().equals("")) if (!notesEdit.getText().toString().equals(""))
data.put("notes", notesEdit.getText().toString()); data.put("notes", notesEdit.getText().toString());
data.put("units", units); data.put("units", units);
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy); if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
if (options.eventType == R.id.careportal_combobolus) { 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("enteredinsulin", enteredInsulin);
data.put("insulin", enteredInsulin * SafeParse.stringToDouble(splitEdit.getText().toString()) / 100); data.put("insulin", enteredInsulin * SafeParse.stringToDouble(editInsulin.getText()) / 100);
data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(splitEdit.getText().toString())) / 100 / SafeParse.stringToDouble(durationeEdit.getText().toString()) * 60); data.put("relative", enteredInsulin * (100 - SafeParse.stringToDouble(editSplit.getText())) / 100 / SafeParse.stringToDouble(editDuration.getText()) * 60);
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();

View file

@ -1038,7 +1038,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch; final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
return true; return true;
} }
@ -1053,7 +1053,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
final OptionsToShow temptarget = CareportalFragment.temptarget; final OptionsToShow temptarget = CareportalFragment.temptarget;
temptarget.executeTempTarget = true; temptarget.executeTempTarget = true;
newTTDialog.setOptions(temptarget); newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
return true; return true;
} }

View file

@ -143,7 +143,7 @@ public class CircadianPercentageProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch; final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
} }
}); });

View file

@ -104,7 +104,7 @@ public class LocalProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch; final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
} }
}); });

View file

@ -102,7 +102,7 @@ public class SimpleProfileFragment extends Fragment {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog(); NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch; final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true; profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch); newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog"); newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
} }
}); });

File diff suppressed because it is too large Load diff

View file

@ -9,17 +9,13 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:padding="10dp"> android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -50,6 +46,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>

View file

@ -11,7 +11,6 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout