diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java
index a7ef33c786..1c81ebbce9 100644
--- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java
+++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.java
@@ -73,6 +73,7 @@ public class Notification {
public static final int CARBS_REQUIRED = 60;
public static final int OMNIPOD_POD_SUSPENDED = 61;
public static final int OMNIPOD_POD_ALERTS_UPDATED = 62;
+ public static final int OMNIPOD_POD_ALERTS = 63;
public static final int IMPORTANCE_HIGH = 2;
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 96cba0fd57..70e7902ef2 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
@@ -9,6 +9,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.SystemClock;
+import android.text.TextUtils;
import androidx.annotation.NonNull;
@@ -74,12 +75,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.acti
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration;
+import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.util.TimeUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.manager.AapsOmnipodManager;
+import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandAcknowledgeAlerts;
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandHandleTimeChange;
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand;
@@ -88,6 +91,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.service.RileyLi
import info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment;
import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodAlertUtil;
+import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.DecimalFormatter;
@@ -241,11 +245,29 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null);
}
+ AlertSet activeAlerts = podStateManager.getActiveAlerts();
+ if (aapsOmnipodManager.isAutomaticallyAcknowledgeAlertsEnabled() && activeAlerts.size() > 0 && !getCommandQueue().isCustomCommandInQueue(CommandAcknowledgeAlerts.class)) {
+ String alerts = TextUtils.join(", ", aapsOmnipodUtil.getTranslatedActiveAlerts(podStateManager));
+ getCommandQueue().customCommand(new CommandAcknowledgeAlerts(), new Callback() {
+ @Override public void run() {
+ if (result != null) {
+ aapsLogger.debug(LTag.PUMP, "Acknowledge alerts result: {} ({})", result.success, result.comment);
+ if (result.success) {
+ Notification notification = new Notification(Notification.OMNIPOD_POD_ALERTS, resourceHelper.gq(R.plurals.omnipod_pod_alerts, activeAlerts.size(), alerts), Notification.URGENT);
+ rxBus.send(new EventNewNotification(notification));
+ }
+ }
+ }
+ });
+ }
+
doPodCheck();
loopHandler.postDelayed(this, STATUS_CHECK_INTERVAL_MILLIS);
}
- };
+ }
+
+ ;
}
@Override
@@ -294,7 +316,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
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)) {
+ event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled) ||
+ event.isChanged(getResourceHelper(), R.string.key_omnipod_automatically_acknowledge_alerts_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 a780f11b5c..5a373177fe 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
@@ -20,6 +20,7 @@ public class OmnipodStorageKeys {
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 final int AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED = R.string.key_omnipod_automatically_acknowledge_alerts_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 1f7ee22885..efee56da0c 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
@@ -113,6 +113,7 @@ public class AapsOmnipodManager {
private boolean notificationUncertainTbrSoundEnabled;
private boolean notificationUncertainSmbSoundEnabled;
private boolean notificationUncertainBolusSoundEnabled;
+ private boolean automaticallyAcknowledgeAlertsEnabled;
@Inject
public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService,
@@ -158,6 +159,7 @@ public class AapsOmnipodManager {
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);
+ automaticallyAcknowledgeAlertsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED, false);
}
public PumpEnactResult initializePod() {
@@ -627,6 +629,10 @@ public class AapsOmnipodManager {
return notificationUncertainBolusSoundEnabled;
}
+ public boolean isAutomaticallyAcknowledgeAlertsEnabled() {
+ return automaticallyAcknowledgeAlertsEnabled;
+ }
+
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 7f992218da..e8931ac0cb 100644
--- a/omnipod/src/main/res/values/strings.xml
+++ b/omnipod/src/main/res/values/strings.xml
@@ -15,6 +15,7 @@
AAPS.Omnipod.expiration_reminder_hours_before_shutdown
AAPS.Omnipod.low_reservoir_alert_enabled
AAPS.Omnipod.low_reservoir_alert_units
+ AAPS.Omnipod.automatically_acknowledge_alerts_enabled
AAPS.Omnipod.notification_uncertain_tbr_sound_enabled
AAPS.Omnipod.notification_uncertain_smb_sound_enabled
AAPS.Omnipod.notification_uncertain_bolus_sound_enabled
@@ -88,6 +89,7 @@
Warning
RileyLink address invalid.
Operation is not possible.\n\nYou need to configure Omnipod first, before you can use this operation.
+ No active Pod
No active Pod
An unexpected error occurred. Please report! (%1$s: %2$s).
Communication failed: message integrity verification failed
@@ -154,7 +156,7 @@
Set basal schedule
Get Pod status
Get Pod info
- Set time
+ Se\t time
Configure alerts
Acknowledge alerts
Suspend delivery
@@ -253,6 +255,7 @@
Less than a minute ago
%1$s and %2$s
%1$s ago
+ Automatically acknowledge Pod alerts (uses notifications to show alerts)
- %1$d minute
- %1$d minutes
@@ -265,5 +268,9 @@
- %1$d day
- %1$d days
+
+ - Pod alert: %1$
+ - Pod alerts: %1$s
+
\ No newline at end of file
diff --git a/omnipod/src/main/res/xml/pref_omnipod.xml b/omnipod/src/main/res/xml/pref_omnipod.xml
index 30367f2c7c..cc0d7a33cd 100644
--- a/omnipod/src/main/res/xml/pref_omnipod.xml
+++ b/omnipod/src/main/res/xml/pref_omnipod.xml
@@ -72,6 +72,11 @@
validate:minNumber="5"
validate:testType="numericRange" />
+
+