Merge pull request #28 from AAPS-Omnipod/omnipod_eros_dev_configurable_notification_sounds
Make sounds for Omnipod uncertain SMB & TBR notifications configurable
This commit is contained in:
commit
f21a053dfc
5 changed files with 62 additions and 12 deletions
|
@ -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) ||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
<string name="key_omnipod_expiration_reminder_hours_before_shutdown" translatable="false">AAPS.Omnipod.expiration_reminder_hours_before_shutdown</string>
|
||||
<string name="key_omnipod_low_reservoir_alert_enabled" translatable="false">AAPS.Omnipod.low_reservoir_alert_enabled</string>
|
||||
<string name="key_omnipod_low_reservoir_alert_units" translatable="false">AAPS.Omnipod.low_reservoir_alert_units</string>
|
||||
<string name="key_omnipod_notification_uncertain_tbr_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_tbr_sound_enabled</string>
|
||||
<string name="key_omnipod_notification_uncertain_smb_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_smb_sound_enabled</string>
|
||||
<string name="key_omnipod_notification_uncertain_bolus_sound_enabled" translatable="false">AAPS.Omnipod.notification_uncertain_bolus_sound_enabled</string>
|
||||
<string name="key_omnipod_tbrs_set" translatable="false">AAPS.Omnipod.tbrs_set</string>
|
||||
<string name="key_omnipod_std_boluses_delivered" translatable="false">AAPS.Omnipod.std_boluses_delivered</string>
|
||||
<string name="key_omnipod_smb_boluses_delivered" translatable="false">AAPS.Omnipod.smb_boluses_delivered</string>
|
||||
|
@ -42,10 +45,14 @@
|
|||
<string name="omnipod_config_expiration_reminder_hours_before_shutdown">Hours before shutdown</string>
|
||||
<string name="omnipod_config_low_reservoir_alert_enabled">Low reservoir alert enabled</string>
|
||||
<string name="omnipod_config_low_reservoir_alert_units">Number of units</string>
|
||||
<string name="omnipod_config_notification_uncertain_tbr_sound_enabled">Sound for uncertain TBR notifications enabled</string>
|
||||
<string name="omnipod_config_notification_uncertain_smb_sound_enabled">Sound for uncertain SMB notifications enabled</string>
|
||||
<string name="omnipod_config_notification_uncertain_bolus_sound_enabled">Sound for uncertain bolus notifications enabled</string>
|
||||
<string name="omnipod_preference_category_rileylink">RileyLink</string>
|
||||
<string name="omnipod_preference_category_other">Other</string>
|
||||
<string name="omnipod_preference_category_alerts">Alerts</string>
|
||||
<string name="omnipod_preference_category_confirmation_beeps">Confirmation beeps</string>
|
||||
<string name="omnipod_preference_category_notifications">Notifications</string>
|
||||
|
||||
<!-- Omnipod - Pod Status -->
|
||||
<string name="omnipod_pod_status_no_active_pod">No active Pod</string>
|
||||
|
|
|
@ -74,6 +74,25 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/omnipod_preference_category_notifications">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_omnipod_notification_uncertain_tbr_sound_enabled"
|
||||
android:title="@string/omnipod_config_notification_uncertain_tbr_sound_enabled" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_omnipod_notification_uncertain_smb_sound_enabled"
|
||||
android:title="@string/omnipod_config_notification_uncertain_smb_sound_enabled" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_omnipod_notification_uncertain_bolus_sound_enabled"
|
||||
android:title="@string/omnipod_config_notification_uncertain_bolus_sound_enabled" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/omnipod_preference_category_other">
|
||||
|
||||
<SwitchPreference
|
||||
|
|
Loading…
Reference in a new issue