disable the suspend Button

This commit is contained in:
Andrei Vereha 2021-11-24 21:43:36 +01:00
parent e903c9c055
commit 1247fded3b
7 changed files with 10 additions and 66 deletions

View file

@ -1092,8 +1092,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
return when (customCommand) {
is CommandSilenceAlerts ->
silenceAlerts()
is CommandSuspendDelivery ->
suspendDelivery()
is CommandResumeDelivery ->
resumeDelivery()
is CommandDeactivatePod ->
@ -1131,17 +1129,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun disableSuspendAlerts(): PumpEnactResult {
val alerts = listOf(
AlertConfiguration(
AlertType.SUSPEND_IN_PROGRESS,
enabled = false,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
0
),
BeepType.XXX,
BeepRepetitionType.XXX4
),
AlertConfiguration(
AlertType.SUSPEND_ENDED,
enabled = false,
@ -1151,7 +1138,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
0
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
),
)
val ret = executeProgrammingCommand(
@ -1164,29 +1151,6 @@ class OmnipodDashPumpPlugin @Inject constructor(
return ret
}
private fun suspendDelivery(): PumpEnactResult {
return executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.SUSPEND_DELIVERY),
command = omnipodManager.suspendDelivery(hasBasalBeepEnabled())
.filter { podEvent -> podEvent.isCommandSent() }
.map {
pumpSyncTempBasal(
0.0,
PodConstants.MAX_POD_LIFETIME.toMinutes(),
PumpSync.TemporaryBasalType.PUMP_SUSPEND
)
}
.ignoreElements(),
pre = observeDeliveryActive(),
).doFinally {
notifyOnUnconfirmed(
Notification.PUMP_ERROR,
"Unconfirmed suspendDelivery command. Please refresh pod status",
R.raw.boluserror
)
}.toPumpEnactResult()
}
private fun observeDeliveryActive(): Completable = Completable.defer {
if (podStateManager.deliveryStatus != DeliveryStatus.SUSPENDED)
Completable.complete()
@ -1289,7 +1253,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
expiryAlertDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
)
)
return executeProgrammingCommand(

View file

@ -437,7 +437,7 @@ class OmnipodDashManagerImpl @Inject constructor(
userExpiryAlertDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
)
)
}

View file

@ -19,27 +19,16 @@ class SuspendDeliveryCommand private constructor(
override val encoded: ByteArray
get() {
val alerts = listOf(
AlertConfiguration(
AlertType.SUSPEND_IN_PROGRESS,
enabled = true,
durationInMinutes = 10,
autoOff = false,
AlertTrigger.TimerTrigger(
1
),
BeepType.XXX,
BeepRepetitionType.XXX4
),
AlertConfiguration(
AlertType.SUSPEND_ENDED,
enabled = true,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
10
20
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
),
)
val programAlerts = ProgramAlertsCommand.Builder()

View file

@ -6,7 +6,7 @@ enum class BeepRepetitionType(
) {
XXX(0x01.toByte()), // Used in lump of coal alert, LOW_RESERVOIR
EVERY_MINUTE(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery
EVERY_MINUTE_AND_EVERY_15_MIN(0x03.toByte()), // Used in USER_SET_EXPIRATION, suspend delivery
XXX3(0x05.toByte()), // published system expiration alert
XXX4(0x06.toByte()), // Used in imminent pod expiration alert, suspend in progress. No repeat?
XXX5(0x08.toByte()); // Lump of coal alert

View file

@ -442,7 +442,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
AlertType.SUSPEND_IN_PROGRESS ->
R.string.omnipod_common_alert_delivery_suspended
AlertType.SUSPEND_ENDED ->
R.string.omnipod_common_alert_delivery_suspended2
R.string.omnipod_common_alert_delivery_suspended
else ->
R.string.omnipod_common_alert_unknown_alert
}
@ -633,17 +633,9 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
private fun updateSuspendDeliveryButton() {
// If the Pod is currently suspended, we show the Resume delivery button instead.
if (isSuspendDeliveryButtonEnabled() &&
podStateManager.isPodRunning &&
(!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))
) {
buttonBinding.buttonSuspendDelivery.visibility = View.VISIBLE
buttonBinding.buttonSuspendDelivery.isEnabled =
podStateManager.isPodRunning && !podStateManager.isSuspended && isQueueEmpty()
} else {
// disable the 'suspendDelivery' button.
buttonBinding.buttonSuspendDelivery.visibility = View.GONE
}
}
private fun updateSetTimeButton() {
if (podStateManager.isActivationCompleted && !podStateManager.sameTimeZone) {

View file

@ -48,5 +48,4 @@
<string name="omnipod_common_history_bolus_value">%1$.2f U</string>
<string name="dash_bolusdelivering">Delivering %1$.2f U</string>
<string name="omnipod_common_alert_delivery_suspended">Insulin delivery is suspended</string>
<string name="omnipod_common_alert_delivery_suspended2">Insulin delivery is suspended 2</string>
</resources>

View file

@ -85,7 +85,7 @@ class ProgramAlertsCommandTest {
false,
AlertTrigger.TimerTrigger(4079.toShort()),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
)
)