Merge pull request #872 from triplem/notes_wizard

Notes wizard
This commit is contained in:
Milos Kozak 2018-04-12 21:17:33 +02:00 committed by GitHub
commit 7fafd59a5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 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;
}

View file

@ -18,6 +18,7 @@ import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
@ -69,6 +70,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
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;
@ -157,6 +160,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
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;
@ -358,6 +363,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
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));
@ -416,6 +422,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
detailedBolusInfo.context = context;
detailedBolusInfo.source = Source.USER;
detailedBolusInfo.notes = finalNotes;
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) {
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
@Override

View file

@ -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

View file

@ -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);
}

View file

@ -122,9 +122,34 @@
</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" />
</LinearLayout>
</ScrollView>
</FrameLayout>

View file

@ -199,6 +199,32 @@
</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" />
<View