commit
dfa05711d3
|
@ -666,8 +666,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
TempTarget tempTarget = new TempTarget()
|
||||
.date(trJson.getLong("mills"))
|
||||
.duration(trJson.getInt("duration"))
|
||||
.low(Profile.toMgdl(trJson.getDouble("targetBottom"), units))
|
||||
.high(Profile.toMgdl(trJson.getDouble("targetTop"), units))
|
||||
.low(trJson.getDouble("targetBottom"))
|
||||
.high(trJson.getDouble("targetTop"))
|
||||
.reason(trJson.getString("reason"))
|
||||
._id(trJson.getString("_id"))
|
||||
.source(Source.NIGHTSCOUT);
|
||||
|
|
|
@ -5,7 +5,9 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -14,6 +16,8 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -21,8 +25,6 @@ import com.google.common.base.Joiner;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -41,19 +43,45 @@ import info.nightscout.utils.NSUpload;
|
|||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
import static info.nightscout.utils.DateUtil.now;
|
||||
|
||||
public class FillDialog extends DialogFragment implements OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(FillDialog.class);
|
||||
|
||||
private CheckBox pumpSiteChangeCheckbox;
|
||||
private CheckBox insulinCartridgeChangeCheckbox;
|
||||
|
||||
private NumberPicker editInsulin;
|
||||
|
||||
double amount1 = 0d;
|
||||
double amount2 = 0d;
|
||||
double amount3 = 0d;
|
||||
|
||||
NumberPicker editInsulin;
|
||||
CheckBox pumpSiteChangeCheckbox;
|
||||
CheckBox insulinCartridgeChangeCheckbox;
|
||||
private EditText notesEdit;
|
||||
|
||||
public FillDialog() {
|
||||
final private TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
validateInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
};
|
||||
|
||||
private void validateInputs() {
|
||||
int time = editInsulin.getValue().intValue();
|
||||
if (Math.abs(time) > 12 * 60) {
|
||||
editInsulin.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.constraintapllied));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,45 +95,47 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
pumpSiteChangeCheckbox = view.findViewById(R.id.catheter_change);
|
||||
insulinCartridgeChangeCheckbox = view.findViewById(R.id.cartridge_change);
|
||||
pumpSiteChangeCheckbox = view.findViewById(R.id.fill_catheter_change);
|
||||
insulinCartridgeChangeCheckbox = view.findViewById(R.id.fill_cartridge_change);
|
||||
|
||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
editInsulin = view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false);
|
||||
editInsulin = view.findViewById(R.id.fill_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
//setup preset buttons
|
||||
Button button1 = (Button) view.findViewById(R.id.fill_preset_button1);
|
||||
Button button2 = (Button) view.findViewById(R.id.fill_preset_button2);
|
||||
Button button3 = (Button) view.findViewById(R.id.fill_preset_button3);
|
||||
|
||||
Button preset1Button = view.findViewById(R.id.fill_preset_button1);
|
||||
amount1 = SP.getDouble("fill_button1", 0.3);
|
||||
amount2 = SP.getDouble("fill_button2", 0d);
|
||||
amount3 = SP.getDouble("fill_button3", 0d);
|
||||
|
||||
if (amount1 > 0) {
|
||||
button1.setVisibility(View.VISIBLE);
|
||||
button1.setText(DecimalFormatter.toPumpSupportedBolus(amount1)); // + "U");
|
||||
button1.setOnClickListener(this);
|
||||
preset1Button.setVisibility(View.VISIBLE);
|
||||
preset1Button.setText(DecimalFormatter.toPumpSupportedBolus(amount1)); // + "U");
|
||||
preset1Button.setOnClickListener(this);
|
||||
} else {
|
||||
button1.setVisibility(View.GONE);
|
||||
preset1Button.setVisibility(View.GONE);
|
||||
}
|
||||
Button preset2Button = view.findViewById(R.id.fill_preset_button2);
|
||||
amount2 = SP.getDouble("fill_button2", 0d);
|
||||
if (amount2 > 0) {
|
||||
button2.setVisibility(View.VISIBLE);
|
||||
button2.setText(DecimalFormatter.toPumpSupportedBolus(amount2)); // + "U");
|
||||
button2.setOnClickListener(this);
|
||||
preset2Button.setVisibility(View.VISIBLE);
|
||||
preset2Button.setText(DecimalFormatter.toPumpSupportedBolus(amount2)); // + "U");
|
||||
preset2Button.setOnClickListener(this);
|
||||
} else {
|
||||
button2.setVisibility(View.GONE);
|
||||
preset2Button.setVisibility(View.GONE);
|
||||
}
|
||||
Button preset3Button = view.findViewById(R.id.fill_preset_button3);
|
||||
amount3 = SP.getDouble("fill_button3", 0d);
|
||||
if (amount3 > 0) {
|
||||
button3.setVisibility(View.VISIBLE);
|
||||
button3.setText(DecimalFormatter.toPumpSupportedBolus(amount3)); // + "U");
|
||||
button3.setOnClickListener(this);
|
||||
preset3Button.setVisibility(View.VISIBLE);
|
||||
preset3Button.setText(DecimalFormatter.toPumpSupportedBolus(amount3)); // + "U");
|
||||
preset3Button.setOnClickListener(this);
|
||||
} else {
|
||||
button3.setVisibility(View.GONE);
|
||||
preset3Button.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
LinearLayout notesLayout = view.findViewById(R.id.fill_notes_layout);
|
||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||
notesEdit = view.findViewById(R.id.fill_notes);
|
||||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
return view;
|
||||
|
@ -154,15 +184,18 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
confirmMessage.add("" + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + getString(R.string.record_insulin_cartridge_change) + "</font>");
|
||||
|
||||
final String notes = notesEdit.getText().toString();
|
||||
if (!notes.isEmpty()) {
|
||||
confirmMessage.add(MainApp.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes);
|
||||
}
|
||||
|
||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
|
||||
final Context context = getContext();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
if (confirmMessage.isEmpty())
|
||||
confirmMessage.add(MainApp.gs(R.string.no_action_selected));
|
||||
|
||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||
if (insulinAfterConstraints > 0 || pumpSiteChangeCheckbox.isChecked() || insulinCartridgeChangeCheckbox.isChecked()) {
|
||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(confirmMessage)));
|
||||
builder.setPositiveButton(getString(R.string.primefill), (dialog, id) -> {
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
|
@ -171,6 +204,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.isValid = false; // do not count it in IOB (for pump history)
|
||||
detailedBolusInfo.notes = notes;
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -186,10 +220,14 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
});
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Fill"));
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
if (pumpSiteChangeCheckbox.isChecked()) NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now);
|
||||
if (insulinCartridgeChangeCheckbox.isChecked()) NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now + 1000);
|
||||
if (pumpSiteChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.SITECHANGE, now(), notes);
|
||||
if (insulinCartridgeChangeCheckbox.isChecked())
|
||||
NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, now() + 1000, notes);
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
||||
}
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
dismiss();
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package info.nightscout.androidaps.plugins.Overview.Dialogs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -19,20 +18,15 @@ import android.view.WindowManager;
|
|||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
|
||||
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -52,36 +46,29 @@ import info.nightscout.utils.DateUtil;
|
|||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
public class NewCarbsDialog extends DialogFragment implements OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener, CompoundButton.OnCheckedChangeListener {
|
||||
import static info.nightscout.utils.DateUtil.now;
|
||||
|
||||
public class NewCarbsDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
private static Logger log = LoggerFactory.getLogger(NewCarbsDialog.class);
|
||||
|
||||
private NumberPicker editCarbs;
|
||||
|
||||
private TextView dateButton;
|
||||
private TextView timeButton;
|
||||
|
||||
private Date initialEventTime;
|
||||
private Date eventTime;
|
||||
|
||||
private Button fav1Button;
|
||||
private Button fav2Button;
|
||||
private Button fav3Button;
|
||||
|
||||
private EditText notesEdit;
|
||||
|
||||
private static final int FAV1_DEFAULT = 5;
|
||||
private static final int FAV2_DEFAULT = 10;
|
||||
private static final int FAV3_DEFAULT = 20;
|
||||
|
||||
private RadioButton startActivityTTCheckbox;
|
||||
private RadioButton startEatingSoonTTCheckbox;
|
||||
private RadioButton startHypoTTCheckbox;
|
||||
private boolean togglingTT;
|
||||
|
||||
private NumberPicker editTime;
|
||||
private NumberPicker editDuration;
|
||||
private NumberPicker editCarbs;
|
||||
private Integer maxCarbs;
|
||||
|
||||
private EditText notesEdit;
|
||||
|
||||
//one shot guards
|
||||
private boolean accepted;
|
||||
private boolean okClicked;
|
||||
|
@ -94,6 +81,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
final private TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
validateInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,12 +90,21 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
|
||||
private void validateInputs() {
|
||||
Integer carbs = SafeParse.stringToInt(editCarbs.getText());
|
||||
int time = editTime.getValue().intValue();
|
||||
if (time > 12 * 60 || time < -12 * 60) {
|
||||
editTime.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.constraintapllied));
|
||||
}
|
||||
Double duration = editDuration.getValue();
|
||||
if (duration > 10) {
|
||||
editDuration.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.constraintapllied));
|
||||
}
|
||||
int carbs = editCarbs.getValue().intValue();
|
||||
if (carbs > maxCarbs) {
|
||||
editCarbs.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.carbsconstraintapplied));
|
||||
|
@ -125,12 +122,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||
|
||||
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
||||
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
|
||||
startActivityTTCheckbox = view.findViewById(R.id.newcarbs_activity_tt);
|
||||
startActivityTTCheckbox.setOnCheckedChangeListener(this);
|
||||
startEatingSoonTTCheckbox = view.findViewById(R.id.newcarbs_eating_soon_tt);
|
||||
|
@ -138,29 +129,35 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
startHypoTTCheckbox = view.findViewById(R.id.newcarbs_hypo_tt);
|
||||
startHypoTTCheckbox.setOnCheckedChangeListener(this);
|
||||
|
||||
dateButton = view.findViewById(R.id.newcarbs_eventdate);
|
||||
timeButton = view.findViewById(R.id.newcarb_eventtime);
|
||||
editTime = view.findViewById(R.id.newcarbs_time);
|
||||
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
||||
|
||||
initialEventTime = new Date();
|
||||
eventTime = new Date(initialEventTime.getTime());
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
dateButton.setOnClickListener(this);
|
||||
timeButton.setOnClickListener(this);
|
||||
LinearLayout durationLayout = view.findViewById(R.id.newcarbs_duration_layout);
|
||||
durationLayout.setVisibility(MainApp.engineeringMode ? View.VISIBLE : View.GONE);
|
||||
|
||||
fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
||||
editDuration = view.findViewById(R.id.new_carbs_duration);
|
||||
editDuration.setParams(0d, 0d, 10d, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
|
||||
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||
|
||||
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
|
||||
Button fav1Button = view.findViewById(R.id.newcarbs_plus1);
|
||||
fav1Button.setOnClickListener(this);
|
||||
fav1Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)));
|
||||
|
||||
fav2Button = view.findViewById(R.id.newcarbs_plus2);
|
||||
Button fav2Button = view.findViewById(R.id.newcarbs_plus2);
|
||||
fav2Button.setOnClickListener(this);
|
||||
fav2Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT)));
|
||||
|
||||
fav3Button = view.findViewById(R.id.newcarbs_plus3);
|
||||
Button fav3Button = view.findViewById(R.id.newcarbs_plus3);
|
||||
fav3Button.setOnClickListener(this);
|
||||
fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)));
|
||||
|
||||
notesEdit = (EditText) view.findViewById(R.id.newcarbs_notes);
|
||||
LinearLayout notesLayout = view.findViewById(R.id.newcarbs_notes_layout);
|
||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||
notesEdit = view.findViewById(R.id.newcarbs_notes);
|
||||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
|
@ -173,8 +170,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
|
||||
@Override
|
||||
public synchronized void onClick(View view) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(eventTime);
|
||||
switch (view.getId()) {
|
||||
case R.id.ok:
|
||||
submit();
|
||||
|
@ -182,28 +177,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
case R.id.cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.newcarbs_eventdate:
|
||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.get(Calendar.DAY_OF_MONTH)
|
||||
);
|
||||
dpd.setThemeDark(true);
|
||||
dpd.dismissOnPause(true);
|
||||
dpd.show(getActivity().getFragmentManager(), "Datepickerdialog");
|
||||
break;
|
||||
case R.id.newcarb_eventtime:
|
||||
TimePickerDialog tpd = TimePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.HOUR_OF_DAY),
|
||||
calendar.get(Calendar.MINUTE),
|
||||
DateFormat.is24HourFormat(getActivity())
|
||||
);
|
||||
tpd.setThemeDark(true);
|
||||
tpd.dismissOnPause(true);
|
||||
tpd.show(getActivity().getFragmentManager(), "Timepickerdialog");
|
||||
break;
|
||||
case R.id.newcarbs_plus1:
|
||||
editCarbs.setValue(Math.max(0, editCarbs.getValue()
|
||||
+ SP.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)));
|
||||
|
@ -309,18 +282,13 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
}
|
||||
okClicked = true;
|
||||
try {
|
||||
final Integer carbs = SafeParse.stringToInt(editCarbs.getText());
|
||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
|
||||
|
||||
List<String> actions = new LinkedList<>();
|
||||
if (carbs > 0)
|
||||
actions.add(MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.colorCarbsButton) + "'>" + carbsAfterConstraints + "g" + "</font>");
|
||||
if (!carbsAfterConstraints.equals(carbs))
|
||||
actions.add("<font color='" + MainApp.gc(R.color.low) + "'>" + MainApp.gs(R.string.carbsconstraintapplied) + "</font>");
|
||||
|
||||
final Profile currentProfile = MainApp.getConfigBuilder().getProfile();
|
||||
if (currentProfile == null)
|
||||
if (currentProfile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int carbs = editCarbs.getValue().intValue();
|
||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
|
||||
|
||||
int activityTTDuration = SP.getInt(R.string.key_activity_duration, Constants.defaultActivityTTDuration);
|
||||
activityTTDuration = activityTTDuration > 0 ? activityTTDuration : Constants.defaultActivityTTDuration;
|
||||
|
@ -337,6 +305,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
double hypoTT = SP.getDouble(R.string.key_hypo_target, currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultHypoTTmmol : Constants.defaultHypoTTmgdl);
|
||||
hypoTT = hypoTT > 0 ? hypoTT : currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultHypoTTmmol : Constants.defaultHypoTTmgdl;
|
||||
|
||||
List<String> actions = new LinkedList<>();
|
||||
|
||||
if (startActivityTTCheckbox.isChecked()) {
|
||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to1Decimal(activityTT) + " mmol/l (" + activityTTDuration + " min)</font>");
|
||||
|
@ -357,28 +327,39 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to0Decimal(hypoTT) + " mg/dl (" + hypoTTDuration + " min)</font>");
|
||||
}
|
||||
|
||||
int timeOffset = editTime.getValue().intValue();
|
||||
final long time = now() + timeOffset * 1000 * 60;
|
||||
if (timeOffset != 0) {
|
||||
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time));
|
||||
}
|
||||
int duration = editDuration.getValue().intValue();
|
||||
if (duration > 0) {
|
||||
actions.add(MainApp.gs(R.string.duration) + ": " + duration + MainApp.gs(R.string.shorthour));
|
||||
}
|
||||
if (carbs > 0) {
|
||||
actions.add(MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.colorCarbsButton) + "'>" + carbsAfterConstraints + "g" + "</font>");
|
||||
}
|
||||
if (!carbsAfterConstraints.equals(carbs)) {
|
||||
actions.add("<font color='" + MainApp.gc(R.color.low) + "'>" + MainApp.gs(R.string.carbsconstraintapplied) + "</font>");
|
||||
}
|
||||
final String notes = notesEdit.getText().toString();
|
||||
if (!notes.isEmpty()) {
|
||||
actions.add(MainApp.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes);
|
||||
}
|
||||
|
||||
final double finalActivityTT = activityTT;
|
||||
final int finalActivityTTDuration = activityTTDuration;
|
||||
final double finalEatigSoonTT = eatingSoonTT;
|
||||
final int finalEatingSoonTTDuration = eatingSoonTTDuration;
|
||||
final double finalHypoTT = hypoTT;
|
||||
final int finalHypoTTDuration = hypoTTDuration;
|
||||
final String finalNotes = notesEdit.getText().toString();
|
||||
|
||||
if (!initialEventTime.equals(eventTime)) {
|
||||
actions.add("Time: " + DateUtil.dateAndTimeString(eventTime));
|
||||
}
|
||||
|
||||
final int finalCarbsAfterConstraints = carbsAfterConstraints;
|
||||
|
||||
final Context context = getContext();
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||
builder.setMessage(actions.isEmpty()
|
||||
? MainApp.gs(R.string.no_action_selected)
|
||||
: Html.fromHtml(Joiner.on("<br/>").join(actions)));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), actions.isEmpty() ? null : (dialog, id) -> {
|
||||
if (carbsAfterConstraints > 0 || startActivityTTCheckbox.isChecked()
|
||||
|| startEatingSoonTTCheckbox.isChecked() || startHypoTTCheckbox.isChecked()) {
|
||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(actions)));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
||||
synchronized (builder) {
|
||||
if (accepted) {
|
||||
log.debug("guarding: already accepted");
|
||||
|
@ -415,16 +396,43 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||
}
|
||||
|
||||
if (finalCarbsAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.date = eventTime.getTime();
|
||||
detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION;
|
||||
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.notes = finalNotes;
|
||||
if (carbsAfterConstraints > 0) {
|
||||
if (duration == 0) {
|
||||
createCarb(carbsAfterConstraints, time, notes);
|
||||
} else {
|
||||
long remainingCarbs = carbsAfterConstraints;
|
||||
int ticks = (duration * 4); //duration guaranteed to be integer greater zero
|
||||
for (int i = 0; i < ticks; i++){
|
||||
long carbTime = time + i * 15 * 60 * 1000;
|
||||
long smallCarbAmount = Math.round((1d * remainingCarbs) / (ticks-i)); //on last iteration (ticks-i) is 1 -> smallCarbAmount == remainingCarbs
|
||||
remainingCarbs -= smallCarbAmount;
|
||||
createCarb(smallCarbAmount, carbTime, notes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
||||
}
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
dismiss();
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void createCarb(long carbs, long time, @Nullable String notes) {
|
||||
DetailedBolusInfo carbInfo = new DetailedBolusInfo();
|
||||
carbInfo.date = time;
|
||||
carbInfo.eventType = CareportalEvent.CARBCORRECTION;
|
||||
carbInfo.carbs = carbs;
|
||||
carbInfo.context = getContext();
|
||||
carbInfo.source = Source.USER;
|
||||
carbInfo.notes = notes;
|
||||
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!result.success) {
|
||||
|
@ -438,32 +446,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
dismiss();
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
||||
eventTime.setYear(year - 1900);
|
||||
eventTime.setMonth(monthOfYear);
|
||||
eventTime.setDate(dayOfMonth);
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int second) {
|
||||
eventTime.setHours(hourOfDay);
|
||||
eventTime.setMinutes(minute);
|
||||
eventTime.setSeconds(second);
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.text.Editable;
|
||||
import android.text.Html;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -18,19 +17,16 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout;
|
||||
import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -54,30 +50,25 @@ import info.nightscout.utils.SP;
|
|||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
public class NewInsulinDialog extends DialogFragment implements OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener {
|
||||
import static info.nightscout.utils.DateUtil.now;
|
||||
|
||||
public class NewInsulinDialog extends DialogFragment implements OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class);
|
||||
|
||||
private NumberPicker editInsulin;
|
||||
|
||||
private TextView dateButton;
|
||||
private TextView timeButton;
|
||||
|
||||
private Date initialEventTime;
|
||||
private Date eventTime;
|
||||
|
||||
private Button plus1Button;
|
||||
private Button plus2Button;
|
||||
private Button plus3Button;
|
||||
|
||||
public static final double PLUS1_DEFAULT = 0.5d;
|
||||
public static final double PLUS2_DEFAULT = 1d;
|
||||
public static final double PLUS3_DEFAULT = 2d;
|
||||
|
||||
private CheckBox startESMCheckbox;
|
||||
private CheckBox startEatingSoonTTCheckbox;
|
||||
private CheckBox recordOnlyCheckbox;
|
||||
|
||||
private LinearLayout editLayout;
|
||||
private NumberPicker editTime;
|
||||
private NumberPicker editInsulin;
|
||||
private Double maxInsulin;
|
||||
|
||||
private EditText notesEdit;
|
||||
|
||||
//one shot guards
|
||||
private boolean accepted;
|
||||
private boolean okClicked;
|
||||
|
@ -90,6 +81,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
final private TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
validateInputs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -98,12 +90,16 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
validateInputs();
|
||||
}
|
||||
};
|
||||
|
||||
private void validateInputs() {
|
||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
int time = editTime.getValue().intValue();
|
||||
if (Math.abs(time) > 12 * 60) {
|
||||
editTime.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.constraintapllied));
|
||||
}
|
||||
Double insulin = editInsulin.getValue();
|
||||
if (insulin > maxInsulin) {
|
||||
editInsulin.setValue(0d);
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.bolusconstraintapplied));
|
||||
|
@ -121,39 +117,34 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
startEatingSoonTTCheckbox = view.findViewById(R.id.newinsulin_start_eating_soon_tt);
|
||||
|
||||
recordOnlyCheckbox = view.findViewById(R.id.newinsulin_record_only);
|
||||
recordOnlyCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> editLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE));
|
||||
|
||||
editLayout = view.findViewById(R.id.newinsulin_time_layout);
|
||||
editLayout.setVisibility(View.GONE);
|
||||
editTime = view.findViewById(R.id.newinsulin_time);
|
||||
editTime.setParams(0d, -12 * 60d, 12 * 60d, 5d, new DecimalFormat("0"), false, textWatcher);
|
||||
|
||||
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newinsulin_amount);
|
||||
|
||||
editInsulin = view.findViewById(R.id.newinsulin_amount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
|
||||
|
||||
dateButton = (TextView) view.findViewById(R.id.newinsulin_eventdate);
|
||||
timeButton = (TextView) view.findViewById(R.id.newinsulin_eventtime);
|
||||
|
||||
initialEventTime = new Date();
|
||||
eventTime = new Date(initialEventTime.getTime());
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
dateButton.setOnClickListener(this);
|
||||
timeButton.setOnClickListener(this);
|
||||
|
||||
plus1Button = (Button) view.findViewById(R.id.newinsulin_plus05);
|
||||
Button plus1Button = view.findViewById(R.id.newinsulin_plus05);
|
||||
plus1Button.setOnClickListener(this);
|
||||
plus1Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT)));
|
||||
plus2Button = (Button) view.findViewById(R.id.newinsulin_plus10);
|
||||
Button plus2Button = view.findViewById(R.id.newinsulin_plus10);
|
||||
plus2Button.setOnClickListener(this);
|
||||
plus2Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT)));
|
||||
plus3Button = (Button) view.findViewById(R.id.newinsulin_plus20);
|
||||
Button plus3Button = view.findViewById(R.id.newinsulin_plus20);
|
||||
plus3Button.setOnClickListener(this);
|
||||
plus3Button.setText(toSignedString(SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT)));
|
||||
|
||||
startESMCheckbox = (CheckBox) view.findViewById(R.id.newinsulin_start_eating_soon_tt);
|
||||
|
||||
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newinsulin_record_only);
|
||||
recordOnlyCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (dateButton != null) dateButton.setEnabled(isChecked);
|
||||
if (timeButton != null) timeButton.setEnabled(isChecked);
|
||||
});
|
||||
LinearLayout notesLayout = view.findViewById(R.id.newinsulin_notes_layout);
|
||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||
notesEdit = view.findViewById(R.id.newinsulin_notes);
|
||||
|
||||
setCancelable(true);
|
||||
getDialog().setCanceledOnTouchOutside(false);
|
||||
|
@ -167,8 +158,6 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
|
||||
@Override
|
||||
public synchronized void onClick(View view) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(eventTime);
|
||||
switch (view.getId()) {
|
||||
case R.id.ok:
|
||||
submit();
|
||||
|
@ -176,28 +165,6 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
case R.id.cancel:
|
||||
dismiss();
|
||||
break;
|
||||
case R.id.newinsulin_eventdate:
|
||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.get(Calendar.DAY_OF_MONTH)
|
||||
);
|
||||
dpd.setThemeDark(true);
|
||||
dpd.dismissOnPause(true);
|
||||
dpd.show(getActivity().getFragmentManager(), "Datepickerdialog");
|
||||
break;
|
||||
case R.id.newinsulin_eventtime:
|
||||
TimePickerDialog tpd = TimePickerDialog.newInstance(
|
||||
this,
|
||||
calendar.get(Calendar.HOUR_OF_DAY),
|
||||
calendar.get(Calendar.MINUTE),
|
||||
DateFormat.is24HourFormat(getActivity())
|
||||
);
|
||||
tpd.setThemeDark(true);
|
||||
tpd.dismissOnPause(true);
|
||||
tpd.show(getActivity().getFragmentManager(), "Timepickerdialog");
|
||||
break;
|
||||
case R.id.newinsulin_plus05:
|
||||
editInsulin.setValue(Math.max(0, editInsulin.getValue()
|
||||
+ SP.getDouble(MainApp.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT)));
|
||||
|
@ -225,6 +192,10 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
okClicked = true;
|
||||
|
||||
try {
|
||||
Profile currentProfile = MainApp.getConfigBuilder().getProfile();
|
||||
if (currentProfile == null)
|
||||
return;
|
||||
|
||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
|
||||
|
@ -239,40 +210,39 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
if (!insulinAfterConstraints.equals(insulin))
|
||||
actions.add("<font color='" + MainApp.sResources.getColor(R.color.low) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>");
|
||||
|
||||
double prefTTDuration = SP.getDouble(R.string.key_eatingsoon_duration, 45d);
|
||||
double ttDuration = prefTTDuration > 0 ? prefTTDuration : 45d;
|
||||
double prefTT = SP.getDouble(R.string.key_eatingsoon_target, 80d);
|
||||
Profile currentProfile = MainApp.getConfigBuilder().getProfile();
|
||||
if (currentProfile == null)
|
||||
return;
|
||||
double tt;
|
||||
if (currentProfile.getUnits().equals(Constants.MMOL))
|
||||
tt = prefTT > 0 ? Profile.toMgdl(prefTT, Constants.MMOL) : 80d;
|
||||
else
|
||||
tt = prefTT > 0 ? prefTT : 80d;
|
||||
final double finalTT = tt;
|
||||
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
|
||||
eatingSoonTTDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : Constants.defaultEatingSoonTTDuration;
|
||||
double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl);
|
||||
eatingSoonTT = eatingSoonTT > 0 ? eatingSoonTT : currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl;
|
||||
|
||||
if (startESMCheckbox.isChecked()) {
|
||||
if (currentProfile.getUnits().equals("mmol")) {
|
||||
actions.add("TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + Profile.toMmol(tt, Constants.MGDL) + " mmol for " + ((int) ttDuration) + " min </font>");
|
||||
if (startEatingSoonTTCheckbox.isChecked()) {
|
||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>");
|
||||
} else
|
||||
actions.add("TT: " + "<font color='" + MainApp.sResources.getColor(R.color.high) + "'>" + ((int) tt) + "mg/dl for " + ((int) ttDuration) + " min </font>");
|
||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.high) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>");
|
||||
}
|
||||
|
||||
if (!initialEventTime.equals(eventTime)) {
|
||||
actions.add("Time: " + DateUtil.dateAndTimeString(eventTime));
|
||||
int timeOffset = editTime.getValue().intValue();
|
||||
final long time = now() + timeOffset * 1000 * 60;
|
||||
if (timeOffset != 0) {
|
||||
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time));
|
||||
}
|
||||
final String notes = notesEdit.getText().toString();
|
||||
if (!notes.isEmpty()) {
|
||||
actions.add(MainApp.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes);
|
||||
}
|
||||
|
||||
final double finalInsulinAfterConstraints = insulinAfterConstraints;
|
||||
final double finalEatigSoonTT = eatingSoonTT;
|
||||
final int finalEatingSoonTTDuration = eatingSoonTTDuration;
|
||||
|
||||
final Context context = getContext();
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
|
||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||
builder.setMessage(actions.isEmpty()
|
||||
? MainApp.gs(R.string.no_action_selected)
|
||||
: Html.fromHtml(Joiner.on("<br/>").join(actions)));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), actions.isEmpty() ? null : (dialog, id) -> {
|
||||
if (finalInsulinAfterConstraints > 0 || startEatingSoonTTCheckbox.isChecked()) {
|
||||
builder.setMessage(Html.fromHtml(Joiner.on("<br/>").join(actions)));
|
||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
||||
synchronized (builder) {
|
||||
if (accepted) {
|
||||
log.debug("guarding: already accepted");
|
||||
|
@ -280,34 +250,29 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
}
|
||||
accepted = true;
|
||||
|
||||
if (startESMCheckbox.isChecked()) {
|
||||
if (startEatingSoonTTCheckbox.isChecked()) {
|
||||
TempTarget tempTarget = new TempTarget()
|
||||
.date(System.currentTimeMillis())
|
||||
.duration((int) ttDuration)
|
||||
.reason("Eating soon")
|
||||
.duration(finalEatingSoonTTDuration)
|
||||
.reason(MainApp.gs(R.string.eatingsoon))
|
||||
.source(Source.USER)
|
||||
.low((int) finalTT)
|
||||
.high((int) finalTT);
|
||||
.low(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()))
|
||||
.high(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()));
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||
}
|
||||
|
||||
if (finalInsulinAfterConstraints <= 0.01) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (recordOnlyCheckbox.isChecked()) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.date = eventTime.getTime();
|
||||
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
} else {
|
||||
if (finalInsulinAfterConstraints > 0) {
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||
detailedBolusInfo.context = context;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
detailedBolusInfo.notes = notes;
|
||||
if (recordOnlyCheckbox.isChecked()) {
|
||||
detailedBolusInfo.date = time;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
} else {
|
||||
detailedBolusInfo.date = now();
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -324,7 +289,11 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(MainApp.gs(R.string.no_action_selected));
|
||||
}
|
||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||
builder.show();
|
||||
dismiss();
|
||||
|
@ -332,20 +301,4 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
|||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
||||
eventTime.setYear(year - 1900);
|
||||
eventTime.setMonth(monthOfYear);
|
||||
eventTime.setDate(dayOfMonth);
|
||||
dateButton.setText(DateUtil.dateString(eventTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int second) {
|
||||
eventTime.setHours(hourOfDay);
|
||||
eventTime.setMinutes(minute);
|
||||
eventTime.setSeconds(second);
|
||||
timeButton.setText(DateUtil.timeString(eventTime));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
NumberPicker editCorr;
|
||||
NumberPicker editCarbTime;
|
||||
|
||||
LinearLayout notesLayout;
|
||||
EditText notesEdit;
|
||||
|
||||
Integer calculatedCarbs = 0;
|
||||
|
@ -209,7 +210,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
|
||||
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
|
||||
|
||||
notesEdit = (EditText) view.findViewById(R.id.newcarbs_notes);
|
||||
notesLayout = view.findViewById(R.id.treatments_wizard_notes_layout);
|
||||
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
|
||||
notesEdit = (EditText) view.findViewById(R.id.treatment_wizard_notes);
|
||||
|
||||
bgTrend = (TextView) view.findViewById(R.id.treatments_wizard_bgtrend);
|
||||
bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin);
|
||||
|
|
|
@ -452,7 +452,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
//log.debug("Adding new Treatment record" + carbsTreatment);
|
||||
}
|
||||
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||
NSUpload.uploadBolusWizardRecord(detailedBolusInfo);
|
||||
NSUpload.uploadTreatmentRecord(detailedBolusInfo);
|
||||
return newRecordCreated;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,10 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
|||
holder.iob.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||
else
|
||||
holder.iob.setTextColor(holder.carbs.getCurrentTextColor());
|
||||
if (t.date > DateUtil.now())
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorScheduled));
|
||||
else
|
||||
holder.date.setTextColor(holder.carbs.getCurrentTextColor());
|
||||
holder.remove.setTag(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,14 +84,10 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
|||
holder.reasonLabel.setText("");
|
||||
holder.reasonColon.setText("");
|
||||
}
|
||||
if (tempTarget.isInProgress()) {
|
||||
if (tempTarget == currentlyActiveTarget) {
|
||||
// active as newest
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
|
||||
} else {
|
||||
// other's that might become active again after the latest (overlapping) is over
|
||||
if (tempTarget.isInProgress() && tempTarget == currentlyActiveTarget) {
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||
}
|
||||
} else if (tempTarget.date > DateUtil.now()) {
|
||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorScheduled));
|
||||
} else {
|
||||
holder.date.setTextColor(holder.reasonColon.getCurrentTextColor());
|
||||
}
|
||||
|
|
|
@ -166,6 +166,10 @@ public class CommandQueue {
|
|||
public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
||||
Command.CommandType type = detailedBolusInfo.isSMB ? Command.CommandType.SMB_BOLUS : Command.CommandType.BOLUS;
|
||||
|
||||
if(type.equals(Command.CommandType.BOLUS) && detailedBolusInfo.carbs > 0 && detailedBolusInfo.insulin == 0){
|
||||
type = Command.CommandType.CARBS_ONLY_TREATMENT;
|
||||
//Carbs only can be added in parallel as they can be "in the future".
|
||||
} else {
|
||||
if (isRunning(type)) {
|
||||
if (callback != null)
|
||||
callback.result(executingNowError()).run();
|
||||
|
@ -174,6 +178,7 @@ public class CommandQueue {
|
|||
|
||||
// remove all unfinished boluses
|
||||
removeAll(type);
|
||||
}
|
||||
|
||||
// apply constraints
|
||||
detailedBolusInfo.insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(detailedBolusInfo.insulin)).value();
|
||||
|
@ -183,13 +188,15 @@ public class CommandQueue {
|
|||
if (detailedBolusInfo.isSMB) {
|
||||
add(new CommandSMBBolus(detailedBolusInfo, callback));
|
||||
} else {
|
||||
add(new CommandBolus(detailedBolusInfo, callback));
|
||||
add(new CommandBolus(detailedBolusInfo, callback, type));
|
||||
if(type.equals(Command.CommandType.BOLUS)) {
|
||||
// Bring up bolus progress dialog (start here, so the dialog is shown when the bolus is requested,
|
||||
// not when the Bolus command is starting. The command closes the dialog upon completion).
|
||||
showBolusProgressDialog(detailedBolusInfo.insulin, detailedBolusInfo.context);
|
||||
// Notify Wear about upcoming bolus
|
||||
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
||||
}
|
||||
}
|
||||
|
||||
notifyAboutNewCommand();
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ public abstract class Command {
|
|||
public enum CommandType {
|
||||
BOLUS,
|
||||
SMB_BOLUS,
|
||||
CARBS_ONLY_TREATMENT,
|
||||
TEMPBASAL,
|
||||
EXTENDEDBOLUS,
|
||||
BASALPROFILE,
|
||||
|
|
|
@ -16,8 +16,8 @@ import info.nightscout.utils.DecimalFormatter;
|
|||
public class CommandBolus extends Command {
|
||||
DetailedBolusInfo detailedBolusInfo;
|
||||
|
||||
public CommandBolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
|
||||
commandType = CommandType.BOLUS;
|
||||
public CommandBolus(DetailedBolusInfo detailedBolusInfo, Callback callback, CommandType type) {
|
||||
commandType = type;
|
||||
this.detailedBolusInfo = detailedBolusInfo;
|
||||
this.callback = callback;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.content.pm.ResolveInfo;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONArray;
|
||||
|
@ -258,7 +259,7 @@ public class NSUpload {
|
|||
}
|
||||
}
|
||||
|
||||
public static void uploadBolusWizardRecord(DetailedBolusInfo detailedBolusInfo) {
|
||||
public static void uploadTreatmentRecord(DetailedBolusInfo detailedBolusInfo) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("eventType", detailedBolusInfo.eventType);
|
||||
|
@ -500,7 +501,7 @@ public class NSUpload {
|
|||
}
|
||||
}
|
||||
|
||||
public static void uploadEvent(String careportalEvent, long time) {
|
||||
public static void uploadEvent(String careportalEvent, long time, @Nullable String notes) {
|
||||
Context context = MainApp.instance().getApplicationContext();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("action", "dbAdd");
|
||||
|
@ -510,6 +511,9 @@ public class NSUpload {
|
|||
data.put("eventType", careportalEvent);
|
||||
data.put("created_at", DateUtil.toISOString(time));
|
||||
data.put("enteredBy", SP.getString("careportal_enteredby", MainApp.gs(R.string.app_name)));
|
||||
if (notes != null) {
|
||||
data.put("notes", notes);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.os.Handler;
|
|||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.DigitsKeyListener;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -164,6 +165,8 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
|
|||
this.formater = formater;
|
||||
this.allowZero = allowZero;
|
||||
|
||||
editText.setKeyListener(DigitsKeyListener.getInstance(minValue < 0, step != Math.rint(step)));
|
||||
|
||||
if (textWatcher != null)
|
||||
editText.removeTextChangedListener(textWatcher);
|
||||
updateEditText();
|
||||
|
|
|
@ -1,70 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/icon_cp_pump_canula" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:text="@string/primefill"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/colorInsulinButton" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:padding="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:src="@drawable/icon_cp_pump_canula" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/careportal_newnstreatment_insulin_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/catheter_change"
|
||||
android:id="@+id/fill_catheter_change"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="Pump site change" />
|
||||
android:text="@string/careportal_pumpsitechange" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cartridge_change"
|
||||
android:id="@+id/fill_cartridge_change"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/careportal_insulincartridgechange" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="Insulin cartridge change" />
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/overview_insulin_label" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/treatments_newtreatment_insulinamount"
|
||||
android:layout_width="130dp"
|
||||
android:id="@+id/fill_insulinamount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/insulin_unit_shortname" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/fill_preset_button1"
|
||||
|
@ -89,6 +120,31 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fill_notes_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:width="60dp"
|
||||
android:padding="2dp"
|
||||
android:text="@string/careportal_newnstreatment_notes_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/fill_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text|textCapSentences" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:text="1"
|
||||
android:textColor="@android:color/black"
|
||||
android:inputType="numberDecimal"
|
||||
android:digits="0123456789.,"
|
||||
android:inputType="number"
|
||||
android:gravity="center"
|
||||
android:imeOptions="actionDone"
|
||||
/>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -18,19 +19,32 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/icon_cp_bolus_carbs" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:text="@string/carbs"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/colorCarbsButton" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/icon_cp_bolus_carbs" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -55,43 +69,101 @@
|
|||
android:id="@+id/newcarbs_hypo_tt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="@string/start_hypo_tt" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/time" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/newcarbs_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shortminute" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/newcarbs_duration_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/duration"/>
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/new_carbs_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:layout_gravity="end" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shorthour"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp">
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/newcarbs_eventdate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp"
|
||||
android:text="2017/05/05" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/newcarb_eventtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp"
|
||||
android:text="08:20pm" />
|
||||
</LinearLayout>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/overview_carbs_label" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/newcarb_carbsamount"
|
||||
android:layout_width="130dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shortgramm" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -123,15 +195,16 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/newcarbs_notes_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:width="60dp"
|
||||
android:padding="2dp"
|
||||
android:text="@string/careportal_newnstreatment_notes_label"
|
||||
|
@ -142,7 +215,7 @@
|
|||
android:id="@+id/newcarbs_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
android:inputType="text|textCapSentences" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -16,20 +16,31 @@
|
|||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="5dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/icon_bolus" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textAlignment="center"
|
||||
android:text="@string/overview_insulin_label"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/colorInsulinButton" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/icon_bolus" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -52,46 +63,74 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/newinsulin_time_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/time" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/newinsulin_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/shortminute" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="5dp">
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/newinsulin_eventdate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:enabled="false"
|
||||
android:padding="5dp"
|
||||
android:text="2017/05/05" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/newinsulin_eventtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:enabled="false"
|
||||
android:padding="5dp"
|
||||
android:text="08:20pm" />
|
||||
</LinearLayout>
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/overview_insulin_label" />
|
||||
|
||||
<info.nightscout.utils.NumberPicker
|
||||
android:id="@+id/treatments_newinsulin_amount"
|
||||
android:layout_width="130dp"
|
||||
android:id="@+id/newinsulin_amount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/insulin_unit_shortname" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
|
@ -117,6 +156,31 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/newinsulin_notes_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:width="60dp"
|
||||
android:padding="2dp"
|
||||
android:text="@string/careportal_newnstreatment_notes_label"
|
||||
android:textAppearance="@android:style/TextAppearance.Material.Small"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/newinsulin_notes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text|textCapSentences" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/mdtp_done_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -216,11 +216,12 @@
|
|||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/newcarbs_notes"
|
||||
android:id="@+id/treatment_wizard_notes"
|
||||
android:layout_width="155dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="left"
|
||||
android:inputType="text|textCapSentences"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<color name="colorSetExtendedButton">#FFDD7792</color>
|
||||
<color name="colorProfileSwitchButton">#ca77dd</color>
|
||||
|
||||
<color name="colorInProgress">#c45026</color>
|
||||
<color name="colorScheduled">#de7550</color>
|
||||
<color name="colorActive">#1b5e20</color>
|
||||
|
||||
<color name="loopenabled">#47c8ff</color>
|
||||
|
|
|
@ -715,6 +715,8 @@
|
|||
<string name="connectiontimedout">Connection timed out</string>
|
||||
<string name="food">Food</string>
|
||||
<string name="shortgramm">g</string>
|
||||
<string name="shortminute">m</string>
|
||||
<string name="shorthour">h</string>
|
||||
<string name="none"><![CDATA[<none>]]></string>
|
||||
<string name="shortkilojoul">kJ</string>
|
||||
<string name="shortenergy">En</string>
|
||||
|
@ -995,4 +997,7 @@
|
|||
<string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string>
|
||||
<string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string>
|
||||
<string name="openapssmb_maxiob_summary">This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value</string>
|
||||
<string name="time">Time</string>
|
||||
<string name="key_show_notes_entry_dialogs">show_notes_entry_dialogs</string>
|
||||
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
|
||||
</resources>
|
||||
|
|
|
@ -110,6 +110,10 @@
|
|||
android:key="@string/key_show_calibration_button"
|
||||
android:title="@string/overview_calibration"
|
||||
android:summary="@string/show_calibration_button_summary"/>
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_show_notes_entry_dialogs"
|
||||
android:title="@string/overview_show_notes_field_in_dialogs_title" />
|
||||
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
|
Loading…
Reference in a new issue