Adding notes to carbs and to wizard on overview

This commit is contained in:
Markus M. May 2018-04-09 22:10:08 +02:00
parent e9ac979a1b
commit 99c8bbc6c2
6 changed files with 71 additions and 0 deletions

View file

@ -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 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 boolean isSMB = false; // is a Super-MicroBolus
public long deliverAt = 0; // SMB should be delivered within 1 min from this time public long deliverAt = 0; // SMB should be delivered within 1 min from this time
public String notes = null;
public DetailedBolusInfo copy() { public DetailedBolusInfo copy() {
DetailedBolusInfo n = new DetailedBolusInfo(); DetailedBolusInfo n = new DetailedBolusInfo();
@ -47,6 +48,7 @@ public class DetailedBolusInfo {
n.pumpId = pumpId; n.pumpId = pumpId;
n.isSMB = isSMB; n.isSMB = isSMB;
n.deliverAt = deliverAt; n.deliverAt = deliverAt;
n.notes = notes;
return n; return n;
} }

View file

@ -18,6 +18,7 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TextView; import android.widget.TextView;
@ -69,6 +70,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
private Button fav2Button; private Button fav2Button;
private Button fav3Button; private Button fav3Button;
private EditText notesEdit;
private static final int FAV1_DEFAULT = 5; private static final int FAV1_DEFAULT = 5;
private static final int FAV2_DEFAULT = 10; private static final int FAV2_DEFAULT = 10;
private static final int FAV3_DEFAULT = 20; private static final int FAV3_DEFAULT = 20;
@ -157,6 +160,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
fav3Button.setOnClickListener(this); fav3Button.setOnClickListener(this);
fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT))); fav3Button.setText(toSignedString(SP.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)));
notesEdit = (EditText) view.findViewById(R.id.newcarbs_notes);
setCancelable(true); setCancelable(true);
getDialog().setCanceledOnTouchOutside(false); getDialog().setCanceledOnTouchOutside(false);
return view; return view;
@ -358,6 +363,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
final int finalEatingSoonTTDuration = eatingSoonTTDuration; final int finalEatingSoonTTDuration = eatingSoonTTDuration;
final double finalHypoTT = hypoTT; final double finalHypoTT = hypoTT;
final int finalHypoTTDuration = hypoTTDuration; final int finalHypoTTDuration = hypoTTDuration;
final String finalNotes = notesEdit.getText().toString();
if (!initialEventTime.equals(eventTime)) { if (!initialEventTime.equals(eventTime)) {
actions.add("Time: " + DateUtil.dateAndTimeString(eventTime)); actions.add("Time: " + DateUtil.dateAndTimeString(eventTime));
@ -416,6 +422,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
detailedBolusInfo.carbs = finalCarbsAfterConstraints; detailedBolusInfo.carbs = finalCarbsAfterConstraints;
detailedBolusInfo.context = context; detailedBolusInfo.context = context;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
detailedBolusInfo.notes = finalNotes;
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
@Override @Override

View file

@ -21,6 +21,7 @@ import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -103,6 +104,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
NumberPicker editCorr; NumberPicker editCorr;
NumberPicker editCarbTime; NumberPicker editCarbTime;
EditText notesEdit;
Integer calculatedCarbs = 0; Integer calculatedCarbs = 0;
Double calculatedTotalInsulin = 0d; Double calculatedTotalInsulin = 0d;
JSONObject boluscalcJSON; JSONObject boluscalcJSON;
@ -205,6 +208,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb); superbolus = (TextView) view.findViewById(R.id.treatments_wizard_sb);
superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin); superbolusInsulin = (TextView) view.findViewById(R.id.treatments_wizard_sbinsulin);
notesEdit = (EditText) view.findViewById(R.id.newcarbs_notes);
bgTrend = (TextView) view.findViewById(R.id.treatments_wizard_bgtrend); bgTrend = (TextView) view.findViewById(R.id.treatments_wizard_bgtrend);
bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin); bgTrendInsulin = (TextView) view.findViewById(R.id.treatments_wizard_bgtrendinsulin);
cobLayout = (LinearLayout) view.findViewById(R.id.treatments_wizard_cob_layout); cobLayout = (LinearLayout) view.findViewById(R.id.treatments_wizard_cob_layout);
@ -320,6 +325,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
final Double bg = SafeParse.stringToDouble(editBg.getText()); final Double bg = SafeParse.stringToDouble(editBg.getText());
final int carbTime = SafeParse.stringToInt(editCarbTime.getText()); final int carbTime = SafeParse.stringToInt(editCarbTime.getText());
final boolean useSuperBolus = superbolusCheckbox.isChecked(); final boolean useSuperBolus = superbolusCheckbox.isChecked();
final String finalNotes = notesEdit.getText().toString();
final AlertDialog.Builder builder = new AlertDialog.Builder(context); final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
@ -363,6 +369,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
detailedBolusInfo.carbTime = carbTime; detailedBolusInfo.carbTime = carbTime;
detailedBolusInfo.boluscalc = boluscalcJSON; detailedBolusInfo.boluscalc = boluscalcJSON;
detailedBolusInfo.source = Source.USER; detailedBolusInfo.source = Source.USER;
detailedBolusInfo.notes = finalNotes;
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
@Override @Override

View file

@ -8,6 +8,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -275,6 +276,9 @@ public class NSUpload {
data.put("boluscalc", detailedBolusInfo.boluscalc); data.put("boluscalc", detailedBolusInfo.boluscalc);
if (detailedBolusInfo.carbTime != 0) if (detailedBolusInfo.carbTime != 0)
data.put("preBolus", detailedBolusInfo.carbTime); data.put("preBolus", detailedBolusInfo.carbTime);
if (!StringUtils.isEmpty(detailedBolusInfo.notes)) {
data.put("notes", detailedBolusInfo.notes);
}
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }

View file

@ -122,9 +122,34 @@
</LinearLayout> </LinearLayout>
<LinearLayout
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_height="wrap_content"
android:layout_gravity="center_horizontal"
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/newcarbs_notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<include layout="@layout/mdtp_done_button" /> <include layout="@layout/mdtp_done_button" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>

View file

@ -199,6 +199,32 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/treatments_wizard_notes_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:width="120dp"
android:padding="10dp"
android:text="@string/careportal_newnstreatment_notes_label"
android:textAppearance="@android:style/TextAppearance.Material.Small"
android:textStyle="bold" />
<EditText
android:id="@+id/newcarbs_notes"
android:layout_width="155dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<include layout="@layout/mdtp_done_button" /> <include layout="@layout/mdtp_done_button" />
<View <View