From 8564cf172ee26b4a29620f0ac7a5eab687332f4a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 16 Mar 2018 22:09:30 +0100 Subject: [PATCH] Carbs button: send carbs to pump if pump supports carbs. --- .../Overview/Dialogs/NewCarbsDialog.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 1d7279ce6e..6813d5a338 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 @@ -1,6 +1,7 @@ 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.v4.app.DialogFragment; @@ -337,7 +338,23 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D detailedBolusInfo.carbs = finalCarbsAfterConstraints; detailedBolusInfo.context = context; detailedBolusInfo.source = Source.USER; - MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); + if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { + ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { + @Override + public void run() { + if (!result.success) { + Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); + i.putExtra("soundid", R.raw.boluserror); + i.putExtra("status", result.comment); + i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + MainApp.instance().startActivity(i); + } + } + }); + } else { + MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); + } } } });