Use error dialog instead of notification for user-enacted boluses

This commit is contained in:
Bart Sopers 2020-11-20 19:10:21 +01:00
parent f0765a6704
commit 1eedf86fa1

View file

@ -1,5 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.manager; 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.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.json.JSONException; import org.json.JSONException;
@ -14,6 +17,7 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import dagger.android.HasAndroidInjector; import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
@ -102,6 +106,7 @@ public class AapsOmnipodManager {
private final OmnipodAlertUtil omnipodAlertUtil; private final OmnipodAlertUtil omnipodAlertUtil;
private final NSUpload nsUpload; private final NSUpload nsUpload;
private final ProfileFunction profileFunction; private final ProfileFunction profileFunction;
private final Context context;
private boolean basalBeepsEnabled; private boolean basalBeepsEnabled;
private boolean bolusBeepsEnabled; private boolean bolusBeepsEnabled;
@ -128,8 +133,9 @@ public class AapsOmnipodManager {
DatabaseHelperInterface databaseHelper, DatabaseHelperInterface databaseHelper,
OmnipodAlertUtil omnipodAlertUtil, OmnipodAlertUtil omnipodAlertUtil,
NSUpload nsUpload, NSUpload nsUpload,
ProfileFunction profileFunction ProfileFunction profileFunction,
) { Context context) {
this.podStateManager = podStateManager; this.podStateManager = podStateManager;
this.aapsOmnipodUtil = aapsOmnipodUtil; this.aapsOmnipodUtil = aapsOmnipodUtil;
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
@ -142,6 +148,7 @@ public class AapsOmnipodManager {
this.omnipodAlertUtil = omnipodAlertUtil; this.omnipodAlertUtil = omnipodAlertUtil;
this.nsUpload = nsUpload; this.nsUpload = nsUpload;
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
this.context = context;
delegate = new OmnipodManager(aapsLogger, communicationService, podStateManager); delegate = new OmnipodManager(aapsLogger, communicationService, podStateManager);
@ -357,7 +364,7 @@ public class AapsOmnipodManager {
if (detailedBolusInfo.isSMB) { if (detailedBolusInfo.isSMB) {
showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null); showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, isNotificationUncertainSmbSoundEnabled() ? R.raw.boluserror : null);
} else { } 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); 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) { private void showPodFaultNotification(FaultEventCode faultEventCode) {
showPodFaultNotification(faultEventCode, R.raw.boluserror); showPodFaultNotification(faultEventCode, R.raw.boluserror);
} }