diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt index 5ce3028b0c..5e6e00d015 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/insulin/program/util/ProgramBasalUtil.kt @@ -189,7 +189,7 @@ object ProgramBasalUtil { return pulsesPerSlot } - fun calculateCurrentSlot(pulsesPerSlot: ShortArray?, currentTime: Date?): CurrentSlot { + fun calculateCurrentSlot(pulsesPerSlot: ShortArray?, currentTime: Date): CurrentSlot { val instance = Calendar.getInstance() instance.time = currentTime val hourOfDay = instance[Calendar.HOUR_OF_DAY] @@ -205,7 +205,7 @@ object ProgramBasalUtil { fun calculateCurrentLongInsulinProgramElement( elements: List, - currentTime: Date? + currentTime: Date ): CurrentBasalInsulinProgramElement { val instance = Calendar.getInstance() instance.time = currentTime diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index dfce49f4bf..371df19101 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -13,6 +13,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.Constants import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.events.EventPreferenceChange +import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -206,6 +207,16 @@ class OmnipodDashOverviewFragment : DaggerFragment() { }, fabricPrivacy::logException ) + + disposables += rxBus + .toObservable(EventPumpStatusChanged::class.java) + .observeOn(aapsSchedulers.main) + .subscribe( + { + updateBluetoothConnectionStatus(it) + }, + fabricPrivacy::logException + ) updateUi() } @@ -231,18 +242,13 @@ class OmnipodDashOverviewFragment : DaggerFragment() { updateQueueStatus() } + private fun updateBluetoothConnectionStatus(event: EventPumpStatusChanged) { + bluetoothStatusBinding.omnipodDashBluetoothStatus.text = event.getStatus(resourceHelper) + } + private fun updateBluetoothStatus() { bluetoothStatusBinding.omnipodDashBluetoothAddress.text = podStateManager.bluetoothAddress ?: PLACEHOLDER - bluetoothStatusBinding.omnipodDashBluetoothStatus.text = - when (podStateManager.bluetoothConnectionState) { - OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTED -> - "{fa-bluetooth}" - OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED -> - "{fa-bluetooth-b}" - OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING -> - "{fa-bluetooth-b spin}" - } val connectionSuccessPercentage = podStateManager.connectionSuccessRatio() * 100 val successPercentageString = String.format("%.2f %%", connectionSuccessPercentage) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt index 782157be74..a6faa187f4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInitializePodViewModel.kt @@ -40,7 +40,7 @@ class DashInitializePodViewModel @Inject constructor( } else null - val disposable = omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy( + omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy( onNext = { podEvent -> logger.debug( LTag.PUMP, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt index 9d39d434ed..9a3530f443 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt @@ -63,7 +63,7 @@ class DashInsertCannulaViewModel @Inject constructor( else null - val disposable = omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy( + omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy( onNext = { podEvent -> logger.debug( LTag.PUMP,