diff --git a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java
index 3935b17b8a..c2f9d16dc3 100644
--- a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java
+++ b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java
@@ -30,6 +30,7 @@ public class DetailedBolusInfo {
public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
public boolean isSMB = false; // is a Super-MicroBolus
public long deliverAt = 0; // SMB should be delivered within 1 min from this time
+ public String notes = null;
public DetailedBolusInfo copy() {
DetailedBolusInfo n = new DetailedBolusInfo();
@@ -47,6 +48,7 @@ public class DetailedBolusInfo {
n.pumpId = pumpId;
n.isSMB = isSMB;
n.deliverAt = deliverAt;
+ n.notes = notes;
return n;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
index 5d2d346fec..8e0baabd99 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewCarbsDialog.java
@@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview.Dialogs;
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;
@@ -16,6 +17,7 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
+import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
@@ -54,6 +56,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
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;
@@ -155,6 +159,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
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);
+
setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view;
@@ -337,6 +343,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
final int finalEatingSoonTTDuration = eatingSoonTTDuration;
final double finalHypoTT = hypoTT;
final int finalHypoTTDuration = hypoTTDuration;
+ final String finalNotes = notesEdit.getText().toString();
long timeOffset = editTime.getValue().longValue();
final long time = DateUtil.now() + timeOffset * 1000 * 60;
@@ -388,14 +395,14 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
if (carbsAfterConstraints > 0) {
if (duration == 0) {
- createCarb(carbsAfterConstraints, time);
+ createCarb(carbsAfterConstraints, time, finalNotes);
} else {
long remainingCarbs = carbsAfterConstraints;
long carbTime = time;
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
if (smallCarbAmount == 0) smallCarbAmount = 1;
while (remainingCarbs > 0) {
- createCarb(Math.min(smallCarbAmount, remainingCarbs), carbTime);
+ createCarb(Math.min(smallCarbAmount, remainingCarbs), carbTime, finalNotes);
remainingCarbs -= smallCarbAmount;
carbTime += 15 * 60 * 1000;
}
@@ -414,13 +421,14 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
}
}
- private void createCarb(long carbs, long time) {
+ 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(carbInfo, new Callback() {
@Override
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
index 962254e503..263bc7e090 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java
@@ -21,6 +21,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
+import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
@@ -104,6 +105,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
NumberPicker editCorr;
NumberPicker editCarbTime;
+ EditText notesEdit;
+
Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d;
JSONObject boluscalcJSON;
@@ -206,6 +209,8 @@ 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);
+
bgTrend = (TextView) view.findViewById(R.id.treatments_wizard_bgtrend);
bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin);
cobLayout = (LinearLayout) view.findViewById(R.id.treatments_wizard_cob_layout);
@@ -321,6 +326,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final Double bg = SafeParse.stringToDouble(editBg.getText());
final int carbTime = SafeParse.stringToInt(editCarbTime.getText());
final boolean useSuperBolus = superbolusCheckbox.isChecked();
+ final String finalNotes = notesEdit.getText().toString();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
@@ -364,6 +370,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
detailedBolusInfo.carbTime = carbTime;
detailedBolusInfo.boluscalc = boluscalcJSON;
detailedBolusInfo.source = Source.USER;
+ detailedBolusInfo.notes = finalNotes;
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
@Override
diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java
index f78e32f15d..c56c4f1a51 100644
--- a/app/src/main/java/info/nightscout/utils/NSUpload.java
+++ b/app/src/main/java/info/nightscout/utils/NSUpload.java
@@ -8,6 +8,7 @@ import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -276,6 +277,9 @@ public class NSUpload {
data.put("boluscalc", detailedBolusInfo.boluscalc);
if (detailedBolusInfo.carbTime != 0)
data.put("preBolus", detailedBolusInfo.carbTime);
+ if (!StringUtils.isEmpty(detailedBolusInfo.notes)) {
+ data.put("notes", detailedBolusInfo.notes);
+ }
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
diff --git a/app/src/main/res/layout/overview_newcarbs_dialog.xml b/app/src/main/res/layout/overview_newcarbs_dialog.xml
index 92fe1fc05d..38dca30d8e 100644
--- a/app/src/main/res/layout/overview_newcarbs_dialog.xml
+++ b/app/src/main/res/layout/overview_newcarbs_dialog.xml
@@ -233,9 +233,34 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml
index 4fbdfd3614..d4609c931e 100644
--- a/app/src/main/res/layout/overview_wizard_dialog.xml
+++ b/app/src/main/res/layout/overview_wizard_dialog.xml
@@ -199,6 +199,32 @@
+
+
+
+
+
+
+
+