MedtronicFragment -> jetpack

This commit is contained in:
Milos Kozak 2021-02-03 23:02:14 +01:00
parent 0054fce4d9
commit ee6cd22d24
8 changed files with 582 additions and 582 deletions

View file

@ -504,7 +504,7 @@
android:drawableTop="@drawable/ic_actions_refill" android:drawableTop="@drawable/ic_actions_refill"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/combo_refresh" /> android:text="@string/refresh" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -649,7 +649,6 @@
<string name="maxiobset">Maximal IOB set properly</string> <string name="maxiobset">Maximal IOB set properly</string>
<string name="hasbgdata">BG available from selected source</string> <string name="hasbgdata">BG available from selected source</string>
<string name="combo_programming_bolus">Programming pump for bolusing</string> <string name="combo_programming_bolus">Programming pump for bolusing</string>
<string name="combo_refresh">Refresh</string>
<string name="combo_pump_state_label">State</string> <string name="combo_pump_state_label">State</string>
<string name="combo_pump_activity_label">Activity</string> <string name="combo_pump_activity_label">Activity</string>
<string name="combo_no_pump_connection">No connection for %1$d min</string> <string name="combo_no_pump_connection">No connection for %1$d min</string>
@ -1000,7 +999,6 @@
<string name="eb_formatter">%1$.2f / %2$.2f U for %3$d min</string> <string name="eb_formatter">%1$.2f / %2$.2f U for %3$d min</string>
<string name="enable_tbr_over_notification">Enable notification of TBR end\n(pump setting)</string> <string name="enable_tbr_over_notification">Enable notification of TBR end\n(pump setting)</string>
<string name="disable_tbr_over_notification">Disable notification of TBR end\n(pump setting)</string> <string name="disable_tbr_over_notification">Disable notification of TBR end\n(pump setting)</string>
<string name="refresh">Refresh</string>
<string name="description_pump_insight_local">Pump integration for Accu-Chek Insight pumps</string> <string name="description_pump_insight_local">Pump integration for Accu-Chek Insight pumps</string>
<string name="not_inserted">Not inserted</string> <string name="not_inserted">Not inserted</string>
<string name="short_status_last_connected">Last conn: %1$d min ago</string> <string name="short_status_last_connected">Last conn: %1$d min ago</string>

View file

@ -31,6 +31,7 @@
<string name="key_quickwizard" translatable="false">QuickWizard</string> <string name="key_quickwizard" translatable="false">QuickWizard</string>
<!-- General--> <!-- General-->
<string name="refresh">Refresh</string>
<string name="error">Error</string> <string name="error">Error</string>
<string name="not_set_short">Not set</string> <string name="not_set_short">Not set</string>
<string name="failedupdatebasalprofile">Failed to update basal profile</string> <string name="failedupdatebasalprofile">Failed to update basal profile</string>

View file

