From 86d6fbc615938f6280004578b411f78d48185cc0 Mon Sep 17 00:00:00 2001 From: Artiom Kenibasov Date: Sat, 21 Nov 2020 15:44:32 +0100 Subject: [PATCH 01/13] Added play test beep mechanism --- .../pump/omnipod/OmnipodPumpPlugin.java | 4 ++ .../definition/OmnipodCommandType.java | 3 +- .../definition/PodHistoryEntryType.java | 2 + .../action/ConfigureBeepAction.java | 49 +++++++++++++++++++ .../message/command/BeepConfigCommand.java | 4 -- .../driver/manager/OmnipodManager.java | 19 +++++++ .../omnipod/manager/AapsOmnipodManager.java | 16 ++++++ .../queue/command/CommandPlayTestBeep.java | 16 ++++++ .../command/OmnipodCustomCommandType.java | 4 +- .../pump/omnipod/ui/PodHistoryActivity.java | 7 +++ omnipod/src/main/res/values/strings.xml | 2 + 11 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureBeepAction.java create mode 100644 omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/CommandPlayTestBeep.java 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 06b7c963a5..c7afc04cf1 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 @@ -76,6 +76,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess 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.BeepConfigType; 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.EventOmnipodActiveAlertsChanged; @@ -85,6 +86,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.event.EventOmnipodTbrChan 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.CommandPlayTestBeep; import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.CommandUpdateAlertConfiguration; import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommand; import info.nightscout.androidaps.plugins.pump.omnipod.queue.command.OmnipodCustomCommandType; @@ -794,6 +796,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, return handleTimeChange(((CommandHandleTimeChange) command).isRequestedByUser()); case UPDATE_ALERT_CONFIGURATION: return updateAlertConfiguration(); + case PLAY_TEST_BEEP: + return executeCommand(OmnipodCommandType.PLAY_TEST_BEEP, () -> aapsOmnipodManager.playTestBeep(((CommandPlayTestBeep)command).getBeepType())); default: aapsLogger.warn(LTag.PUMP, "Unknown custom command: " + commandType); return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(resourceHelper.gs(R.string.omnipod_error_unknown_custom_command, commandType)); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java index 8d9b250ac4..7cbc3c8a11 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/OmnipodCommandType.java @@ -21,7 +21,8 @@ public enum OmnipodCommandType { ACKNOWLEDGE_ALERTS(R.string.omnipod_cmd_acknowledge_alerts), // READ_POD_PULSE_LOG(R.string.omnipod_cmd_read_pulse_log), // SUSPEND_DELIVERY(R.string.omnipod_cmd_suspend_delivery), - RESUME_DELIVERY(R.string.omnipod_cmd_resume_delivery); + RESUME_DELIVERY(R.string.omnipod_cmd_resume_delivery), + PLAY_TEST_BEEP(R.string.omnipod_cmd_play_test_beep); private int resourceId; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java index 89560786e0..366e675b20 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/definition/PodHistoryEntryType.java @@ -35,12 +35,14 @@ public enum PodHistoryEntryType { CONFIGURE_ALERTS(50, R.string.omnipod_cmd_configure_alerts, PumpHistoryEntryGroup.Alarm), ACKNOWLEDGE_ALERTS(51, R.string.omnipod_cmd_acknowledge_alerts, PumpHistoryEntryGroup.Alarm), + PLAY_TEST_BEEP(52, R.string.omnipod_cmd_play_test_beep, PumpHistoryEntryGroup.Alarm), SUSPEND_DELIVERY(60, R.string.omnipod_cmd_suspend_delivery, PumpHistoryEntryGroup.Basal), RESUME_DELIVERY(61, R.string.omnipod_cmd_resume_delivery, PumpHistoryEntryGroup.Basal), UNKNOWN_ENTRY_TYPE(99, R.string.omnipod_cmd_unknown_entry); + private int code; private static final Map instanceMap; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureBeepAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureBeepAction.java new file mode 100644 index 0000000000..f75c2b652c --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/ConfigureBeepAction.java @@ -0,0 +1,49 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action; + +import org.joda.time.Duration; + +import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.BeepConfigCommand; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager; +import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.manager.OmnipodRileyLinkCommunicationManager; + +public class ConfigureBeepAction implements OmnipodAction { + private final PodStateManager podStateManager; + private final BeepConfigType beepType; + private final boolean basalCompletionBeep; + private final Duration basalIntervalBeep; + private final boolean tempBasalCompletionBeep; + private final Duration tempBasalIntervalBeep; + private final boolean bolusCompletionBeep; + private final Duration bolusIntervalBeep; + + public ConfigureBeepAction(PodStateManager podState, BeepConfigType beepType, boolean basalCompletionBeep, Duration basalIntervalBeep, boolean tempBasalCompletionBeep, Duration tempBasalIntervalBeep, boolean bolusCompletionBeep, Duration bolusIntervalBeep) { + if (podState == null || beepType == null) { + throw new IllegalArgumentException("Pod state manager cannot be null"); + } + + this.beepType = beepType; + this.basalCompletionBeep = basalCompletionBeep; + this.basalIntervalBeep = basalIntervalBeep; + this.tempBasalCompletionBeep = tempBasalCompletionBeep; + this.tempBasalIntervalBeep = tempBasalIntervalBeep; + this.bolusCompletionBeep = bolusCompletionBeep; + this.bolusIntervalBeep = bolusIntervalBeep; + this.podStateManager = podState; + } + + + public ConfigureBeepAction(PodStateManager podState, BeepConfigType beepType) { + this(podState, beepType, false, Duration.ZERO, false, Duration.ZERO, false, Duration.ZERO); + } + + @Override + public StatusResponse execute(OmnipodRileyLinkCommunicationManager communicationService) { + return communicationService.sendCommand( + StatusResponse.class, podStateManager + , new BeepConfigCommand(beepType, basalCompletionBeep, basalIntervalBeep, + tempBasalCompletionBeep, tempBasalIntervalBeep, + bolusCompletionBeep, bolusIntervalBeep)); + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BeepConfigCommand.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BeepConfigCommand.java index fc36e68eab..47cf4533ba 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BeepConfigCommand.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/message/command/BeepConfigCommand.java @@ -30,10 +30,6 @@ public class BeepConfigCommand extends MessageBlock { encode(); } - public BeepConfigCommand(BeepConfigType beepType) { - this(beepType, false, Duration.ZERO, false, Duration.ZERO, false, Duration.ZERO); - } - private void encode() { encodedData = new byte[]{beepType.getValue()}; encodedData = ByteUtil.concat(encodedData, (byte) ((basalCompletionBeep ? (1 << 6) : 0) + (basalIntervalBeep.getStandardMinutes() & 0x3f))); diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java index 7158e9f98d..d4cf973d15 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/manager/OmnipodManager.java @@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.acti import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.BolusAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.CancelDeliveryAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.ConfigureAlertsAction; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.ConfigureBeepAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.DeactivatePodAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.GetPodInfoAction; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.action.GetStatusAction; @@ -33,6 +34,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse; 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.BeepConfigType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType; @@ -427,6 +429,23 @@ public class OmnipodManager { podStateManager.discardState(); } + public synchronized void configureBeeps(BeepConfigType beepType, boolean basalCompletionBeep, Duration basalIntervalBeep, + boolean tempBasalCompletionBeep, Duration tempBasalIntervalBeep, + boolean bolusCompletionBeep, Duration bolusIntervalBeep) { + if (!podStateManager.isPodInitialized()) { + throw new IllegalPodProgressException(PodProgressStatus.REMINDER_INITIALIZED, null); + } + communicationService.executeAction(new ConfigureBeepAction(podStateManager, beepType, false, Duration.ZERO, false, Duration.ZERO, false, Duration.ZERO)); + } + + public synchronized void playTestBeep(BeepConfigType beepType) { + if (!podStateManager.isPodInitialized()) { + throw new IllegalPodProgressException(PodProgressStatus.REMINDER_INITIALIZED, null); + } + communicationService.executeAction(new ConfigureBeepAction(podStateManager, beepType)); + } + + public OmnipodRileyLinkCommunicationManager getCommunicationService() { return communicationService; } 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 fec5c84cac..9f5333330c 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 @@ -46,6 +46,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoRecentPulseLog; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertConfiguration; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType; @@ -232,6 +233,21 @@ public class AapsOmnipodManager { return new PumpEnactResult(injector).success(true).enacted(false); } + public PumpEnactResult playTestBeep(BeepConfigType beepType) { + try { + executeCommand(() -> delegate.playTestBeep(beepType)); + } catch (Exception ex) { + String errorMessage = translateException(ex); + addFailureToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, errorMessage); + return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage); + } + + addSuccessToHistory(PodHistoryEntryType.PLAY_TEST_BEEP, beepType); + return new PumpEnactResult(injector).success(true).enacted(false); + } + + + public PumpEnactResult getPodStatus() { StatusResponse statusResponse; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/CommandPlayTestBeep.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/CommandPlayTestBeep.java new file mode 100644 index 0000000000..94ff4996c0 --- /dev/null +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/CommandPlayTestBeep.java @@ -0,0 +1,16 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.queue.command; + +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType; + +public class CommandPlayTestBeep extends OmnipodCustomCommand { + private BeepConfigType beepType; + + public CommandPlayTestBeep(BeepConfigType beepType) { + super(OmnipodCustomCommandType.PLAY_TEST_BEEP); + this.beepType = beepType; + } + + public BeepConfigType getBeepType() { + return beepType; + } +} diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/OmnipodCustomCommandType.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/OmnipodCustomCommandType.java index e6df62c47b..ab7cb38b39 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/OmnipodCustomCommandType.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/queue/command/OmnipodCustomCommandType.java @@ -8,7 +8,9 @@ public enum OmnipodCustomCommandType { RESUME_DELIVERY("RESUME DELIVERY"), DEACTIVATE_POD("DEACTIVATE POD"), HANDLE_TIME_CHANGE("HANDLE TIME CHANGE"), - UPDATE_ALERT_CONFIGURATION("UPDATE ALERT CONFIGURATION"); + UPDATE_ALERT_CONFIGURATION("UPDATE ALERT CONFIGURATION"), + PLAY_TEST_BEEP("EMIT BEEP") + ; private final String description; diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java index ff8319a557..74aded32fb 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/PodHistoryActivity.java @@ -35,6 +35,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil; import info.nightscout.androidaps.plugins.pump.omnipod.R; import info.nightscout.androidaps.plugins.pump.omnipod.definition.PodHistoryEntryType; +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType; import info.nightscout.androidaps.plugins.pump.omnipod.util.AapsOmnipodUtil; import info.nightscout.androidaps.utils.resources.ResourceHelper; @@ -272,6 +273,12 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity { } break; + case PLAY_TEST_BEEP: { + if (historyEntry.getData() != null) { + valueView.setText(historyEntry.getData()); + } + } + break; case GET_POD_STATUS: case GET_POD_INFO: case SET_TIME: diff --git a/omnipod/src/main/res/values/strings.xml b/omnipod/src/main/res/values/strings.xml index 6cfea07b2b..6bc4cc2b11 100644 --- a/omnipod/src/main/res/values/strings.xml +++ b/omnipod/src/main/res/values/strings.xml @@ -255,6 +255,8 @@ Less than a minute ago %1$s and %2$s %1$s ago + Beep config + Play test beep %1$d minute %1$d minutes From 3aace47d576f99c08af07bb3d05a984c6d461b1f Mon Sep 17 00:00:00 2001 From: Artiom Kenibasov Date: Sat, 21 Nov 2020 15:58:39 +0100 Subject: [PATCH 02/13] Add beep in the end of canula insertion --- .../driver/communication/action/InsertCannulaAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java index ff47b1b900..a6fdd139d9 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/driver/communication/action/InsertCannulaAction.java @@ -58,7 +58,7 @@ public class InsertCannulaAction implements OmnipodAction { if (podStateManager.getActivationProgress().needsCannulaInsertion()) { communicationService.executeAction(new BolusAction(podStateManager, OmnipodConstants.POD_CANNULA_INSERTION_BOLUS_UNITS, - Duration.standardSeconds(1), false, false)); + Duration.standardSeconds(1), false, true)); podStateManager.setActivationProgress(ActivationProgress.INSERTING_CANNULA); } From 8dc75111d24cc6ee13dbd15d02691e6f5759a295 Mon Sep 17 00:00:00 2001 From: Artiom Kenibasov Date: Sat, 21 Nov 2020 17:12:16 +0100 Subject: [PATCH 03/13] Added test beep button and made rileylink stats optional --- .../pump/omnipod/OmnipodPumpPlugin.java | 2 + .../definition/OmnipodStorageKeys.java | 2 + .../omnipod/manager/AapsOmnipodManager.java | 11 ++++ .../omnipod/ui/OmnipodOverviewFragment.kt | 29 ++++++++++ .../src/main/res/drawable/ic_speaker_icon.xml | 14 +++++ .../src/main/res/layout/omnipod_overview.xml | 58 ++++++++++++------- omnipod/src/main/res/values/strings.xml | 6 ++ omnipod/src/main/res/xml/pref_omnipod.xml | 12 ++++ 8 files changed, 112 insertions(+), 22 deletions(-) create mode 100644 omnipod/src/main/res/drawable/ic_speaker_icon.xml 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 c7afc04cf1..3e6b0bef6c 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 @@ -309,6 +309,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface, 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_rileylink_stats_button_enabled) || + event.isChanged(getResourceHelper(), R.string.key_omnipod_test_beep_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) || 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 5a373177fe..b1e6a2c9be 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 @@ -12,6 +12,7 @@ public class OmnipodStorageKeys { public static final int TBR_BEEPS_ENABLED = R.string.key_omnipod_tbr_beeps_enabled; public static final int SUSPEND_DELIVERY_BUTTON_ENABLED = R.string.key_omnipod_suspend_delivery_button_enabled; public static final int PULSE_LOG_BUTTON_ENABLED = R.string.key_omnipod_pulse_log_button_enabled; + public static final int TEST_BEEP_BUTTON_ENABLED = R.string.key_omnipod_test_beep_button_enabled; public static final int TIME_CHANGE_EVENT_ENABLED = R.string.key_omnipod_time_change_event_enabled; public static final int EXPIRATION_REMINDER_ENABLED = R.string.key_omnipod_expiration_reminder_enabled; public static final int EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN = R.string.key_omnipod_expiration_reminder_hours_before_shutdown; @@ -21,6 +22,7 @@ public class OmnipodStorageKeys { 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 final int RILEYLINK_STATS_BUTTON_ENABLED = R.string.key_omnipod_rileylink_stats_button_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 9f5333330c..65474891e3 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 @@ -115,6 +115,8 @@ public class AapsOmnipodManager { private boolean notificationUncertainSmbSoundEnabled; private boolean notificationUncertainBolusSoundEnabled; private boolean automaticallyAcknowledgeAlertsEnabled; + private boolean testBeepButtonEnabled; + private boolean rileylinkStatsButtonEnabled; @Inject public AapsOmnipodManager(OmnipodRileyLinkCommunicationManager communicationService, @@ -156,6 +158,8 @@ public class AapsOmnipodManager { tbrBeepsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED, true); suspendDeliveryButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED, false); pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false); + testBeepButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TEST_BEEP_BUTTON_ENABLED, true); + rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_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); @@ -629,6 +633,13 @@ public class AapsOmnipodManager { return pulseLogButtonEnabled; } + public boolean isTestBeepButtonEnabled() { + return testBeepButtonEnabled; } + + public boolean isRileylinkStatsButtonEnabled() { + return rileylinkStatsButtonEnabled; + } + public boolean isTimeChangeEventEnabled() { return timeChangeEventEnabled; } diff --git a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodOverviewFragment.kt b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodOverviewFragment.kt index 3fd3b27472..bb9123033a 100644 --- a/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodOverviewFragment.kt +++ b/omnipod/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/ui/OmnipodOverviewFragment.kt @@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin import info.nightscout.androidaps.plugins.pump.omnipod.R import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress +import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.BeepConfigType import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus import info.nightscout.androidaps.plugins.pump.omnipod.driver.manager.PodStateManager @@ -119,6 +120,12 @@ class OmnipodOverviewFragment : DaggerFragment() { DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status), false)) } + omnipod_overview_button_test_beep.setOnClickListener { + disablePodActionButtons() + commandQueue.customCommand(CommandPlayTestBeep(BeepConfigType.BIP_BIP), + DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_play_test_beep), false)) + } + omnipod_overview_button_rileylink_stats.setOnClickListener { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { startActivity(Intent(context, RileyLinkStatusActivity::class.java)) @@ -448,8 +455,11 @@ class OmnipodOverviewFragment : DaggerFragment() { updateSuspendDeliveryButton() updateSetTimeButton() updatePulseLogButton() + updateTestBeepButton() + updateRileylinkStatsButton() } + private fun disablePodActionButtons() { omnipod_overview_button_acknowledge_active_alerts.isEnabled = false omnipod_overview_button_resume_delivery.isEnabled = false @@ -457,6 +467,7 @@ class OmnipodOverviewFragment : DaggerFragment() { omnipod_overview_button_set_time.isEnabled = false omnipod_overview_button_refresh_status.isEnabled = false omnipod_overview_button_pulse_log.isEnabled = false + omnipod_overview_button_test_beep.isEnabled = false } private fun updateRefreshStatusButton() { @@ -510,6 +521,24 @@ class OmnipodOverviewFragment : DaggerFragment() { } } + private fun updateRileylinkStatsButton() { + if (omnipodManager.isRileylinkStatsButtonEnabled) { + omnipod_overview_button_rileylink_stats.visibility = View.VISIBLE + omnipod_overview_button_rileylink_stats.isEnabled = true + } else { + omnipod_overview_button_rileylink_stats.visibility = View.GONE + } + } + + private fun updateTestBeepButton() { + if (omnipodManager.isTestBeepButtonEnabled) { + omnipod_overview_button_test_beep.visibility = View.VISIBLE + omnipod_overview_button_test_beep.isEnabled = podStateManager.isPodActivationCompleted && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty() + } else { + omnipod_overview_button_test_beep.visibility = View.GONE + } + } + private fun displayNotConfiguredDialog() { context?.let { UIRunnable(Runnable { diff --git a/omnipod/src/main/res/drawable/ic_speaker_icon.xml b/omnipod/src/main/res/drawable/ic_speaker_icon.xml new file mode 100644 index 0000000000..e642e65ab3 --- /dev/null +++ b/omnipod/src/main/res/drawable/ic_speaker_icon.xml @@ -0,0 +1,14 @@ + + + + diff --git a/omnipod/src/main/res/layout/omnipod_overview.xml b/omnipod/src/main/res/layout/omnipod_overview.xml index ff36031400..2088ac3e4f 100644 --- a/omnipod/src/main/res/layout/omnipod_overview.xml +++ b/omnipod/src/main/res/layout/omnipod_overview.xml @@ -779,28 +779,6 @@ android:paddingRight="0dp" android:text="@string/omnipod_overview_button_acknowledge_active_alerts" /> -