Merge branch 'omnipod_eros_dev' into omnipod_eros_dev_remove_omnipod_pump_state

This commit is contained in:
Bart Sopers 2020-08-23 13:07:10 +02:00
commit 219b1e02ba
3 changed files with 57 additions and 34 deletions

View file

@ -143,8 +143,6 @@ class OmnipodFragment : DaggerFragment() {
}) })
} }
} }
omnipod_lastconnection.setTextColor(Color.WHITE)
} }
override fun onResume() { override fun onResume() {
@ -219,6 +217,7 @@ class OmnipodFragment : DaggerFragment() {
fun updateOmipodUiElements() { fun updateOmipodUiElements() {
updateLastConnectionUiElements() updateLastConnectionUiElements()
updateAcknowledgeAlertsUiElements() updateAcknowledgeAlertsUiElements()
updatePodStatusUiElements()
setVisibilityOfPodDebugButton() setVisibilityOfPodDebugButton()
val errors = ArrayList<String>(); val errors = ArrayList<String>();
@ -242,11 +241,6 @@ class OmnipodFragment : DaggerFragment() {
omnipod_tempbasal.text = "-" omnipod_tempbasal.text = "-"
omnipod_lastbolus.text = "-" omnipod_lastbolus.text = "-"
omnipod_lastconnection.setTextColor(Color.WHITE) omnipod_lastconnection.setTextColor(Color.WHITE)
if (podStateManager.hasPodState()) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_not_initalized)
} else {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_pod_connected)
}
} else { } else {
omnipod_pod_address.text = podStateManager.address.toString() omnipod_pod_address.text = podStateManager.address.toString()
omnipod_pod_lot.text = podStateManager.lot.toString() omnipod_pod_lot.text = podStateManager.lot.toString()
@ -255,26 +249,11 @@ class OmnipodFragment : DaggerFragment() {
val expiresAt = podStateManager.expiresAt val expiresAt = podStateManager.expiresAt
omnipod_pod_expiry.text = if (expiresAt == null) "???" else dateUtil.dateAndTimeString(expiresAt.toDate()) omnipod_pod_expiry.text = if (expiresAt == null) "???" else dateUtil.dateAndTimeString(expiresAt.toDate())
val stateText: String if (podStateManager.hasFaultEvent()) {
when {
podStateManager.hasFaultEvent() -> {
val faultEventCode = podStateManager.faultEvent.faultEventCode val faultEventCode = podStateManager.faultEvent.faultEventCode
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault)
errors.add(resourceHelper.gs(R.string.omnipod_pod_status_pod_fault_description, faultEventCode.value, faultEventCode.name)) errors.add(resourceHelper.gs(R.string.omnipod_pod_status_pod_fault_description, faultEventCode.value, faultEventCode.name))
} }
podStateManager.isPodRunning -> {
stateText = resourceHelper.gs(R.string.omnipod_pod_status_pod_running, if (podStateManager.lastDeliveryStatus == null) null else podStateManager.lastDeliveryStatus.name)
}
else -> {
stateText = resourceHelper.gs(R.string.omnipod_pod_setup_in_progress, podStateManager.podProgressStatus.name)
}
}
omnipod_pod_status.text = stateText
updateLastConnectionUiElements()
// last bolus // last bolus
if (podStateManager.lastBolusStartTime != null && podStateManager.lastBolusAmount != null) { if (podStateManager.lastBolusStartTime != null && podStateManager.lastBolusAmount != null) {
val ago = readableDuration(podStateManager.lastBolusStartTime) val ago = readableDuration(podStateManager.lastBolusStartTime)
@ -299,8 +278,13 @@ class OmnipodFragment : DaggerFragment() {
} }
} }
omnipod_pod_status.setTextColor(if (podStateManager.hasFaultEvent()) Color.RED else Color.WHITE) if (errors.size == 0) {
omnipod_errors.text = if (errors.size == 0) "-" else StringUtils.join(errors, System.lineSeparator()) omnipod_errors.text = "-"
omnipod_errors.setTextColor(Color.WHITE)
} else {
omnipod_errors.text = StringUtils.join(errors, System.lineSeparator())
omnipod_errors.setTextColor(Color.RED)
}
val status = commandQueue.spannedStatus() val status = commandQueue.spannedStatus()
if (status.toString() == "") { if (status.toString() == "") {
@ -335,6 +319,44 @@ class OmnipodFragment : DaggerFragment() {
} }
} }
private fun updatePodStatusUiElements() {
if (!podStateManager.hasPodState()) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_active_pod)
} else if (!podStateManager.isPodActivationCompleted) {
if (!podStateManager.isPodInitialized) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_pair_and_prime)
} else {
if (PodProgressStatus.ACTIVATION_TIME_EXCEEDED == podStateManager.podProgressStatus) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_activation_time_exceeded)
} else if (podStateManager.podProgressStatus.isBefore(PodProgressStatus.PRIMING_COMPLETED)) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_pair_and_prime)
} else {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_waiting_for_cannula_insertion)
}
}
} else {
if (podStateManager.podProgressStatus.isRunning) {
if (podStateManager.isSuspended) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_suspended)
} else {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_running)
}
} else if (podStateManager.podProgressStatus == PodProgressStatus.FAULT_EVENT_OCCURRED) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_pod_fault)
} else if (podStateManager.podProgressStatus == PodProgressStatus.INACTIVE) {
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_inactive)
} else {
omnipod_pod_status.text = podStateManager.podProgressStatus.toString()
}
}
if (!podStateManager.isPodActivationCompleted || podStateManager.isPodDead || podStateManager.isSuspended) {
omnipod_pod_status.setTextColor(Color.RED)
} else {
omnipod_pod_status.setTextColor(Color.WHITE)
}
}
private fun updateAcknowledgeAlertsUiElements() { private fun updateAcknowledgeAlertsUiElements() {
if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts()) { if (podStateManager.isPodInitialized && podStateManager.hasActiveAlerts()) {
omnipod_pod_active_alerts_ack.isEnabled = true omnipod_pod_active_alerts_ack.isEnabled = true

View file

@ -80,7 +80,7 @@ public abstract class PodStateManager {
* @return true if we have a Pod state and the Pod activation has been completed. The pod could also be dead at this point * @return true if we have a Pod state and the Pod activation has been completed. The pod could also be dead at this point
*/ */
public final boolean isPodActivationCompleted() { public final boolean isPodActivationCompleted() {
return isPodInitialized() && podState.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS); return isPodInitialized() && podState.getPodProgressStatus().isAtLeast(PodProgressStatus.ABOVE_FIFTY_UNITS) && podState.getPodProgressStatus() != PodProgressStatus.ACTIVATION_TIME_EXCEEDED;
} }
/** /**

View file

@ -31,18 +31,19 @@
<string name="omnipod_pod_address">Pod Address</string> <string name="omnipod_pod_address">Pod Address</string>
<string name="omnipod_pod_expiry">Pod Expires</string> <string name="omnipod_pod_expiry">Pod Expires</string>
<string name="omnipod_warning">Warning</string> <string name="omnipod_warning">Warning</string>
<string name="omnipod_pod_status_no_pod_connected">No Pod connected</string> <string name="omnipod_pod_status_no_active_pod">No active Pod</string>
<string name="omnipod_pod_setup_in_progress">Pod setup in progress (Pod progress status: %1$s)</string> <string name="omnipod_pod_status_waiting_for_pair_and_prime">Setup in progress (waiting for pair and prime)</string>
<string name="omnipod_pod_status_not_initalized">Pod not initialized</string> <string name="omnipod_pod_status_waiting_for_cannula_insertion">Setup in progress (waiting for cannula insertion)</string>
<string name="omnipod_pod_status_running">Running</string>
<string name="omnipod_pod_status_suspended">Suspended</string>
<string name="omnipod_pod_status_pod_fault">Pod Fault</string> <string name="omnipod_pod_status_pod_fault">Pod Fault</string>
<string name="omnipod_pod_status_activation_time_exceeded">Activation time exceeded</string>
<string name="omnipod_pod_status_inactive">Inactive</string>
<string name="omnipod_pod_status_pod_fault_description">Pod Fault: %1$s %2$s</string> <string name="omnipod_pod_status_pod_fault_description">Pod Fault: %1$s %2$s</string>
<string name="omnipod_pod_status_pod_running">Pod running (last delivery status: %1$s)</string>
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string> <string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
<string name="omnipod_ack_short">Ack Alerts</string> <string name="omnipod_ack_short">Ack Alerts</string>
<string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string> <string name="omnipod_last_bolus" translatable="false">%1$.2f %2$s (%3$s)</string>
<string name="omnipod_pod_status_initalizing">Initializing</string> <string name="omnipod_pod_status_initalizing">Initializing</string>
<string name="omnipod_pod_status_active">Active</string>
<string name="omnipod_pod_status_unknown">Unknown</string>
<!-- Omnipod - Dialogs --> <!-- Omnipod - Dialogs -->