From 1eedf86fa1f64ea04146627b32766c3ef0b9071d Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Fri, 20 Nov 2020 19:10:21 +0100 Subject: [PATCH] Use error dialog instead of notification for user-enacted boluses --- .../omnipod/manager/AapsOmnipodManager.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java index 7eadeb8686..f430dcca4e 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/manager/AapsOmnipodManager.java @@ -1,5 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.manager; +import android.content.Context; +import android.content.Intent; + import org.joda.time.DateTime; import org.joda.time.Duration; import org.json.JSONException; @@ -14,6 +17,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import dagger.android.HasAndroidInjector; +import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; @@ -102,6 +106,7 @@ public class AapsOmnipodManager { private final OmnipodAlertUtil omnipodAlertUtil; private final NSUpload nsUpload; private final ProfileFunction profileFunction; + private final Context context; private boolean basalBeepsEnabled; private boolean bolusBeepsEnabled; @@ -128,8 +133,9 @@ public class AapsOmnipodManager { DatabaseHelperInterface databaseHelper, OmnipodAlertUtil omnipodAlertUtil, NSUpload nsUpload, - ProfileFunction profileFunction - ) { + ProfileFunction profileFunction, + Context context) { + this.podStateManager = podStateManager; this.aapsOmnipodUtil = aapsOmnipodUtil; this.aapsLogger = aapsLogger; @@ -142,6 +148,7 @@ public class AapsOmnipodManager { this.omnipodAlertUtil = omnipodAlertUtil; this.nsUpload = nsUpload; this.profileFunction = profileFunction; + this.context = context; delegate = new OmnipodManager(aapsLogger, communicationService, podStateManager); @@ -357,7 +364,7 @@ public class AapsOmnipodManager { if (detailedBolusInfo.isSMB) { showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null); } else { - showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain), Notification.URGENT, isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : null); + showErrorDialog(getStringResource(R.string.omnipod_error_bolus_failed_uncertain), isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : null); } } @@ -854,6 +861,15 @@ public class AapsOmnipodManager { rxBus.send(event); } + private void showErrorDialog(String message, Integer sound) { + Intent intent = new Intent(context, ErrorHelperActivity.class); + intent.putExtra("soundid", sound); + intent.putExtra("status", message); + intent.putExtra("title", resourceHelper.gs(R.string.error)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(intent); + } + private void showPodFaultNotification(FaultEventCode faultEventCode) { showPodFaultNotification(faultEventCode, R.raw.boluserror); }