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
1 change: 1 addition & 0 deletions pump/omnipod/common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="omnipod_common_overview_lot_number">LOT Number</string>
<string name="omnipod_common_overview_pod_sequence_number">Sequence Number</string>
<string name="omnipod_common_overview_pod_expiry_date">Pod Expires</string>
<string name="omnipod_common_overview_pod_hard_end_date">Pod Hard End</string>
<string name="omnipod_common_overview_last_connection">Last Connection</string>
<string name="omnipod_common_overview_last_bolus">Last Bolus</string>
<string name="omnipod_common_overview_temp_basal_rate">Temp Basal Rate</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import java.time.Duration
import java.time.Instant
import java.time.ZonedDateTime
import java.util.Date
import java.util.Locale
Expand Down Expand Up @@ -139,7 +140,7 @@

// region Info Rows

private fun buildInfoRows(): List<PumpInfoRow> = buildList {

Check failure on line 143 in pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/ui/compose/DashOverviewViewModel.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 39 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=nightscout_AndroidAPS&issues=AZ1y94LpkpOC1dcbFd4V&open=AZ1y94LpkpOC1dcbFd4V&pullRequest=4609
val initialized = podStateManager.activationProgress.isAtLeast(ActivationProgress.SET_UNIQUE_ID)

// Bluetooth section (Dash-specific)
Expand Down Expand Up @@ -184,6 +185,7 @@
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_firmware_version), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_time_on_pod), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel()))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_connection), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_bolus), value = PLACEHOLDER))
Expand Down Expand Up @@ -237,6 +239,16 @@
}
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = expiryValue, level = expiryLevel))

// Hard end date (+8 hours after expiry)
val hardEndAt = expiresAt?.toInstant()?.plus(Duration.ofHours(8))
val hardEndValue = hardEndAt?.let { dateUtil.dateAndTimeString(it.toEpochMilli()) } ?: PLACEHOLDER
val hardEndLevel = when {
hardEndAt != null && Instant.now().isAfter(hardEndAt) -> StatusLevel.CRITICAL
hardEndAt != null && Instant.now().isAfter(hardEndAt.minus(Duration.ofHours(4))) -> StatusLevel.WARNING
else -> StatusLevel.NORMAL
}
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = hardEndValue, level = hardEndLevel))

// Pod status
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@

// region Info Rows

private fun buildInfoRows(): List<PumpInfoRow> = buildList {

Check failure on line 159 in pump/omnipod/eros/src/main/java/app/aaps/pump/omnipod/eros/ui/compose/ErosOverviewViewModel.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 41 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=nightscout_AndroidAPS&issues=AZ1y94BTkpOC1dcbFd4U&open=AZ1y94BTkpOC1dcbFd4U&pullRequest=4609
// RileyLink status (Eros-specific)
val rlState = rileyLinkServiceData.rileyLinkServiceState
val rlError = rileyLinkServiceData.rileyLinkError
Expand All @@ -179,6 +179,7 @@
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_firmware_version), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_time_on_pod), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = PLACEHOLDER))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel()))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_connection), value = buildLastConnection().first, level = buildLastConnection().second))
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_bolus), value = PLACEHOLDER))
Expand Down Expand Up @@ -209,6 +210,12 @@
val expiryLevel = if (expiresAt != null && DateTime.now().isAfter(expiresAt)) StatusLevel.CRITICAL else StatusLevel.NORMAL
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = expiryValue, level = expiryLevel))

// Hard end date (+8 hours after expiry)
val hardEndAt = expiresAt?.plusHours(8)
val hardEndValue = hardEndAt?.let { dateUtil.dateAndTimeString(it.millis) } ?: PLACEHOLDER
val hardEndLevel = if (hardEndAt != null && DateTime.now().isAfter(hardEndAt)) StatusLevel.CRITICAL else StatusLevel.NORMAL
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = hardEndValue, level = hardEndLevel))

// Pod status
add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel()))

Expand Down