From 6d90f7952173739bf56c343025883837148762a3 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 22 May 2017 19:14:22 +0200 Subject: [PATCH] also cancel temp on disable loop plugin --- .../androidaps/plugins/Overview/OverviewFragment.java | 9 +++++++++ .../plugins/SmsCommunicator/SmsCommunicatorPlugin.java | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 37fa7bcc50..dedfb3fdf0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -366,6 +366,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, activeloop.setFragmentVisible(PluginBase.LOOP, false); MainApp.getConfigBuilder().storeSettings(); scheduleUpdateGUI("suspendmenu"); + sHandler.post(new Runnable() { + @Override + public void run() { + PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(); + if (!result.success) { + ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror)); + } + } + }); ConfigBuilderPlugin.uploadOpenAPSOffline(60); // upload 60 min, we don;t know real duration return true; } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index a68ff3e6a4..d7020a536d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -277,7 +277,10 @@ public class SmsCommunicatorPlugin implements PluginBase { LoopPlugin loopPlugin = (LoopPlugin) MainApp.getSpecificPlugin(LoopPlugin.class); if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) { loopPlugin.setFragmentEnabled(PluginBase.LOOP, false); - reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled); + PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(); + MainApp.bus().post(new EventRefreshGui(false)); + reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " + + MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } receivedSms.processed = true;