@ -1,6 +1,5 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
android { android {
@ -19,6 +18,9 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = '1.8' jvmTarget = '1.8'
} }
buildFeatures {
viewBinding true
}
buildTypes { buildTypes {
release { release {

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.medtronic package info.nightscout.androidaps.plugins.pump.medtronic
import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
@ -17,19 +18,20 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState import info.nightscout.androidaps.plugins.pump.common.events.EventRefreshButtonState
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
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.medtronic.databinding.MedtronicFragmentBinding
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.queue.events.EventQueueChanged import info.nightscout.androidaps.queue.events.EventQueueChanged
@ -42,10 +44,10 @@ import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
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.medtronic_fragment.*
import javax.inject.Inject import javax.inject.Inject
class MedtronicFragment : DaggerFragment() { class MedtronicFragment : DaggerFragment() {
@Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@ -71,21 +73,27 @@ class MedtronicFragment : DaggerFragment() {
} }
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { private var _binding: MedtronicFragmentBinding? = null
return inflater.inflate(R.layout.medtronic_fragment, 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 =
MedtronicFragmentBinding.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)
medtronic_pumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder)) binding.pumpStatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
medtronic_rl_status.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.resourceId) binding.rlStatus.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.resourceId)
medtronic_pump_status.setTextColor(Color.WHITE) binding.pumpStatusIcon.setTextColor(Color.WHITE)
medtronic_pump_status.text = "{fa-bed}" @SuppressLint("SetTextI18n")
binding.pumpStatusIcon.text = "{fa-bed}"
medtronic_history.setOnClickListener { binding.history.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
startActivity(Intent(context, MedtronicHistoryActivity::class.java)) startActivity(Intent(context, MedtronicHistoryActivity::class.java))
} else { } else {
@ -93,21 +101,21 @@ class MedtronicFragment : DaggerFragment() {
} }
} }
medtronic_refresh.setOnClickListener { binding.refresh.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() != true) { if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
displayNotConfiguredDialog() displayNotConfiguredDialog()
} else { } else {
medtronic_refresh.isEnabled = false binding.refresh.isEnabled = false
medtronicPumpPlugin.resetStatusState() medtronicPumpPlugin.resetStatusState()
commandQueue.readStatus("Clicked refresh", object : Callback() { commandQueue.readStatus("Clicked refresh", object : Callback() {
override fun run() { override fun run() {
activity?.runOnUiThread { medtronic_refresh?.isEnabled = true } activity?.runOnUiThread { if (_binding != null) binding.refresh.isEnabled = true }
} }
}) })
} }
} }
medtronic_stats.setOnClickListener { binding.stats.setOnClickListener {
if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { if (medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
startActivity(Intent(context, RileyLinkStatusActivity::class.java)) startActivity(Intent(context, RileyLinkStatusActivity::class.java))
} else { } else {
@ -123,7 +131,7 @@ class MedtronicFragment : DaggerFragment() {
disposable += rxBus disposable += rxBus
.toObservable(EventRefreshButtonState::class.java) .toObservable(EventRefreshButtonState::class.java)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ medtronic_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) }) .subscribe({ binding.refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
disposable += rxBus disposable += rxBus
.toObservable(EventRileyLinkDeviceStatusChange::class.java) .toObservable(EventRileyLinkDeviceStatusChange::class.java)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -170,11 +178,18 @@ class MedtronicFragment : DaggerFragment() {
loopHandler.removeCallbacks(refreshLoop) loopHandler.removeCallbacks(refreshLoop)
} }
@Synchronized
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
@SuppressLint("SetTextI18n")
@Synchronized @Synchronized
private fun setDeviceStatus() { private fun setDeviceStatus() {
val resourceId = rileyLinkServiceData.rileyLinkServiceState.resourceId val resourceId = rileyLinkServiceData.rileyLinkServiceState.resourceId
val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error val rileyLinkError = medtronicPumpPlugin.rileyLinkService?.error
medtronic_rl_status.text = binding.rlStatus.text =
when { when {
rileyLinkServiceData.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId) rileyLinkServiceData.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
rileyLinkServiceData.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId) rileyLinkServiceData.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
@ -182,37 +197,37 @@ class MedtronicFragment : DaggerFragment() {
rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)) rileyLinkServiceData.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId) else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
} }
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE) binding.rlStatus.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
medtronic_errors.text = binding.errors.text =
rileyLinkServiceData.rileyLinkError?.let { rileyLinkServiceData.rileyLinkError?.let {
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump)) resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump))
} ?: "-" } ?: "-"
when (medtronicPumpStatus.pumpDeviceState) { when (medtronicPumpStatus.pumpDeviceState) {
null, null,
PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PumpDeviceState.NeverContacted, PumpDeviceState.NeverContacted,
PumpDeviceState.WakingUp, PumpDeviceState.WakingUp,
PumpDeviceState.PumpUnreachable, PumpDeviceState.PumpUnreachable,
PumpDeviceState.ErrorWhenCommunicating, PumpDeviceState.ErrorWhenCommunicating,
PumpDeviceState.TimeoutWhenCommunicating, PumpDeviceState.TimeoutWhenCommunicating,
PumpDeviceState.InvalidConfiguration -> medtronic_pump_status.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) PumpDeviceState.InvalidConfiguration -> binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
PumpDeviceState.Active -> { PumpDeviceState.Active -> {
val cmd = medtronicUtil.currentCommand val cmd = medtronicUtil.currentCommand
if (cmd == null) if (cmd == null)
medtronic_pump_status.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId)
else { else {
aapsLogger.debug(LTag.PUMP, "Command: " + cmd) aapsLogger.debug(LTag.PUMP, "Command: $cmd")
val cmdResourceId = cmd.resourceId val cmdResourceId = cmd.resourceId
if (cmd == MedtronicCommandType.GetHistoryData) { if (cmd == MedtronicCommandType.GetHistoryData) {
medtronic_pump_status.text = medtronicUtil.frameNumber?.let { binding.pumpStatusIcon.text = medtronicUtil.frameNumber?.let {
resourceHelper.gs(cmdResourceId, medtronicUtil.pageNumber, medtronicUtil.frameNumber) resourceHelper.gs(cmdResourceId, medtronicUtil.pageNumber, medtronicUtil.frameNumber)
} }
?: resourceHelper.gs(R.string.medtronic_cmd_desc_get_history_request, medtronicUtil.pageNumber) ?: resourceHelper.gs(R.string.medtronic_cmd_desc_get_history_request, medtronicUtil.pageNumber)
} else { } else {
medtronic_pump_status.text = " " + (cmdResourceId?.let { resourceHelper.gs(it) } binding.pumpStatusIcon.text = " " + (cmdResourceId?.let { resourceHelper.gs(it) }
?: cmd.getCommandDescription()) ?: cmd.getCommandDescription())
} }
} }
@ -223,10 +238,10 @@ class MedtronicFragment : DaggerFragment() {
val status = commandQueue.spannedStatus() val status = commandQueue.spannedStatus()
if (status.toString() == "") { if (status.toString() == "") {
medtronic_queue.visibility = View.GONE binding.queue.visibility = View.GONE
} else { } else {
medtronic_queue.visibility = View.VISIBLE binding.queue.visibility = View.VISIBLE
medtronic_queue.text = status binding.queue.text = status
} }
} }
@ -238,9 +253,10 @@ class MedtronicFragment : DaggerFragment() {
} }
// GUI functions // GUI functions
@SuppressLint("SetTextI18n")
@Synchronized @Synchronized
fun updateGUI() { fun updateGUI() {
if (medtronic_rl_status == null) return if (_binding == null) return
setDeviceStatus() setDeviceStatus()
@ -249,27 +265,27 @@ class MedtronicFragment : DaggerFragment() {
val minAgo = DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastConnection) val minAgo = DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastConnection)
val min = (System.currentTimeMillis() - medtronicPumpStatus.lastConnection) / 1000 / 60 val min = (System.currentTimeMillis() - medtronicPumpStatus.lastConnection) / 1000 / 60
if (medtronicPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) { if (medtronicPumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
medtronic_lastconnection.setText(R.string.medtronic_pump_connected_now) binding.lastConnection.setText(R.string.medtronic_pump_connected_now)
medtronic_lastconnection.setTextColor(Color.WHITE) binding.lastConnection.setTextColor(Color.WHITE)
} else if (medtronicPumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) { } else if (medtronicPumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
if (min < 60) { if (min < 60) {
medtronic_lastconnection.text = resourceHelper.gs(R.string.minago, min) binding.lastConnection.text = resourceHelper.gs(R.string.minago, min)
} else if (min < 1440) { } else if (min < 1440) {
val h = (min / 60).toInt() val h = (min / 60).toInt()
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.duration_hours, h, h) + " " binding.lastConnection.text = (resourceHelper.gq(R.plurals.duration_hours, h, h) + " "
+ resourceHelper.gs(R.string.ago)) + resourceHelper.gs(R.string.ago))
} else { } else {
val h = (min / 60).toInt() val h = (min / 60).toInt()
val d = h / 24 val d = h / 24
// h = h - (d * 24); // h = h - (d * 24);
medtronic_lastconnection.text = (resourceHelper.gq(R.plurals.duration_days, d, d) + " " binding.lastConnection.text = (resourceHelper.gq(R.plurals.duration_days, d, d) + " "
+ resourceHelper.gs(R.string.ago)) + resourceHelper.gs(R.string.ago))
} }
medtronic_lastconnection.setTextColor(Color.RED) binding.lastConnection.setTextColor(Color.RED)
} else { } else {
medtronic_lastconnection.text = minAgo binding.lastConnection.text = minAgo
medtronic_lastconnection.setTextColor(Color.WHITE) binding.lastConnection.setTextColor(Color.WHITE)
} }
} }
@ -280,39 +296,36 @@ class MedtronicFragment : DaggerFragment() {
val agoMsc = System.currentTimeMillis() - medtronicPumpStatus.lastBolusTime.time val agoMsc = System.currentTimeMillis() - medtronicPumpStatus.lastBolusTime.time
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0 val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
val unit = resourceHelper.gs(R.string.insulin_unit_shortname) val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
val ago: String val ago = when {
if (agoMsc < 60 * 1000) { agoMsc < 60 * 1000 -> resourceHelper.gs(R.string.medtronic_pump_connected_now)
ago = resourceHelper.gs(R.string.medtronic_pump_connected_now) bolusMinAgo < 60 -> DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastBolusTime.time)
} else if (bolusMinAgo < 60) { else -> DateUtil.hourAgo(medtronicPumpStatus.lastBolusTime.time, resourceHelper)
ago = DateUtil.minAgo(resourceHelper, medtronicPumpStatus.lastBolusTime.time)
} else {
ago = DateUtil.hourAgo(medtronicPumpStatus.lastBolusTime.time, resourceHelper)
} }
medtronic_lastbolus.text = resourceHelper.gs(R.string.mdt_last_bolus, bolus, unit, ago) binding.lastBolus.text = resourceHelper.gs(R.string.mdt_last_bolus, bolus, unit, ago)
} else { } else {
medtronic_lastbolus.text = "" binding.lastBolus.text = ""
} }
// base basal rate // base basal rate
medtronic_basabasalrate.text = ("(" + medtronicPumpStatus.activeProfileName + ") " binding.baseBasalRate.text = ("(" + medtronicPumpStatus.activeProfileName + ") "
+ resourceHelper.gs(R.string.pump_basebasalrate, medtronicPumpPlugin.baseBasalRate)) + resourceHelper.gs(R.string.pump_basebasalrate, medtronicPumpPlugin.baseBasalRate))
medtronic_tempbasal.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() binding.tempBasal.text = activePlugin.activeTreatments.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull()
?: "" ?: ""
// battery // battery
if (medtronicPumpStatus.batteryType == BatteryType.None || medtronicPumpStatus.batteryVoltage == null) { if (medtronicPumpStatus.batteryType == BatteryType.None || medtronicPumpStatus.batteryVoltage == null) {
medtronic_pumpstate_battery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} " binding.pumpStateBattery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} "
} else { } else {
medtronic_pumpstate_battery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} " + medtronicPumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", medtronicPumpStatus.batteryVoltage) binding.pumpStateBattery.text = "{fa-battery-" + medtronicPumpStatus.batteryRemaining / 25 + "} " + medtronicPumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", medtronicPumpStatus.batteryVoltage)
} }
warnColors.setColorInverse(medtronic_pumpstate_battery, medtronicPumpStatus.batteryRemaining.toDouble(), 25.0, 10.0) warnColors.setColorInverse(binding.pumpStateBattery, medtronicPumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
// reservoir // reservoir
medtronic_reservoir.text = resourceHelper.gs(R.string.reservoirvalue, medtronicPumpStatus.reservoirRemainingUnits, medtronicPumpStatus.reservoirFullUnits) binding.reservoir.text = resourceHelper.gs(R.string.reservoirvalue, medtronicPumpStatus.reservoirRemainingUnits, medtronicPumpStatus.reservoirFullUnits)
warnColors.setColorInverse(medtronic_reservoir, medtronicPumpStatus.reservoirRemainingUnits, 50.0, 20.0) warnColors.setColorInverse(binding.reservoir, medtronicPumpStatus.reservoirRemainingUnits, 50.0, 20.0)
medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() medtronicPumpPlugin.rileyLinkService?.verifyConfiguration()
medtronic_errors.text = medtronicPumpStatus.errorInfo binding.errors.text = medtronicPumpStatus.errorInfo
} }
} }

