diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 76290678e2..15c775cc42 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -284,13 +284,16 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, .toObservable(EventPreferenceChange.class) .observeOn(Schedulers.io()) .subscribe(event -> { - if ((event.isChanged(getResourceHelper(), R.string.key_omnipod_basal_beeps_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_bolus_beeps_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_tbr_beeps_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_smb_beeps_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_suspend_delivery_button_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_pulse_log_button_enabled)) || - (event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled))) { + if (event.isChanged(getResourceHelper(), R.string.key_omnipod_basal_beeps_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_bolus_beeps_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_tbr_beeps_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_smb_beeps_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_suspend_delivery_button_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_pulse_log_button_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_tbr_sound_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_smb_sound_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled)) { aapsOmnipodManager.reloadSettings(); } else if (event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_enabled) || event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_hours_before_shutdown) || diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java index 557e8352db..a780f11b5c 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodStorageKeys.java @@ -17,6 +17,9 @@ public class OmnipodStorageKeys { public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = R.string.key_omnipod_expiration_reminder_hours_before_shutdown; public static final int LOW_RESERVOIR_ALERT_ENABLED = R.string.key_omnipod_low_reservoir_alert_enabled; public static final int LOW_RESERVOIR_ALERT_UNITS = R.string.key_omnipod_low_reservoir_alert_units; + public static final int NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_tbr_sound_enabled; + public static final int NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_smb_sound_enabled; + public static final int NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED = R.string.key_omnipod_notification_uncertain_bolus_sound_enabled; } public static class Statistics { 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 9a2956792d..bf51916268 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 @@ -56,13 +56,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.Activati import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CommandFailedAfterChangingDeliveryStatusException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.CrcMismatchException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.DeliveryStatusVerificationFailedException; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalDeliveryStatusException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageAddressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalMessageSequenceNumberException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPacketTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalPodProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalResponseException; -import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalActivationProgressException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.IllegalVersionResponseTypeException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.MessageDecodingException; import info.nightscout.androidaps.plugins.pump.omnipod.driver.exception.NonceOutOfSyncException; @@ -110,6 +110,9 @@ public class AapsOmnipodManager { private boolean suspendDeliveryButtonEnabled; private boolean pulseLogButtonEnabled; private boolean timeChangeEventEnabled; + private boolean notificationUncertainTbrSoundEnabled; + private boolean notificationUncertainSmbSoundEnabled; + private boolean notificationUncertainBolusSoundEnabled; @Inject public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService, @@ -152,6 +155,9 @@ public class AapsOmnipodManager { suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false); pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false); timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true); + notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, true); + notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true); + notificationUncertainBolusSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED, true); } public PumpEnactResult initializePod() { @@ -349,9 +355,9 @@ public class AapsOmnipodManager { if (OmnipodManager.CommandDeliveryStatus.UNCERTAIN_FAILURE.equals(bolusCommandResult.getCommandDeliveryStatus())) { // For safety reasons, we treat this as a bolus that has successfully been delivered, in order to prevent insulin overdose if (detailedBolusInfo.isSMB) { - showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain_smb, detailedBolusInfo.insulin), Notification.URGENT, R.raw.boluserror); + 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, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_bolus_failed_uncertain), Notification.URGENT, isNotificationUncertainBolusSoundEnabled() ? R.raw.boluserror : null); } } @@ -469,7 +475,7 @@ public class AapsOmnipodManager { note = getStringResource(R.string.omnipod_error_set_temp_basal_failed_old_tbr_might_be_cancelled); addFailureToHistory(PodHistoryEntryType.SET_TEMPORARY_BASAL, errorMessage); } - showNotification(note, Notification.URGENT, R.raw.boluserror); + showNotification(note, Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); } catch (Exception ex) { @@ -493,7 +499,7 @@ public class AapsOmnipodManager { executeCommand(() -> delegate.cancelTemporaryBasal(isTbrBeepsEnabled())); } catch (Exception ex) { if (ex instanceof OmnipodException && !((OmnipodException) ex).isCertainFailure()) { - showNotification(getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, R.raw.boluserror); + showNotification(getStringResource(R.string.omnipod_error_cancel_temp_basal_failed_uncertain), Notification.URGENT, isNotificationUncertainTbrSoundEnabled() ? R.raw.boluserror : null); } String errorMessage = translateException(ex); addFailureToHistory(PodHistoryEntryType.CANCEL_TEMPORARY_BASAL, errorMessage); @@ -611,6 +617,18 @@ public class AapsOmnipodManager { return timeChangeEventEnabled; } + public boolean isNotificationUncertainTbrSoundEnabled() { + return notificationUncertainTbrSoundEnabled; + } + + public boolean isNotificationUncertainSmbSoundEnabled() { + return notificationUncertainSmbSoundEnabled; + } + + public boolean isNotificationUncertainBolusSoundEnabled() { + return notificationUncertainBolusSoundEnabled; + } + public void addBolusToHistory(DetailedBolusInfo originalDetailedBolusInfo) { DetailedBolusInfo detailedBolusInfo = originalDetailedBolusInfo.copy(); diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index befc1d8233..52f9eeabc9 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -15,6 +15,9 @@ AAPS.Omnipod.expiration_reminder_hours_before_shutdown AAPS.Omnipod.low_reservoir_alert_enabled AAPS.Omnipod.low_reservoir_alert_units + AAPS.Omnipod.notification_uncertain_tbr_sound_enabled + AAPS.Omnipod.notification_uncertain_smb_sound_enabled + AAPS.Omnipod.notification_uncertain_bolus_sound_enabled AAPS.Omnipod.tbrs_set AAPS.Omnipod.std_boluses_delivered AAPS.Omnipod.smb_boluses_delivered @@ -42,10 +45,14 @@ Hours before shutdown Low reservoir alert enabled Number of units + Enable sound for uncertain TBR notifications + Enable sound for uncertain SMB notifications + Enable sound for uncertain bolus notifications RileyLink Other Alerts Confirmation beeps + Notifications No active Pod diff --git a/omnipod/src/main/res/xml/pref_omnipod.xml b/omnipod/src/main/res/xml/pref_omnipod.xml index 5e0ce96ea4..30367f2c7c 100644 --- a/omnipod/src/main/res/xml/pref_omnipod.xml +++ b/omnipod/src/main/res/xml/pref_omnipod.xml @@ -74,6 +74,25 @@ + + + + + + + + + +