Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ object BolusProgressData {
bolusEnded = false
stopPressed = false
status = ""
wearStatus = ""
percent = 0
}

Expand Down Expand Up @@ -48,6 +49,7 @@ object BolusProgressData {
* Last received status update
*/
var status = ""
var wearStatus = ""
var percent = 0

var bolusEnded = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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)
)

/**
Expand All @@ -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)
)
}
1 change: 1 addition & 0 deletions core/interfaces/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<resources>
<!-- Events-->
<string name="bolus_delivering">Delivering %1$.2fU</string>
<string name="bolus_delivered_so_far">%1$.2fU / %2$.2fU delivered</string>
<string name="bolus_delivered_successfully">Bolus %1$.2fU delivered successfully</string>

<!-- PumpPluginBase -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -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
Expand Down
Loading