View file

@ -1,18 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment"> tools:context="info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/medtronic_buttons" android:layout_above="@+id/buttons"
android:fillViewport="true"> android:fillViewport="true">
@ -22,16 +18,16 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/overview_pumpstatuslayout" android:id="@+id/pump_status_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="5dp"
android:visibility="gone"> android:visibility="gone">
<TextView <TextView
android:id="@+id/medtronic_pumpstatus" android:id="@+id/pump_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
@ -45,10 +41,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -70,13 +66,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView <com.joanzapata.iconify.widget.IconTextView
android:id="@+id/medtronic_rl_status" android:id="@+id/rl_status"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -93,10 +89,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -118,13 +114,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView <com.joanzapata.iconify.widget.IconTextView
android:id="@+id/medtronic_pump_status" android:id="@+id/pump_status_icon"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -138,7 +134,7 @@
</LinearLayout> </LinearLayout>
<TextView <TextView
android:id="@+id/medtronic_queue" android:id="@+id/queue"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="content" android:text="content"
@ -147,10 +143,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -172,20 +168,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<com.joanzapata.iconify.widget.IconTextView <com.joanzapata.iconify.widget.IconTextView
android:id="@+id/medtronic_pumpstate_battery" android:id="@+id/pump_state_battery"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:gravity="start" android:gravity="start"
android:paddingLeft="5dp" android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:text="" android:text=""
android:textColor="@android:color/white"
android:textSize="14sp" /> android:textSize="14sp" />
@ -194,10 +190,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -219,13 +215,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_lastconnection" android:id="@+id/last_connection"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -239,10 +235,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -264,13 +260,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_lastbolus" android:id="@+id/last_bolus"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -285,10 +281,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -310,13 +306,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_basabasalrate" android:id="@+id/base_basal_rate"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -330,10 +326,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -355,13 +351,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_tempbasal" android:id="@+id/temp_basal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -375,10 +371,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
@ -401,13 +397,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_reservoir" android:id="@+id/reservoir"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -422,10 +418,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<LinearLayout <LinearLayout
@ -447,13 +443,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0" android:layout_weight="0"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp" android:paddingStart="2dp"
android:paddingEnd="2dp"
android:text=":" android:text=":"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <TextView
android:id="@+id/medtronic_errors" android:id="@+id/errors"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
@ -467,10 +463,10 @@
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="5dp"
android:background="@color/listdelimiter" /> android:background="@color/listdelimiter" />
<TextView <TextView
@ -485,20 +481,14 @@
</ScrollView> </ScrollView>
<LinearLayout <LinearLayout
android:id="@+id/medtronic_buttons" android:id="@+id/buttons"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:id="@+id/medtronic_refresh" android:id="@+id/refresh"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -506,11 +496,11 @@
android:drawableTop="@drawable/ic_actions_refill" android:drawableTop="@drawable/ic_actions_refill"
android:paddingLeft="0dp" android:paddingLeft="0dp"
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="@string/combo_refresh" /> android:text="@string/refresh" />
<Button <Button
android:id="@+id/medtronic_history" android:id="@+id/history"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -521,7 +511,7 @@
android:text="@string/pumphistory" /> android:text="@string/pumphistory" />
<Button <Button
android:id="@+id/medtronic_stats" android:id="@+id/stats"
style="@style/ButtonSmallFontStyle" style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -531,10 +521,7 @@
android:paddingRight="0dp" android:paddingRight="0dp"
android:text="RL Stats" /> android:text="RL Stats" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
</FrameLayout>

