OmnipodOverviewFragment -> jetpack
This commit is contained in:
parent
ec8edaecab
commit
a401f49bce
3 changed files with 921 additions and 902 deletions
|
@ -19,6 +19,9 @@ android {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = '1.8'
|
jvmTarget = '1.8'
|
||||||
}
|
}
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
import info.nightscout.androidaps.plugins.pump.omnipod.R
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.databinding.OmnipodOverviewBinding
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus
|
||||||
|
@ -50,7 +51,6 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import info.nightscout.androidaps.utils.ui.UIRunnable
|
import info.nightscout.androidaps.utils.ui.UIRunnable
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import kotlinx.android.synthetic.main.omnipod_overview.*
|
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
import org.joda.time.Duration
|
import org.joda.time.Duration
|
||||||
|
@ -61,8 +61,8 @@ import kotlin.collections.ArrayList
|
||||||
class OmnipodOverviewFragment : DaggerFragment() {
|
class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
private const val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
||||||
private val PLACEHOLDER = "-" // 15 seconds
|
private const val PLACEHOLDER = "-" // 15 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -92,14 +92,19 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
private var _binding: OmnipodOverviewBinding? = null
|
||||||
return inflater.inflate(R.layout.omnipod_overview, container, false)
|
|
||||||
}
|
// This property is only valid between onCreateView and
|
||||||
|
// onDestroyView.
|
||||||
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||||
|
OmnipodOverviewBinding.inflate(inflater, container, false).also { _binding = it }.root
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
omnipod_overview_button_pod_management.setOnClickListener {
|
binding.buttonPodManagement.setOnClickListener {
|
||||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
|
@ -114,19 +119,19 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_button_resume_delivery.setOnClickListener {
|
binding.buttonResumeDelivery.setOnClickListener {
|
||||||
disablePodActionButtons()
|
disablePodActionButtons()
|
||||||
commandQueue.customCommand(CommandResumeDelivery(),
|
commandQueue.customCommand(CommandResumeDelivery(),
|
||||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_delivery_resumed)))
|
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_resume_delivery), true).messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_delivery_resumed)))
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_button_refresh_status.setOnClickListener {
|
binding.buttonRefreshStatus.setOnClickListener {
|
||||||
disablePodActionButtons()
|
disablePodActionButtons()
|
||||||
commandQueue.customCommand(CommandGetPodStatus(),
|
commandQueue.customCommand(CommandGetPodStatus(),
|
||||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status), false))
|
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status), false))
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_button_acknowledge_active_alerts.setOnClickListener {
|
binding.buttonAcknowledgeActiveAlerts.setOnClickListener {
|
||||||
disablePodActionButtons()
|
disablePodActionButtons()
|
||||||
commandQueue.customCommand(CommandAcknowledgeAlerts(),
|
commandQueue.customCommand(CommandAcknowledgeAlerts(),
|
||||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_acknowledge_alerts), false)
|
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_acknowledge_alerts), false)
|
||||||
|
@ -134,14 +139,14 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
.actionOnSuccess { rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_ALERTS)) })
|
.actionOnSuccess { rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_ALERTS)) })
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_button_suspend_delivery.setOnClickListener {
|
binding.buttonSuspendDelivery.setOnClickListener {
|
||||||
disablePodActionButtons()
|
disablePodActionButtons()
|
||||||
commandQueue.customCommand(CommandSuspendDelivery(),
|
commandQueue.customCommand(CommandSuspendDelivery(),
|
||||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_suspend_delivery), true)
|
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_suspend_delivery), true)
|
||||||
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_suspended_delivery)))
|
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_suspended_delivery)))
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_button_set_time.setOnClickListener {
|
binding.buttonSetTime.setOnClickListener {
|
||||||
disablePodActionButtons()
|
disablePodActionButtons()
|
||||||
commandQueue.customCommand(CommandHandleTimeChange(true),
|
commandQueue.customCommand(CommandHandleTimeChange(true),
|
||||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_set_time), true)
|
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_set_time), true)
|
||||||
|
@ -188,6 +193,12 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
loopHandler.removeCallbacks(refreshLoop)
|
loopHandler.removeCallbacks(refreshLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
_binding = null
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateUi() {
|
private fun updateUi() {
|
||||||
updateRileyLinkStatus()
|
updateRileyLinkStatus()
|
||||||
updateOmnipodStatus()
|
updateOmnipodStatus()
|
||||||
|
@ -202,7 +213,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
val resourceId = rileyLinkServiceState.resourceId
|
val resourceId = rileyLinkServiceState.resourceId
|
||||||
val rileyLinkError = rileyLinkServiceData.rileyLinkError
|
val rileyLinkError = rileyLinkServiceData.rileyLinkError
|
||||||
|
|
||||||
omnipod_overview_riley_link_status.text =
|
binding.rileyLinkStatus.text =
|
||||||
when {
|
when {
|
||||||
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||||
rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||||
|
@ -210,7 +221,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.Omnipod))
|
rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
}
|
}
|
||||||
omnipod_overview_riley_link_status.setTextColor(if (rileyLinkServiceState.isError || rileyLinkError != null) Color.RED else Color.WHITE)
|
binding.rileyLinkStatus.setTextColor(if (rileyLinkServiceState.isError || rileyLinkError != null) Color.RED else Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateOmnipodStatus() {
|
private fun updateOmnipodStatus() {
|
||||||
|
@ -228,41 +239,41 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!podStateManager.hasPodState() || !podStateManager.isPodInitialized) {
|
if (!podStateManager.hasPodState() || !podStateManager.isPodInitialized) {
|
||||||
omnipod_overview_pod_address.text = if (podStateManager.hasPodState()) {
|
binding.podAddress.text = if (podStateManager.hasPodState()) {
|
||||||
podStateManager.address.toString()
|
podStateManager.address.toString()
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
}
|
}
|
||||||
omnipod_overview_pod_lot.text = PLACEHOLDER
|
binding.podLot.text = PLACEHOLDER
|
||||||
omnipod_overview_pod_tid.text = PLACEHOLDER
|
binding.podTid.text = PLACEHOLDER
|
||||||
omnipod_overview_firmware_version.text = PLACEHOLDER
|
binding.firmwareVersion.text = PLACEHOLDER
|
||||||
omnipod_overview_time_on_pod.text = PLACEHOLDER
|
binding.timeOnPod.text = PLACEHOLDER
|
||||||
omnipod_overview_pod_expiry_date.text = PLACEHOLDER
|
binding.podExpiryDate.text = PLACEHOLDER
|
||||||
omnipod_overview_pod_expiry_date.setTextColor(Color.WHITE)
|
binding.podExpiryDate.setTextColor(Color.WHITE)
|
||||||
omnipod_overview_base_basal_rate.text = PLACEHOLDER
|
binding.baseBasalRate.text = PLACEHOLDER
|
||||||
omnipod_overview_total_delivered.text = PLACEHOLDER
|
binding.totalDelivered.text = PLACEHOLDER
|
||||||
omnipod_overview_reservoir.text = PLACEHOLDER
|
binding.reservoir.text = PLACEHOLDER
|
||||||
omnipod_overview_reservoir.setTextColor(Color.WHITE)
|
binding.reservoir.setTextColor(Color.WHITE)
|
||||||
omnipod_overview_pod_active_alerts.text = PLACEHOLDER
|
binding.podActiveAlerts.text = PLACEHOLDER
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_pod_address.text = podStateManager.address.toString()
|
binding.podAddress.text = podStateManager.address.toString()
|
||||||
omnipod_overview_pod_lot.text = podStateManager.lot.toString()
|
binding.podLot.text = podStateManager.lot.toString()
|
||||||
omnipod_overview_pod_tid.text = podStateManager.tid.toString()
|
binding.podTid.text = podStateManager.tid.toString()
|
||||||
omnipod_overview_firmware_version.text = resourceHelper.gs(R.string.omnipod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
binding.firmwareVersion.text = resourceHelper.gs(R.string.omnipod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
||||||
|
|
||||||
omnipod_overview_time_on_pod.text = readableZonedTime(podStateManager.time)
|
binding.timeOnPod.text = readableZonedTime(podStateManager.time)
|
||||||
omnipod_overview_time_on_pod.setTextColor(if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
binding.timeOnPod.setTextColor(if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
||||||
Color.RED
|
Color.RED
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
})
|
})
|
||||||
val expiresAt = podStateManager.expiresAt
|
val expiresAt = podStateManager.expiresAt
|
||||||
if (expiresAt == null) {
|
if (expiresAt == null) {
|
||||||
omnipod_overview_pod_expiry_date.text = PLACEHOLDER
|
binding.podExpiryDate.text = PLACEHOLDER
|
||||||
omnipod_overview_pod_expiry_date.setTextColor(Color.WHITE)
|
binding.podExpiryDate.setTextColor(Color.WHITE)
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_pod_expiry_date.text = readableZonedTime(expiresAt)
|
binding.podExpiryDate.text = readableZonedTime(expiresAt)
|
||||||
omnipod_overview_pod_expiry_date.setTextColor(if (DateTime.now().isAfter(expiresAt)) {
|
binding.podExpiryDate.setTextColor(if (DateTime.now().isAfter(expiresAt)) {
|
||||||
Color.RED
|
Color.RED
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
|
@ -275,14 +286,14 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// base basal rate
|
// base basal rate
|
||||||
omnipod_overview_base_basal_rate.text = if (podStateManager.isPodActivationCompleted) {
|
binding.baseBasalRate.text = if (podStateManager.isPodActivationCompleted) {
|
||||||
resourceHelper.gs(R.string.pump_basebasalrate, omnipodPumpPlugin.model().determineCorrectBasalSize(podStateManager.basalSchedule.rateAt(TimeUtil.toDuration(DateTime.now()))))
|
resourceHelper.gs(R.string.pump_basebasalrate, omnipodPumpPlugin.model().determineCorrectBasalSize(podStateManager.basalSchedule.rateAt(TimeUtil.toDuration(DateTime.now()))))
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
}
|
}
|
||||||
|
|
||||||
// total delivered
|
// total delivered
|
||||||
omnipod_overview_total_delivered.text = if (podStateManager.isPodActivationCompleted && podStateManager.totalInsulinDelivered != null) {
|
binding.totalDelivered.text = if (podStateManager.isPodActivationCompleted && podStateManager.totalInsulinDelivered != null) {
|
||||||
resourceHelper.gs(R.string.omnipod_overview_total_delivered_value, podStateManager.totalInsulinDelivered - OmnipodConstants.POD_SETUP_UNITS)
|
resourceHelper.gs(R.string.omnipod_overview_total_delivered_value, podStateManager.totalInsulinDelivered - OmnipodConstants.POD_SETUP_UNITS)
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
|
@ -290,21 +301,21 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
|
|
||||||
// reservoir
|
// reservoir
|
||||||
if (podStateManager.reservoirLevel == null) {
|
if (podStateManager.reservoirLevel == null) {
|
||||||
omnipod_overview_reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value_over50)
|
binding.reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value_over50)
|
||||||
omnipod_overview_reservoir.setTextColor(Color.WHITE)
|
binding.reservoir.setTextColor(Color.WHITE)
|
||||||
} else {
|
} else {
|
||||||
val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
|
val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
|
||||||
?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble()
|
?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble()
|
||||||
|
|
||||||
omnipod_overview_reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value, podStateManager.reservoirLevel)
|
binding.reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value, podStateManager.reservoirLevel)
|
||||||
omnipod_overview_reservoir.setTextColor(if (podStateManager.reservoirLevel < lowReservoirThreshold) {
|
binding.reservoir.setTextColor(if (podStateManager.reservoirLevel < lowReservoirThreshold) {
|
||||||
Color.RED
|
Color.RED
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_pod_active_alerts.text = if (podStateManager.hasActiveAlerts()) {
|
binding.podActiveAlerts.text = if (podStateManager.hasActiveAlerts()) {
|
||||||
TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
|
@ -312,27 +323,27 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errors.size == 0) {
|
if (errors.size == 0) {
|
||||||
omnipod_overview_errors.text = PLACEHOLDER
|
binding.errors.text = PLACEHOLDER
|
||||||
omnipod_overview_errors.setTextColor(Color.WHITE)
|
binding.errors.setTextColor(Color.WHITE)
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_errors.text = StringUtils.join(errors, System.lineSeparator())
|
binding.errors.text = StringUtils.join(errors, System.lineSeparator())
|
||||||
omnipod_overview_errors.setTextColor(Color.RED)
|
binding.errors.setTextColor(Color.RED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLastConnection() {
|
private fun updateLastConnection() {
|
||||||
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) {
|
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) {
|
||||||
omnipod_overview_last_connection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
binding.lastConnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||||
val lastConnectionColor =
|
val lastConnectionColor =
|
||||||
if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().millis)) {
|
if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().millis)) {
|
||||||
Color.RED
|
Color.RED
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
omnipod_overview_last_connection.setTextColor(lastConnectionColor)
|
binding.lastConnection.setTextColor(lastConnectionColor)
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_last_connection.setTextColor(Color.WHITE)
|
binding.lastConnection.setTextColor(Color.WHITE)
|
||||||
omnipod_overview_last_connection.text = if (podStateManager.hasPodState() && podStateManager.lastSuccessfulCommunication != null) {
|
binding.lastConnection.text = if (podStateManager.hasPodState() && podStateManager.lastSuccessfulCommunication != null) {
|
||||||
readableDuration(podStateManager.lastSuccessfulCommunication)
|
readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||||
} else {
|
} else {
|
||||||
PLACEHOLDER
|
PLACEHOLDER
|
||||||
|
@ -341,7 +352,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePodStatus() {
|
private fun updatePodStatus() {
|
||||||
omnipod_overview_pod_status.text = if (!podStateManager.hasPodState()) {
|
binding.podStatus.text = if (!podStateManager.hasPodState()) {
|
||||||
resourceHelper.gs(R.string.omnipod_pod_status_no_active_pod)
|
resourceHelper.gs(R.string.omnipod_pod_status_no_active_pod)
|
||||||
} else if (!podStateManager.isPodActivationCompleted) {
|
} else if (!podStateManager.isPodActivationCompleted) {
|
||||||
if (!podStateManager.isPodInitialized) {
|
if (!podStateManager.isPodInitialized) {
|
||||||
|
@ -380,7 +391,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
} else {
|
} else {
|
||||||
Color.WHITE
|
Color.WHITE
|
||||||
}
|
}
|
||||||
omnipod_overview_pod_status.setTextColor(podStatusColor)
|
binding.podStatus.setTextColor(podStatusColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLastBolus() {
|
private fun updateLastBolus() {
|
||||||
|
@ -395,20 +406,20 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_last_bolus.text = text
|
binding.lastBolus.text = text
|
||||||
omnipod_overview_last_bolus.setTextColor(textColor)
|
binding.lastBolus.setTextColor(textColor)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_last_bolus.text = PLACEHOLDER
|
binding.lastBolus.text = PLACEHOLDER
|
||||||
omnipod_overview_last_bolus.setTextColor(Color.WHITE)
|
binding.lastBolus.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTempBasal() {
|
private fun updateTempBasal() {
|
||||||
if (podStateManager.isPodActivationCompleted && podStateManager.isTempBasalRunning) {
|
if (podStateManager.isPodActivationCompleted && podStateManager.isTempBasalRunning) {
|
||||||
if (!podStateManager.hasTempBasal()) {
|
if (!podStateManager.hasTempBasal()) {
|
||||||
omnipod_overview_temp_basal.text = "???"
|
binding.tempBasal.text = "???"
|
||||||
omnipod_overview_temp_basal.setTextColor(Color.RED)
|
binding.tempBasal.setTextColor(Color.RED)
|
||||||
} else {
|
} else {
|
||||||
val now = DateTime.now()
|
val now = DateTime.now()
|
||||||
|
|
||||||
|
@ -428,8 +439,8 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_temp_basal.text = text
|
binding.tempBasal.text = text
|
||||||
omnipod_overview_temp_basal.setTextColor(textColor)
|
binding.tempBasal.setTextColor(textColor)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var text = PLACEHOLDER
|
var text = PLACEHOLDER
|
||||||
|
@ -442,17 +453,17 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
omnipod_overview_temp_basal.text = text
|
binding.tempBasal.text = text
|
||||||
omnipod_overview_temp_basal.setTextColor(textColor)
|
binding.tempBasal.setTextColor(textColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateQueueStatus() {
|
private fun updateQueueStatus() {
|
||||||
if (isQueueEmpty()) {
|
if (isQueueEmpty()) {
|
||||||
omnipod_overview_queue.visibility = View.GONE
|
binding.queue.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_queue.visibility = View.VISIBLE
|
binding.queue.visibility = View.VISIBLE
|
||||||
omnipod_overview_queue.text = commandQueue.spannedStatus().toString()
|
binding.queue.text = commandQueue.spannedStatus().toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,52 +476,52 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disablePodActionButtons() {
|
private fun disablePodActionButtons() {
|
||||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = false
|
binding.buttonAcknowledgeActiveAlerts.isEnabled = false
|
||||||
omnipod_overview_button_resume_delivery.isEnabled = false
|
binding.buttonResumeDelivery.isEnabled = false
|
||||||
omnipod_overview_button_suspend_delivery.isEnabled = false
|
binding.buttonSuspendDelivery.isEnabled = false
|
||||||
omnipod_overview_button_set_time.isEnabled = false
|
binding.buttonSetTime.isEnabled = false
|
||||||
omnipod_overview_button_refresh_status.isEnabled = false
|
binding.buttonRefreshStatus.isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRefreshStatusButton() {
|
private fun updateRefreshStatusButton() {
|
||||||
omnipod_overview_button_refresh_status.isEnabled = podStateManager.isPodInitialized && podStateManager.activationProgress.isAtLeast(ActivationProgress.PAIRING_COMPLETED)
|
binding.buttonRefreshStatus.isEnabled = podStateManager.isPodInitialized && podStateManager.activationProgress.isAtLeast(ActivationProgress.PAIRING_COMPLETED)
|
||||||
&& rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
&& rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateResumeDeliveryButton() {
|
private fun updateResumeDeliveryButton() {
|
||||||
if (podStateManager.isPodRunning && (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandResumeDelivery::class.java))) {
|
if (podStateManager.isPodRunning && (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandResumeDelivery::class.java))) {
|
||||||
omnipod_overview_button_resume_delivery.visibility = View.VISIBLE
|
binding.buttonResumeDelivery.visibility = View.VISIBLE
|
||||||
omnipod_overview_button_resume_delivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
binding.buttonResumeDelivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_button_resume_delivery.visibility = View.GONE
|
binding.buttonResumeDelivery.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAcknowledgeAlertsButton() {
|
private fun updateAcknowledgeAlertsButton() {
|
||||||
if (!omnipodManager.isAutomaticallyAcknowledgeAlertsEnabled && podStateManager.isPodRunning && (podStateManager.hasActiveAlerts() || commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java))) {
|
if (!omnipodManager.isAutomaticallyAcknowledgeAlertsEnabled && podStateManager.isPodRunning && (podStateManager.hasActiveAlerts() || commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java))) {
|
||||||
omnipod_overview_button_acknowledge_active_alerts.visibility = View.VISIBLE
|
binding.buttonAcknowledgeActiveAlerts.visibility = View.VISIBLE
|
||||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
binding.buttonAcknowledgeActiveAlerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_button_acknowledge_active_alerts.visibility = View.GONE
|
binding.buttonAcknowledgeActiveAlerts.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSuspendDeliveryButton() {
|
private fun updateSuspendDeliveryButton() {
|
||||||
// If the Pod is currently suspended, we show the Resume delivery button instead.
|
// If the Pod is currently suspended, we show the Resume delivery button instead.
|
||||||
if (omnipodManager.isSuspendDeliveryButtonEnabled && podStateManager.isPodRunning && (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))) {
|
if (omnipodManager.isSuspendDeliveryButtonEnabled && podStateManager.isPodRunning && (!podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandSuspendDelivery::class.java))) {
|
||||||
omnipod_overview_button_suspend_delivery.visibility = View.VISIBLE
|
binding.buttonSuspendDelivery.visibility = View.VISIBLE
|
||||||
omnipod_overview_button_suspend_delivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
binding.buttonSuspendDelivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_button_suspend_delivery.visibility = View.GONE
|
binding.buttonSuspendDelivery.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSetTimeButton() {
|
private fun updateSetTimeButton() {
|
||||||
if (podStateManager.isPodRunning && (podStateManager.timeDeviatesMoreThan(Duration.standardMinutes(5)) || commandQueue.isCustomCommandInQueue(CommandHandleTimeChange::class.java))) {
|
if (podStateManager.isPodRunning && (podStateManager.timeDeviatesMoreThan(Duration.standardMinutes(5)) || commandQueue.isCustomCommandInQueue(CommandHandleTimeChange::class.java))) {
|
||||||
omnipod_overview_button_set_time.visibility = View.VISIBLE
|
binding.buttonSetTime.visibility = View.VISIBLE
|
||||||
omnipod_overview_button_set_time.isEnabled = !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
binding.buttonSetTime.isEnabled = !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||||
} else {
|
} else {
|
||||||
omnipod_overview_button_set_time.visibility = View.GONE
|
binding.buttonSetTime.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue