diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/pump/BolusProgressData.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/pump/BolusProgressData.kt index b6c796a2fb4..30d590b5660 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/pump/BolusProgressData.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/pump/BolusProgressData.kt @@ -20,6 +20,7 @@ object BolusProgressData { bolusEnded = false stopPressed = false status = "" + wearStatus = "" percent = 0 } @@ -48,6 +49,7 @@ object BolusProgressData { * Last received status update */ var status = "" + var wearStatus = "" var percent = 0 var bolusEnded = false diff --git a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/events/EventOverviewBolusProgress.kt b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/events/EventOverviewBolusProgress.kt index 3e33b7f45f7..a86339558fa 100644 --- a/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/events/EventOverviewBolusProgress.kt +++ b/core/interfaces/src/main/kotlin/app/aaps/core/interfaces/rx/events/EventOverviewBolusProgress.kt @@ -8,12 +8,13 @@ import kotlin.math.min /** * Custom status message and percent */ -class EventOverviewBolusProgress(status: String, val id: Long? = null, percent: Int? = null) : Event() { +class EventOverviewBolusProgress(status: String, val id: Long? = null, percent: Int? = null, wearStatus: String? = null) : Event() { init { if (id == BolusProgressData.id || id == null) { BolusProgressData.status = status percent?.let { BolusProgressData.percent = it } + BolusProgressData.wearStatus = wearStatus ?: status } } @@ -22,9 +23,10 @@ class EventOverviewBolusProgress(status: String, val id: Long? = null, percent: */ constructor(rh: ResourceHelper, delivered: Double, id: Long? = null) : this( - rh.gs(R.string.bolus_delivering, delivered), + status = rh.gs(R.string.bolus_delivering, delivered), id = id, - percent = min((delivered / BolusProgressData.insulin * 100).toInt(), 100) + percent = min((delivered / BolusProgressData.insulin * 100).toInt(), 100), + wearStatus = rh.gs(R.string.bolus_delivered_so_far, delivered, BolusProgressData.insulin) ) /** @@ -37,6 +39,9 @@ class EventOverviewBolusProgress(status: String, val id: Long? = null, percent: if (percent == 100) rh.gs(R.string.bolus_delivered_successfully, BolusProgressData.insulin) else rh.gs(R.string.bolus_delivering, BolusProgressData.insulin * percent / 100.0), id = id, - percent = min(percent, 100) - ) + percent = min(percent, 100), + wearStatus = + if (percent == 100) rh.gs(R.string.bolus_delivered_successfully, BolusProgressData.insulin) + else rh.gs(R.string.bolus_delivered_so_far, BolusProgressData.insulin * percent / 100.0, BolusProgressData.insulin) + ) } \ No newline at end of file diff --git a/core/interfaces/src/main/res/values/strings.xml b/core/interfaces/src/main/res/values/strings.xml index 486268e11dd..379ca57538e 100644 --- a/core/interfaces/src/main/res/values/strings.xml +++ b/core/interfaces/src/main/res/values/strings.xml @@ -2,6 +2,7 @@ Delivering %1$.2fU + %1$.2fU / %2$.2fU delivered Bolus %1$.2fU delivered successfully diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt index bed229d395c..8167b0dc542 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/wear/WearPlugin.kt @@ -91,7 +91,7 @@ class WearPlugin @Inject constructor( .observeOn(aapsSchedulers.io) .subscribe({ event: EventOverviewBolusProgress -> if (!BolusProgressData.isSMB || preferences.get(BooleanKey.WearNotifyOnSmb)) { - if (isEnabled()) rxBus.send(EventMobileToWear(EventData.BolusProgress(percent = BolusProgressData.percent, status = BolusProgressData.status))) + if (isEnabled()) rxBus.send(EventMobileToWear(EventData.BolusProgress(percent = BolusProgressData.percent, status = BolusProgressData.wearStatus))) } }, fabricPrivacy::logException) disposable += rxBus diff --git a/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index 0aa93b79d9f..14439107a12 100644 --- a/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -700,10 +700,7 @@ class OmnipodDashPumpPlugin @Inject constructor( continue } val percent = (waited.toFloat() / estimatedDeliveryTimeSeconds) * 100 - updateBolusProgressDialog( - rh.gs(app.aaps.core.interfaces.R.string.bolus_delivering, Round.roundTo(percent * requestedBolusAmount / 100, PodConstants.POD_PULSE_BOLUS_UNITS)), - percent.toInt() - ) + rxBus.send(EventOverviewBolusProgress(rh, percent = percent.toInt())) } (1..BOLUS_RETRIES).forEach { tryNumber -> @@ -731,10 +728,7 @@ class OmnipodDashPumpPlugin @Inject constructor( // delivery not complete yet val remainingUnits = podStateManager.lastBolus!!.bolusUnitsRemaining val percent = ((requestedBolusAmount - remainingUnits) / requestedBolusAmount) * 100 - updateBolusProgressDialog( - rh.gs(app.aaps.core.interfaces.R.string.bolus_delivering, Round.roundTo(requestedBolusAmount - remainingUnits, PodConstants.POD_PULSE_BOLUS_UNITS)), - percent.toInt() - ) + rxBus.send(EventOverviewBolusProgress(rh, percent = percent.toInt())) val sleepSeconds = if (bolusCanceled) BOLUS_RETRY_INTERVAL_MS