View file

@ -789,7 +789,7 @@
android:layout_weight="1" android:layout_weight="1"
android:drawableTop="@drawable/ic_omnipod_overview_refresh_pod_status" android:drawableTop="@drawable/ic_omnipod_overview_refresh_pod_status"
android:drawablePadding="@dimen/omnipod_icon_button_drawable_padding" android:drawablePadding="@dimen/omnipod_icon_button_drawable_padding"
android:text="@string/omnipod_overview_button_refresh" /> android:text="@string/refresh" />
<Button <Button
android:id="@+id/omnipod_overview_button_pod_management" android:id="@+id/omnipod_overview_button_pod_management"

View file

@ -244,7 +244,6 @@
<!-- Omnipod - Overview --> <!-- Omnipod - Overview -->
<string name="omnipod_overview_button_set_time">Set time</string> <string name="omnipod_overview_button_set_time">Set time</string>
<string name="omnipod_overview_button_suspend_delivery">Suspend</string> <string name="omnipod_overview_button_suspend_delivery">Suspend</string>
<string name="omnipod_overview_button_refresh">Refresh</string>
<string name="omnipod_overview_button_resume_delivery">Resume Delivery</string> <string name="omnipod_overview_button_resume_delivery">Resume Delivery</string>
<string name="omnipod_overview_button_pod_management">Pod Mgmt</string> <string name="omnipod_overview_button_pod_management">Pod Mgmt</string>
<string name="omnipod_overview_button_acknowledge_active_alerts">Ack Alerts</string> <string name="omnipod_overview_button_acknowledge_active_alerts">Ack Alerts</string>