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 {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
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.omnipod.OmnipodPumpPlugin
|
||||
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.OmnipodConstants
|
||||
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 io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.omnipod_overview.*
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.Duration
|
||||
|
@ -61,8 +61,8 @@ import kotlin.collections.ArrayList
|
|||
class OmnipodOverviewFragment : DaggerFragment() {
|
||||
companion object {
|
||||
|
||||
private val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
||||
private val PLACEHOLDER = "-" // 15 seconds
|
||||
private const val REFRESH_INTERVAL_MILLIS = 15 * 1000L // 15 seconds
|
||||
private const val PLACEHOLDER = "-" // 15 seconds
|
||||
}
|
||||
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
|
@ -92,14 +92,19 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.omnipod_overview, container, false)
|
||||
}
|
||||
private var _binding: OmnipodOverviewBinding? = null
|
||||
|
||||
// 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?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
omnipod_overview_button_pod_management.setOnClickListener {
|
||||
binding.buttonPodManagement.setOnClickListener {
|
||||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
|
||||
activity?.let { activity ->
|
||||
context?.let { context ->
|
||||
|
@ -114,19 +119,19 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
omnipod_overview_button_resume_delivery.setOnClickListener {
|
||||
binding.buttonResumeDelivery.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandResumeDelivery(),
|
||||
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()
|
||||
commandQueue.customCommand(CommandGetPodStatus(),
|
||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_refresh_status), false))
|
||||
}
|
||||
|
||||
omnipod_overview_button_acknowledge_active_alerts.setOnClickListener {
|
||||
binding.buttonAcknowledgeActiveAlerts.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandAcknowledgeAlerts(),
|
||||
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)) })
|
||||
}
|
||||
|
||||
omnipod_overview_button_suspend_delivery.setOnClickListener {
|
||||
binding.buttonSuspendDelivery.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandSuspendDelivery(),
|
||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_suspend_delivery), true)
|
||||
.messageOnSuccess(resourceHelper.gs(R.string.omnipod_confirmation_suspended_delivery)))
|
||||
}
|
||||
|
||||
omnipod_overview_button_set_time.setOnClickListener {
|
||||
binding.buttonSetTime.setOnClickListener {
|
||||
disablePodActionButtons()
|
||||
commandQueue.customCommand(CommandHandleTimeChange(true),
|
||||
DisplayResultDialogCallback(resourceHelper.gs(R.string.omnipod_error_failed_to_set_time), true)
|
||||
|
@ -188,6 +193,12 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
|
||||
private fun updateUi() {
|
||||
updateRileyLinkStatus()
|
||||
updateOmnipodStatus()
|
||||
|
@ -202,7 +213,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
val resourceId = rileyLinkServiceState.resourceId
|
||||
val rileyLinkError = rileyLinkServiceData.rileyLinkError
|
||||
|
||||
omnipod_overview_riley_link_status.text =
|
||||
binding.rileyLinkStatus.text =
|
||||
when {
|
||||
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> 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))
|
||||
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() {
|
||||
|
@ -228,41 +239,41 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
if (!podStateManager.hasPodState() || !podStateManager.isPodInitialized) {
|
||||
omnipod_overview_pod_address.text = if (podStateManager.hasPodState()) {
|
||||
binding.podAddress.text = if (podStateManager.hasPodState()) {
|
||||
podStateManager.address.toString()
|
||||
} else {
|
||||
PLACEHOLDER
|
||||
}
|
||||
omnipod_overview_pod_lot.text = PLACEHOLDER
|
||||
omnipod_overview_pod_tid.text = PLACEHOLDER
|
||||
omnipod_overview_firmware_version.text = PLACEHOLDER
|
||||
omnipod_overview_time_on_pod.text = PLACEHOLDER
|
||||
omnipod_overview_pod_expiry_date.text = PLACEHOLDER
|
||||
omnipod_overview_pod_expiry_date.setTextColor(Color.WHITE)
|
||||
omnipod_overview_base_basal_rate.text = PLACEHOLDER
|
||||
omnipod_overview_total_delivered.text = PLACEHOLDER
|
||||
omnipod_overview_reservoir.text = PLACEHOLDER
|
||||
omnipod_overview_reservoir.setTextColor(Color.WHITE)
|
||||
omnipod_overview_pod_active_alerts.text = PLACEHOLDER
|
||||
binding.podLot.text = PLACEHOLDER
|
||||
binding.podTid.text = PLACEHOLDER
|
||||
binding.firmwareVersion.text = PLACEHOLDER
|
||||
binding.timeOnPod.text = PLACEHOLDER
|
||||
binding.podExpiryDate.text = PLACEHOLDER
|
||||
binding.podExpiryDate.setTextColor(Color.WHITE)
|
||||
binding.baseBasalRate.text = PLACEHOLDER
|
||||
binding.totalDelivered.text = PLACEHOLDER
|
||||
binding.reservoir.text = PLACEHOLDER
|
||||
binding.reservoir.setTextColor(Color.WHITE)
|
||||
binding.podActiveAlerts.text = PLACEHOLDER
|
||||
} else {
|
||||
omnipod_overview_pod_address.text = podStateManager.address.toString()
|
||||
omnipod_overview_pod_lot.text = podStateManager.lot.toString()
|
||||
omnipod_overview_pod_tid.text = podStateManager.tid.toString()
|
||||
omnipod_overview_firmware_version.text = resourceHelper.gs(R.string.omnipod_firmware_version_value, podStateManager.pmVersion.toString(), podStateManager.piVersion.toString())
|
||||
binding.podAddress.text = podStateManager.address.toString()
|
||||
binding.podLot.text = podStateManager.lot.toString()
|
||||
binding.podTid.text = podStateManager.tid.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)
|
||||
omnipod_overview_time_on_pod.setTextColor(if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
||||
binding.timeOnPod.text = readableZonedTime(podStateManager.time)
|
||||
binding.timeOnPod.setTextColor(if (podStateManager.timeDeviatesMoreThan(OmnipodConstants.TIME_DEVIATION_THRESHOLD)) {
|
||||
Color.RED
|
||||
} else {
|
||||
Color.WHITE
|
||||
})
|
||||
val expiresAt = podStateManager.expiresAt
|
||||
if (expiresAt == null) {
|
||||
omnipod_overview_pod_expiry_date.text = PLACEHOLDER
|
||||
omnipod_overview_pod_expiry_date.setTextColor(Color.WHITE)
|
||||
binding.podExpiryDate.text = PLACEHOLDER
|
||||
binding.podExpiryDate.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
omnipod_overview_pod_expiry_date.text = readableZonedTime(expiresAt)
|
||||
omnipod_overview_pod_expiry_date.setTextColor(if (DateTime.now().isAfter(expiresAt)) {
|
||||
binding.podExpiryDate.text = readableZonedTime(expiresAt)
|
||||
binding.podExpiryDate.setTextColor(if (DateTime.now().isAfter(expiresAt)) {
|
||||
Color.RED
|
||||
} else {
|
||||
Color.WHITE
|
||||
|
@ -275,14 +286,14 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
// 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()))))
|
||||
} else {
|
||||
PLACEHOLDER
|
||||
}
|
||||
|
||||
// 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)
|
||||
} else {
|
||||
PLACEHOLDER
|
||||
|
@ -290,21 +301,21 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
|
||||
// reservoir
|
||||
if (podStateManager.reservoirLevel == null) {
|
||||
omnipod_overview_reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value_over50)
|
||||
omnipod_overview_reservoir.setTextColor(Color.WHITE)
|
||||
binding.reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value_over50)
|
||||
binding.reservoir.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
val lowReservoirThreshold = (omnipodAlertUtil.lowReservoirAlertUnits
|
||||
?: OmnipodConstants.DEFAULT_MAX_RESERVOIR_ALERT_THRESHOLD).toDouble()
|
||||
|
||||
omnipod_overview_reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value, podStateManager.reservoirLevel)
|
||||
omnipod_overview_reservoir.setTextColor(if (podStateManager.reservoirLevel < lowReservoirThreshold) {
|
||||
binding.reservoir.text = resourceHelper.gs(R.string.omnipod_overview_reservoir_value, podStateManager.reservoirLevel)
|
||||
binding.reservoir.setTextColor(if (podStateManager.reservoirLevel < lowReservoirThreshold) {
|
||||
Color.RED
|
||||
} else {
|
||||
Color.WHITE
|
||||
})
|
||||
}
|
||||
|
||||
omnipod_overview_pod_active_alerts.text = if (podStateManager.hasActiveAlerts()) {
|
||||
binding.podActiveAlerts.text = if (podStateManager.hasActiveAlerts()) {
|
||||
TextUtils.join(System.lineSeparator(), omnipodUtil.getTranslatedActiveAlerts(podStateManager))
|
||||
} else {
|
||||
PLACEHOLDER
|
||||
|
@ -312,27 +323,27 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
if (errors.size == 0) {
|
||||
omnipod_overview_errors.text = PLACEHOLDER
|
||||
omnipod_overview_errors.setTextColor(Color.WHITE)
|
||||
binding.errors.text = PLACEHOLDER
|
||||
binding.errors.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
omnipod_overview_errors.text = StringUtils.join(errors, System.lineSeparator())
|
||||
omnipod_overview_errors.setTextColor(Color.RED)
|
||||
binding.errors.text = StringUtils.join(errors, System.lineSeparator())
|
||||
binding.errors.setTextColor(Color.RED)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateLastConnection() {
|
||||
if (podStateManager.isPodInitialized && podStateManager.lastSuccessfulCommunication != null) {
|
||||
omnipod_overview_last_connection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
binding.lastConnection.text = readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
val lastConnectionColor =
|
||||
if (omnipodPumpPlugin.isUnreachableAlertTimeoutExceeded(getPumpUnreachableTimeout().millis)) {
|
||||
Color.RED
|
||||
} else {
|
||||
Color.WHITE
|
||||
}
|
||||
omnipod_overview_last_connection.setTextColor(lastConnectionColor)
|
||||
binding.lastConnection.setTextColor(lastConnectionColor)
|
||||
} else {
|
||||
omnipod_overview_last_connection.setTextColor(Color.WHITE)
|
||||
omnipod_overview_last_connection.text = if (podStateManager.hasPodState() && podStateManager.lastSuccessfulCommunication != null) {
|
||||
binding.lastConnection.setTextColor(Color.WHITE)
|
||||
binding.lastConnection.text = if (podStateManager.hasPodState() && podStateManager.lastSuccessfulCommunication != null) {
|
||||
readableDuration(podStateManager.lastSuccessfulCommunication)
|
||||
} else {
|
||||
PLACEHOLDER
|
||||
|
@ -341,7 +352,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
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)
|
||||
} else if (!podStateManager.isPodActivationCompleted) {
|
||||
if (!podStateManager.isPodInitialized) {
|
||||
|
@ -380,7 +391,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
} else {
|
||||
Color.WHITE
|
||||
}
|
||||
omnipod_overview_pod_status.setTextColor(podStatusColor)
|
||||
binding.podStatus.setTextColor(podStatusColor)
|
||||
}
|
||||
|
||||
private fun updateLastBolus() {
|
||||
|
@ -395,20 +406,20 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||
}
|
||||
|
||||
omnipod_overview_last_bolus.text = text
|
||||
omnipod_overview_last_bolus.setTextColor(textColor)
|
||||
binding.lastBolus.text = text
|
||||
binding.lastBolus.setTextColor(textColor)
|
||||
|
||||
} else {
|
||||
omnipod_overview_last_bolus.text = PLACEHOLDER
|
||||
omnipod_overview_last_bolus.setTextColor(Color.WHITE)
|
||||
binding.lastBolus.text = PLACEHOLDER
|
||||
binding.lastBolus.setTextColor(Color.WHITE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTempBasal() {
|
||||
if (podStateManager.isPodActivationCompleted && podStateManager.isTempBasalRunning) {
|
||||
if (!podStateManager.hasTempBasal()) {
|
||||
omnipod_overview_temp_basal.text = "???"
|
||||
omnipod_overview_temp_basal.setTextColor(Color.RED)
|
||||
binding.tempBasal.text = "???"
|
||||
binding.tempBasal.setTextColor(Color.RED)
|
||||
} else {
|
||||
val now = DateTime.now()
|
||||
|
||||
|
@ -428,8 +439,8 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||
}
|
||||
|
||||
omnipod_overview_temp_basal.text = text
|
||||
omnipod_overview_temp_basal.setTextColor(textColor)
|
||||
binding.tempBasal.text = text
|
||||
binding.tempBasal.setTextColor(textColor)
|
||||
}
|
||||
} else {
|
||||
var text = PLACEHOLDER
|
||||
|
@ -442,17 +453,17 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
text += " (" + resourceHelper.gs(R.string.omnipod_uncertain) + ")"
|
||||
}
|
||||
|
||||
omnipod_overview_temp_basal.text = text
|
||||
omnipod_overview_temp_basal.setTextColor(textColor)
|
||||
binding.tempBasal.text = text
|
||||
binding.tempBasal.setTextColor(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateQueueStatus() {
|
||||
if (isQueueEmpty()) {
|
||||
omnipod_overview_queue.visibility = View.GONE
|
||||
binding.queue.visibility = View.GONE
|
||||
} else {
|
||||
omnipod_overview_queue.visibility = View.VISIBLE
|
||||
omnipod_overview_queue.text = commandQueue.spannedStatus().toString()
|
||||
binding.queue.visibility = View.VISIBLE
|
||||
binding.queue.text = commandQueue.spannedStatus().toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -465,52 +476,52 @@ class OmnipodOverviewFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun disablePodActionButtons() {
|
||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = false
|
||||
omnipod_overview_button_resume_delivery.isEnabled = false
|
||||
omnipod_overview_button_suspend_delivery.isEnabled = false
|
||||
omnipod_overview_button_set_time.isEnabled = false
|
||||
omnipod_overview_button_refresh_status.isEnabled = false
|
||||
binding.buttonAcknowledgeActiveAlerts.isEnabled = false
|
||||
binding.buttonResumeDelivery.isEnabled = false
|
||||
binding.buttonSuspendDelivery.isEnabled = false
|
||||
binding.buttonSetTime.isEnabled = false
|
||||
binding.buttonRefreshStatus.isEnabled = false
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
private fun updateResumeDeliveryButton() {
|
||||
if (podStateManager.isPodRunning && (podStateManager.isSuspended || commandQueue.isCustomCommandInQueue(CommandResumeDelivery::class.java))) {
|
||||
omnipod_overview_button_resume_delivery.visibility = View.VISIBLE
|
||||
omnipod_overview_button_resume_delivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
binding.buttonResumeDelivery.visibility = View.VISIBLE
|
||||
binding.buttonResumeDelivery.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_overview_button_resume_delivery.visibility = View.GONE
|
||||
binding.buttonResumeDelivery.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateAcknowledgeAlertsButton() {
|
||||
if (!omnipodManager.isAutomaticallyAcknowledgeAlertsEnabled && podStateManager.isPodRunning && (podStateManager.hasActiveAlerts() || commandQueue.isCustomCommandInQueue(CommandAcknowledgeAlerts::class.java))) {
|
||||
omnipod_overview_button_acknowledge_active_alerts.visibility = View.VISIBLE
|
||||
omnipod_overview_button_acknowledge_active_alerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
binding.buttonAcknowledgeActiveAlerts.visibility = View.VISIBLE
|
||||
binding.buttonAcknowledgeActiveAlerts.isEnabled = rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_overview_button_acknowledge_active_alerts.visibility = View.GONE
|
||||
binding.buttonAcknowledgeActiveAlerts.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSuspendDeliveryButton() {
|
||||
// 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))) {
|
||||
omnipod_overview_button_suspend_delivery.visibility = View.VISIBLE
|
||||
omnipod_overview_button_suspend_delivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
binding.buttonSuspendDelivery.visibility = View.VISIBLE
|
||||
binding.buttonSuspendDelivery.isEnabled = podStateManager.isPodRunning && !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_overview_button_suspend_delivery.visibility = View.GONE
|
||||
binding.buttonSuspendDelivery.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSetTimeButton() {
|
||||
if (podStateManager.isPodRunning && (podStateManager.timeDeviatesMoreThan(Duration.standardMinutes(5)) || commandQueue.isCustomCommandInQueue(CommandHandleTimeChange::class.java))) {
|
||||
omnipod_overview_button_set_time.visibility = View.VISIBLE
|
||||
omnipod_overview_button_set_time.isEnabled = !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
binding.buttonSetTime.visibility = View.VISIBLE
|
||||
binding.buttonSetTime.isEnabled = !podStateManager.isSuspended && rileyLinkServiceData.rileyLinkServiceState.isReady && isQueueEmpty()
|
||||
} else {
|
||||
omnipod_overview_button_set_time.visibility = View.GONE
|
||||
binding.buttonSetTime.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="info.nightscout.androidaps.plugins.pump.omnipod.ui.OmnipodOverviewFragment">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/omnipod_overview_buttons"
|
||||
android:layout_above="@+id/buttons"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -69,10 +66,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<com.joanzapata.iconify.widget.IconTextView
|
||||
android:id="@+id/omnipod_overview_riley_link_status"
|
||||
android:id="@+id/riley_link_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -81,7 +79,8 @@
|
|||
android:paddingEnd="5dp"
|
||||
android:text="{fa-bluetooth-b}"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -118,10 +117,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_pod_address"
|
||||
android:id="@+id/pod_address"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -156,10 +156,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_pod_lot"
|
||||
android:id="@+id/pod_lot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -194,10 +195,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_pod_tid"
|
||||
android:id="@+id/pod_tid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -232,10 +234,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_firmware_version"
|
||||
android:id="@+id/firmware_version"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -270,10 +273,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_time_on_pod"
|
||||
android:id="@+id/time_on_pod"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -309,10 +313,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_pod_expiry_date"
|
||||
android:id="@+id/pod_expiry_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -348,10 +353,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<com.joanzapata.iconify.widget.IconTextView
|
||||
android:id="@+id/omnipod_overview_pod_status"
|
||||
android:id="@+id/pod_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -365,7 +371,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_queue"
|
||||
android:id="@+id/queue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
|
@ -403,10 +409,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_last_connection"
|
||||
android:id="@+id/last_connection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -450,10 +457,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_last_bolus"
|
||||
android:id="@+id/last_bolus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -497,10 +505,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_base_basal_rate"
|
||||
android:id="@+id/base_basal_rate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -544,10 +553,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_temp_basal"
|
||||
android:id="@+id/temp_basal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -591,10 +601,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_reservoir"
|
||||
android:id="@+id/reservoir"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -638,10 +649,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_total_delivered"
|
||||
android:id="@+id/total_delivered"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -685,10 +697,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_errors"
|
||||
android:id="@+id/errors"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -732,10 +745,11 @@
|
|||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/omnipod_overview_pod_active_alerts"
|
||||
android:id="@+id/pod_active_alerts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -760,29 +774,24 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:drawableTop="@drawable/ic_pod"
|
||||
android:paddingTop="10dp"
|
||||
android:rotationX="180"
|
||||
android:rotationY="180" />
|
||||
android:rotationY="180"
|
||||
app:drawableTopCompat="@drawable/ic_pod" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/omnipod_overview_buttons"
|
||||
android:id="@+id/buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_refresh_status"
|
||||
android:id="@+id/button_refresh_status"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -792,7 +801,7 @@
|
|||
android:text="@string/refresh" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_pod_management"
|
||||
android:id="@+id/button_pod_management"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -802,7 +811,7 @@
|
|||
android:text="@string/omnipod_overview_button_pod_management" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_acknowledge_active_alerts"
|
||||
android:id="@+id/button_acknowledge_active_alerts"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -812,7 +821,7 @@
|
|||
android:text="@string/omnipod_overview_button_acknowledge_active_alerts" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_set_time"
|
||||
android:id="@+id/button_set_time"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -823,7 +832,7 @@
|
|||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_resume_delivery"
|
||||
android:id="@+id/button_resume_delivery"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -834,7 +843,7 @@
|
|||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/omnipod_overview_button_suspend_delivery"
|
||||
android:id="@+id/button_suspend_delivery"
|
||||
style="@style/ButtonSmallFontStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -846,8 +855,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
Loading…
Reference in a new issue