dismiss bolus progress via events
This commit is contained in:
parent
686e16de8d
commit
98edfc57e0
|
@ -52,6 +52,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
|
||||||
|
@ -448,13 +449,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
|
|
||||||
BolusProgressDialog.bolusEnded = true;
|
BolusProgressDialog.bolusEnded = true;
|
||||||
|
|
||||||
if (bolusProgressDialog != null && BolusProgressDialog.running) {
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
|
||||||
try {
|
|
||||||
bolusProgressDialog.dismiss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace(); // TODO: handle this better
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
|
@ -501,13 +496,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
|
|
||||||
BolusProgressDialog.bolusEnded = true;
|
BolusProgressDialog.bolusEnded = true;
|
||||||
|
|
||||||
if (bolusProgressDialog != null && BolusProgressDialog.running) {
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
|
||||||
try {
|
|
||||||
bolusProgressDialog.dismiss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace(); // TODO: handle this better
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.logCongigBuilderActions)
|
if (Config.logCongigBuilderActions)
|
||||||
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
|
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
|
|
||||||
|
@ -127,6 +128,13 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||||
|
if(BolusProgressDialog.running){
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package info.nightscout.androidaps.plugins.Overview.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 20/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventDismissBolusprogressIfRunning {
|
||||||
|
public final PumpEnactResult result;
|
||||||
|
|
||||||
|
public EventDismissBolusprogressIfRunning(PumpEnactResult result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
|
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
@ -177,6 +178,20 @@ public class WearPlugin implements PluginBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||||
|
String status;
|
||||||
|
if(ev.result.success){
|
||||||
|
status = MainApp.sResources.getString(R.string.success);
|
||||||
|
} else {
|
||||||
|
status = MainApp.sResources.getString(R.string.nosuccess);
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
|
||||||
|
intent.putExtra("progresspercent", 100);
|
||||||
|
intent.putExtra("progressstatus", status);
|
||||||
|
ctx.startService(intent);
|
||||||
|
}
|
||||||
|
|
||||||
public void requestActionConfirmation(String title, String message, String actionstring){
|
public void requestActionConfirmation(String title, String message, String actionstring){
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);
|
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);
|
||||||
|
|
|
@ -540,4 +540,5 @@
|
||||||
<string name="wear_settings">Wear settings</string>
|
<string name="wear_settings">Wear settings</string>
|
||||||
<string name="wear_detailedIOB_title">Show detailed IOB</string>
|
<string name="wear_detailedIOB_title">Show detailed IOB</string>
|
||||||
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
|
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
|
||||||
|
<string name="nosuccess">not successful - please check phone</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue