From 8dc75111d24cc6ee13dbd15d02691e6f5759a295 Mon Sep 17 00:00:00 2001 From: Artiom Kenibasov Date: Sat, 21 Nov 2020 17:12:16 +0100 Subject: [PATCH] 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" /> -