Merge remote-tracking branch 'origin/dev' into carbs-gen-pr
* origin/dev: Adding notes to carbs and to wizard on overview
This commit is contained in:
commit
4acf0c713a
6 changed files with 75 additions and 3 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.Overview.Dialogs;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -16,6 +17,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.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
|
@ -54,6 +56,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
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;
|
||||||
|
@ -155,6 +159,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
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;
|
||||||
|
@ -337,6 +343,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
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();
|
||||||
|
|
||||||
long timeOffset = editTime.getValue().longValue();
|
long timeOffset = editTime.getValue().longValue();
|
||||||
final long time = DateUtil.now() + timeOffset * 1000 * 60;
|
final long time = DateUtil.now() + timeOffset * 1000 * 60;
|
||||||
|
@ -388,14 +395,14 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
|
|
||||||
if (carbsAfterConstraints > 0) {
|
if (carbsAfterConstraints > 0) {
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
createCarb(carbsAfterConstraints, time);
|
createCarb(carbsAfterConstraints, time, finalNotes);
|
||||||
} else {
|
} else {
|
||||||
long remainingCarbs = carbsAfterConstraints;
|
long remainingCarbs = carbsAfterConstraints;
|
||||||
long carbTime = time;
|
long carbTime = time;
|
||||||
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
|
long smallCarbAmount = Math.round(remainingCarbs / (editDuration.getValue() * 4));
|
||||||
if (smallCarbAmount == 0) smallCarbAmount = 1;
|
if (smallCarbAmount == 0) smallCarbAmount = 1;
|
||||||
while (remainingCarbs > 0) {
|
while (remainingCarbs > 0) {
|
||||||
createCarb(Math.min(smallCarbAmount, remainingCarbs), carbTime);
|
createCarb(Math.min(smallCarbAmount, remainingCarbs), carbTime, finalNotes);
|
||||||
remainingCarbs -= smallCarbAmount;
|
remainingCarbs -= smallCarbAmount;
|
||||||
carbTime += 15 * 60 * 1000;
|
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();
|
DetailedBolusInfo carbInfo = new DetailedBolusInfo();
|
||||||
carbInfo.date = time;
|
carbInfo.date = time;
|
||||||
carbInfo.eventType = CareportalEvent.CARBCORRECTION;
|
carbInfo.eventType = CareportalEvent.CARBCORRECTION;
|
||||||
carbInfo.carbs = carbs;
|
carbInfo.carbs = carbs;
|
||||||
carbInfo.context = getContext();
|
carbInfo.context = getContext();
|
||||||
carbInfo.source = Source.USER;
|
carbInfo.source = Source.USER;
|
||||||
|
carbInfo.notes = notes;
|
||||||
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
|
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
|
||||||
ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -104,6 +105,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;
|
||||||
|
@ -206,6 +209,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);
|
||||||
|
@ -321,6 +326,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));
|
||||||
|
@ -364,6 +370,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
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -276,6 +277,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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,9 +233,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>
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue