Pump status line refactor

This commit is contained in:
Milos Kozak 2021-10-04 17:35:17 +02:00
parent da481f0da4
commit f802cc488e
22 changed files with 848 additions and 899 deletions

View file

@ -63,7 +63,8 @@ class OverviewData @Inject constructor(
BG,
IOB_COB,
SENSITIVITY,
GRAPH
GRAPH,
PUMPSTATUS
}
var rangeToDisplay = 6 // for graph
@ -72,6 +73,7 @@ class OverviewData @Inject constructor(
var endTime: Long = 0
fun reset() {
pumpStatus = ""
calcProgress = ""
lastBg = null
temporaryBasal = null
@ -122,6 +124,12 @@ class OverviewData @Inject constructor(
endTime = toTime
}
/*
* PUMP STATUS
*/
var pumpStatus: String = ""
/*
* CALC PROGRESS
*/

View file

@ -61,7 +61,11 @@ import info.nightscout.androidaps.plugins.source.DexcomPlugin
import info.nightscout.androidaps.plugins.source.XdripPlugin
import info.nightscout.androidaps.queue.CommandQueue
import info.nightscout.androidaps.skins.SkinProvider
import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.TrendCalculator
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.protection.ProtectionCheck
@ -73,6 +77,7 @@ import info.nightscout.androidaps.utils.wizard.QuickWizard
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import java.util.*
import java.util.concurrent.TimeUnit
import javax.inject.Inject
import kotlin.collections.ArrayList
import kotlin.math.abs
@ -159,8 +164,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, landscape, resourceHelper.gb(R.bool.isTablet), smallHeight)
binding.nsclientLayout.visibility = config.NSCLIENT.toVisibility()
binding.loopPumpStatusLayout.pumpStatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
binding.notifications.setHasFixedSize(false)
binding.notifications.layoutManager = LinearLayoutManager(view.context)
axisWidth = if (dm.densityDpi <= 120) 3 else if (dm.densityDpi <= 160) 10 else if (dm.densityDpi <= 320) 35 else if (dm.densityDpi <= 420) 50 else if (dm.densityDpi <= 560) 70 else 80
@ -189,10 +192,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
prepareGraphsIfNeeded(overviewMenus.setting.size)
overviewMenus.setupChartMenu(binding.graphsLayout.chartMenuButton)
binding.loopPumpStatusLayout.activeProfile.setOnClickListener(this)
binding.loopPumpStatusLayout.activeProfile.setOnLongClickListener(this)
binding.loopPumpStatusLayout.tempTarget.setOnClickListener(this)
binding.loopPumpStatusLayout.tempTarget.setOnLongClickListener(this)
binding.activeProfile.setOnClickListener(this)
binding.activeProfile.setOnLongClickListener(this)
binding.tempTarget.setOnClickListener(this)
binding.tempTarget.setOnLongClickListener(this)
binding.buttonsLayout.acceptTempButton.setOnClickListener(this)
binding.buttonsLayout.treatmentButton.setOnClickListener(this)
binding.buttonsLayout.wizardButton.setOnClickListener(this)
@ -204,7 +207,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
binding.buttonsLayout.quickWizardButton.setOnLongClickListener(this)
binding.infoLayout.apsMode.setOnClickListener(this)
binding.infoLayout.apsMode.setOnLongClickListener(this)
binding.loopPumpStatusLayout.activeProfile.setOnLongClickListener(this)
binding.activeProfile.setOnLongClickListener(this)
}
@Synchronized
@ -245,10 +248,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
.toObservable(EventNewOpenLoopNotification::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ scheduleUpdateGUI("EventNewOpenLoopNotification") }, fabricPrivacy::logException))
disposable.add(rxBus
disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main)
.subscribe({ updatePumpStatus(it) }, fabricPrivacy::logException))
.delay (30, TimeUnit.MILLISECONDS, aapsSchedulers.main)
.subscribe({
overviewData.pumpStatus = it.getStatus(resourceHelper)
updateGUI("EventPumpStatusChanged", OverviewData.Property.PUMPSTATUS)
}, fabricPrivacy::logException)
refreshLoop = Runnable {
overviewPlugin.refreshLoop("refreshLoop")
@ -406,18 +413,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
}
private fun updatePumpStatus(event: EventPumpStatusChanged) {
val status = event.getStatus(resourceHelper)
if (status != "") {
binding.loopPumpStatusLayout.pumpStatus.text = status
binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.VISIBLE
binding.loopPumpStatusLayout.loopLayout.visibility = View.GONE
} else {
binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.GONE
binding.loopPumpStatusLayout.loopLayout.visibility = View.VISIBLE
}
}
@SuppressLint("SetTextI18n")
private fun processButtonsVisibility() {
val lastBG = iobCobCalculator.ads.lastBg()
@ -600,14 +595,11 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
// if (what != OverviewData.Property.CALC_PROGRESS)
// aapsLogger.debug(LTag.UI, "UpdateGui $from $what")
if (profileFunction.getProfile() == null) {
binding.loopPumpStatusLayout.pumpStatus.setText(R.string.noprofileset)
binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.VISIBLE
binding.loopPumpStatusLayout.loopLayout.visibility = View.GONE
binding.activeProfile.setText(R.string.noprofileset)
binding.activeProfile.setBackgroundColor(resourceHelper.gc(R.color.errorAlertBackground))
return
}
binding.notifications.let { notificationStore.updateNotifications(it) }
binding.loopPumpStatusLayout.pumpStatusLayout.visibility = View.GONE
binding.loopPumpStatusLayout.loopLayout.visibility = View.VISIBLE
val units = profileFunction.getUnits()
val pump = activePlugin.activePump
@ -658,9 +650,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
else resourceHelper.gc(R.color.ribbonTextDefault)
} ?: resourceHelper.gc(R.color.ribbonTextDefault)
binding.loopPumpStatusLayout.activeProfile.text = profileFunction.getProfileNameWithRemainingTime()
binding.loopPumpStatusLayout.activeProfile.setBackgroundColor(profileBackgroundColor)
binding.loopPumpStatusLayout.activeProfile.setTextColor(profileTextColor)
binding.activeProfile.text = profileFunction.getProfileNameWithRemainingTime()
binding.activeProfile.setBackgroundColor(profileBackgroundColor)
binding.activeProfile.setTextColor(profileTextColor)
}
OverviewData.Property.TEMPORARY_BASAL -> {
@ -721,9 +713,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (overviewData.temporaryTarget?.isInProgress(dateUtil) == false) overviewData.temporaryTarget = null
val tempTarget = overviewData.temporaryTarget
if (tempTarget != null) {
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(tempTarget.lowTarget, tempTarget.highTarget, GlucoseUnit.MGDL, units) + " " + dateUtil.untilString(tempTarget.end, resourceHelper)
binding.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
binding.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
binding.tempTarget.text = Profile.toTargetRangeString(tempTarget.lowTarget, tempTarget.highTarget, GlucoseUnit.MGDL, units) + " " + dateUtil.untilString(tempTarget.end, resourceHelper)
} else {
// If the target is not the same as set in the profile then oref has overridden it
profileFunction.getProfile()?.let { profile ->
@ -731,13 +723,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (targetUsed != 0.0 && abs(profile.getTargetMgdl() - targetUsed) > 0.01) {
aapsLogger.debug("Adjusted target. Profile: ${profile.getTargetMgdl()} APS: $targetUsed")
binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(targetUsed, targetUsed, GlucoseUnit.MGDL, units)
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground))
binding.tempTarget.text = Profile.toTargetRangeString(targetUsed, targetUsed, GlucoseUnit.MGDL, units)
binding.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
binding.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground))
} else {
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
binding.loopPumpStatusLayout.tempTarget.text = Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), GlucoseUnit.MGDL, units)
binding.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
binding.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
binding.tempTarget.text = Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), GlucoseUnit.MGDL, units)
}
}
}
@ -832,6 +824,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
String.format(Locale.ENGLISH, "%.0f%%", autosensData.autosensResult.ratio * 100)
} ?: ""
}
OverviewData.Property.PUMPSTATUS -> {
val status = overviewData.pumpStatus
binding.pumpStatus.text = status
binding.pumpStatusLayout.visibility = (status != "").toVisibility()
}
}
}
}

View file

@ -135,16 +135,22 @@ class OverviewPlugin @Inject constructor(
.toObservable(EventLoopInvoked::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ overviewData.preparePredictions("EventLoopInvoked") }, fabricPrivacy::logException)
disposable.add(rxBus
disposable += rxBus
.toObservable(EventNewBasalProfile::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ loadProfile("EventNewBasalProfile") }, fabricPrivacy::logException))
disposable.add(rxBus
.subscribe({ loadProfile("EventNewBasalProfile") }, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventAutosensCalculationFinished::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({
if (it.cause !is EventCustomCalculationFinished) refreshLoop("EventAutosensCalculationFinished")
}, fabricPrivacy::logException))
}, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({
overviewData.pumpStatus = it.getStatus(resourceHelper)
}, fabricPrivacy::logException)
Thread { loadAll("onResume") }.start()
}

View file

@ -135,6 +135,7 @@ class QueueThread internal constructor(
aapsLogger.debug(LTag.PUMPQUEUE, "disconnected")
return
} else {
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.WAITING_FOR_DISCONNECTION))
aapsLogger.debug(LTag.PUMPQUEUE, "waiting for disconnect")
SystemClock.sleep(1000)
}

View file

@ -273,7 +273,7 @@
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_danarhistory"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/nav_historybrowser"

View file

@ -273,7 +273,7 @@
style="@style/ButtonSmallFontStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_danarhistory"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/nav_historybrowser"

View file

@ -10,8 +10,7 @@
android:id="@+id/top_part_scrollbar"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
tools:ignore="UselessParent">
android:layout_weight="1">
<LinearLayout
android:id="@+id/inner_layout"
@ -24,9 +23,42 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="@+id/loop_pump_status_layout"
layout="@layout/overview_loop_pumpstatus_layout" />
<LinearLayout
android:id="@+id/loop_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/active_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="Profile"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/temp_target"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="TempTarget"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/mdtp_white"
tools:ignore="HardcodedText" />
</LinearLayout>
<include
android:id="@+id/info_layout"
@ -92,6 +124,28 @@
</ScrollView>
<LinearLayout
android:id="@+id/pump_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/pump_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/pumpStatusBackground"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<include
android:id="@+id/buttons_layout"
layout="@layout/overview_buttons_layout" />

View file

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/loop_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/active_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="Profile"
android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/temp_target"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="TempTarget"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/mdtp_white"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:id="@+id/pump_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:id="@+id/pump_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>

View file

@ -10,6 +10,7 @@ class EventPumpStatusChanged : EventStatus {
CONNECTED,
HANDSHAKING,
PERFORMING,
WAITING_FOR_DISCONNECTION,
DISCONNECTING,
DISCONNECTED
}
@ -50,6 +51,7 @@ class EventPumpStatusChanged : EventStatus {
Status.HANDSHAKING -> resourceHelper.gs(R.string.handshaking)
Status.CONNECTED -> resourceHelper.gs(R.string.connected)
Status.PERFORMING -> performingAction
Status.WAITING_FOR_DISCONNECTION -> resourceHelper.gs(R.string.waiting_for_disconnection)
Status.DISCONNECTING -> resourceHelper.gs(R.string.disconnecting)
Status.DISCONNECTED -> ""
}

View file

@ -12,7 +12,7 @@
<color name="black_overlay">#66000000</color>
<!-- Fragments-->
<color name="colorInitializingBorder">#00695c</color>
<color name="pumpStatusBackground">#505050</color>
<!-- Dialogs-->
<color name="dialog_title_background">#303030</color>

View file

@ -81,6 +81,7 @@
<string name="connected">Connected</string>
<string name="disconnected">Disconnected</string>
<string name="disconnecting">Disconnecting</string>
<string name="waiting_for_disconnection">Waiting for disconnection</string>
<string name="androidaps_start">AndroidAPS started</string>
<string name="formatinsulinunits1">%1$.1f U</string>
<string name="formatinsulinunits">%1$.2f U</string>
@ -289,6 +290,8 @@
<string name="loop">Loop</string>
<string name="ns">NS</string>
<string name="record">Record</string>
<string name="reading_pump_history">Reading pump history</string>
<string name="pump_icon">Pump icon</string>
<!-- Command-->
<string name="connectiontimedout">Connection timed out</string>

View file

@ -64,6 +64,8 @@ class DanaFragment : DaggerFragment() {
private val loopHandler = Handler(Looper.getMainLooper())
private lateinit var refreshLoop: Runnable
private var pumpStatus = ""
private var pumpStatusIcon = "{fa-bluetooth-b}"
private var _binding: DanarFragmentBinding? = null
@ -87,10 +89,8 @@ class DanaFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.danaPumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
binding.history.setOnClickListener { startActivity(Intent(context, DanaHistoryActivity::class.java)) }
binding.viewprofile.setOnClickListener {
binding.viewProfile.setOnClickListener {
val profile = danaPump.createConvertedProfile()?.getDefaultProfileJson()
?: return@setOnClickListener
val profileName = danaPump.createConvertedProfile()?.getDefaultProfileName()
@ -152,31 +152,25 @@ class DanaFragment : DaggerFragment() {
.toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main)
.subscribe({
when (it.status) {
pumpStatusIcon = when (it.status) {
EventPumpStatusChanged.Status.CONNECTING ->
@Suppress("SetTextI18n")
binding.btconnection.text = "{fa-bluetooth-b spin} ${it.secondsElapsed}s"
"{fa-bluetooth-b spin} ${it.secondsElapsed}s"
EventPumpStatusChanged.Status.CONNECTED ->
@Suppress("SetTextI18n")
binding.btconnection.text = "{fa-bluetooth}"
"{fa-bluetooth}"
EventPumpStatusChanged.Status.DISCONNECTED ->
@Suppress("SetTextI18n")
binding.btconnection.text = "{fa-bluetooth-b}"
"{fa-bluetooth-b}"
else -> {
}
}
if (it.getStatus(resourceHelper) != "") {
binding.danaPumpstatus.text = it.getStatus(resourceHelper)
binding.danaPumpstatuslayout.visibility = View.VISIBLE
} else {
binding.danaPumpstatuslayout.visibility = View.GONE
else ->
"{fa-bluetooth-b}"
}
binding.btconnection.text = pumpStatusIcon
pumpStatus = it.getStatus(resourceHelper)
binding.pumpStatus.text = pumpStatus
binding.pumpStatusLayout.visibility = (pumpStatus != "").toVisibility()
}, fabricPrivacy::logException)
binding.danaPumpstatus.text = ""
binding.danaPumpstatuslayout.visibility = View.GONE
@Suppress("SetTextI18n")
binding.btconnection.text = "{fa-bluetooth-b}"
pumpStatus = ""
pumpStatusIcon = "{fa-bluetooth-b}"
updateGUI()
}
@ -185,6 +179,8 @@ class DanaFragment : DaggerFragment() {
super.onPause()
disposable.clear()
loopHandler.removeCallbacks(refreshLoop)
pumpStatus = ""
pumpStatusIcon = "{fa-bluetooth-b}"
}
@Synchronized
@ -197,6 +193,11 @@ class DanaFragment : DaggerFragment() {
@Synchronized
fun updateGUI() {
if (_binding == null) return
binding.btconnection.text = pumpStatusIcon
binding.pumpStatus.text = pumpStatus
binding.pumpStatusLayout.visibility = (pumpStatus != "").toVisibility()
binding.queue.text = commandQueue.spannedStatus()
binding.queueStatusLayout.visibility = (commandQueue.spannedStatus().toString() != "").toVisibility()
val pump = danaPump
val plugin: Pump = activePlugin.activePump
if (pump.lastConnection != 0L) {
@ -225,18 +226,9 @@ class DanaFragment : DaggerFragment() {
warnColors.setColorInverse(binding.reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
binding.battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
warnColors.setColorInverse(binding.battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
binding.iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob)
binding.firmware.text = resourceHelper.gs(R.string.dana_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode)
binding.basalstep.text = pump.basalStep.toString()
binding.bolusstep.text = pump.bolusStep.toString()
binding.basalBolusStep.text = pump.basalStep.toString() + "/" + pump.bolusStep.toString()
binding.serialNumber.text = pump.serialNumber
val status = commandQueue.spannedStatus()
if (status.toString() == "") {
binding.queue.visibility = View.GONE
} else {
binding.queue.visibility = View.VISIBLE
binding.queue.text = status
}
val icon = if (danaPump.pumpType() == PumpType.DANA_I) R.drawable.ic_dana_i else R.drawable.ic_dana_rs
binding.danaIcon.setImageDrawable(context?.let { ContextCompat.getDrawable(it, icon) })
//hide user options button if not an RS pump or old firmware

View file

@ -1,46 +1,22 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="5dp"
tools:context="info.nightscout.androidaps.dana.DanaFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
tools:context="info.nightscout.androidaps.dana.DanaFragment"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttons"
android:fillViewport="true">
android:layout_height="0dp"
android:paddingTop="5dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/dana_pumpstatuslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingTop="2dp"
android:visibility="gone">
<TextView
android:id="@+id/dana_pumpstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -51,9 +27,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/serialnumber"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -63,7 +40,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/serial_number"
@ -71,9 +49,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -97,9 +76,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/danar_bluetooth_status"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -109,7 +89,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/btconnection"
@ -117,21 +98,15 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:text="{fa-bluetooth-b}"
android:textColor="@android:color/white"
android:textSize="20dp" />
android:textSize="14sp"
tools:ignore="HardcodedText,RtlSymmetry" />
</LinearLayout>
<TextView
android:id="@+id/queue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="content"
android:textAlignment="center" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
@ -151,9 +126,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/battery_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -163,7 +139,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<com.joanzapata.iconify.widget.IconTextView
android:id="@+id/battery"
@ -171,9 +148,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="20dp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -197,9 +175,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/lastconnection_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -209,7 +188,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/lastconnection"
@ -217,9 +197,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -242,9 +223,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/lastbolus_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -254,7 +236,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/lastbolus"
@ -262,9 +245,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -287,9 +271,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/dailyunits"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -299,7 +284,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/dailyunits"
@ -307,9 +293,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -334,7 +321,8 @@
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/basebasalrate_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlHardcoded,RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -344,7 +332,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/basabasalrate"
@ -352,9 +341,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -377,9 +367,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/tempbasal_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -389,7 +380,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tempbasal"
@ -397,9 +389,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -422,9 +415,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/virtualpump_extendedbolus_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -434,7 +428,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/extendedbolus"
@ -442,9 +437,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -467,9 +463,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/reservoir_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -479,7 +476,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/reservoir"
@ -487,9 +485,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -512,9 +511,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/danar_iob_label"
android:textSize="14sp" />
android:paddingEnd="5dp"
android:text="@string/basal_bolus_step"
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -524,17 +524,19 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/iob"
android:id="@+id/basal_bolus_step"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -557,99 +559,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/basal_step"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/basalstep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/list_delimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/bolus_step"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/bolusstep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/list_delimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="5dp"
android:paddingEnd="5dp"
android:text="@string/virtualpump_firmware_label"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
<TextView
android:layout_width="5dp"
@ -659,7 +572,8 @@
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/firmware"
@ -667,9 +581,10 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:paddingStart="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="14sp"
tools:ignore="RtlSymmetry" />
</LinearLayout>
@ -688,26 +603,65 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableTop="@drawable/ic_dana_rs"
android:paddingTop="10dp" />
android:paddingTop="10dp"
android:contentDescription="@string/pump_icon" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttons"
android:id="@+id/pump_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
android:orientation="horizontal"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:visibility="visible">
<TextView
android:id="@+id/pump_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/pumpStatusBackground"
android:gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:id="@+id/queue_status_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:visibility="visible">
<TextView
android:id="@+id/queue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/pumpStatusBackground"
android:gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/viewprofile"
android:id="@+id/view_profile"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -724,10 +678,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/ic_danarhistory"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/pumphistory" />
android:text="@string/pumphistory"
tools:ignore="TooManyViews" />
<Button
android:id="@+id/stats"
@ -753,8 +708,4 @@
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</FrameLayout>
</LinearLayout>

View file

@ -28,7 +28,7 @@
android:contentDescription="@string/pumphistory"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_danarhistory" />
app:srcCompat="@drawable/ic_pump_history" />
<TextView
android:id="@+id/textView2"

View file

@ -108,8 +108,6 @@
<string name="profile_set_failed">Setting of basal profile failed</string>
<string name="danar_bluetooth_status">Bluetooth status</string>
<string name="danar_iob_label">Pump IOB</string>
<string name="basal_step">Basal Step</string>
<string name="bolus_step">Bolus Step</string>
<string name="virtualpump_firmware_label">Firmware</string>
<string name="danar_pump_settings">Dana pump settings</string>
<string name="timeformat12h">12h</string>
@ -131,5 +129,6 @@
<string name="press_ok_on_the_pump">Press OK on the pump\nand enter 2 displayed numbers\nKeep display on pump ON by pressing minus button until you finish entering code.</string>
<string name="num1pin">1: (12 digits)</string>
<string name="num2pin">2: (8 digits)</string>
<string name="basal_bolus_step">Basal/bolus step</string>
</resources>

View file

@ -190,6 +190,7 @@ class DanaRSService : DaggerService() {
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds")
}
}
rxBus.send(EventPumpStatusChanged(resourceHelper.gs(R.string.reading_pump_history)))
loadEvents()
// RS doesn't provide exact timestamp = rely on history
val eb = pumpSync.expectedPumpState().extendedBolus

View file

@ -10,6 +10,8 @@ import android.view.View
import android.view.ViewGroup
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.activities.TDDStatsActivity
import info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity
import info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity
import info.nightscout.androidaps.diaconn.databinding.DiaconnG8FragmentBinding
import info.nightscout.androidaps.diaconn.events.EventDiaconnG8NewStatus
import info.nightscout.androidaps.events.EventExtendedBolusChange
@ -74,10 +76,9 @@ class DiaconnG8Fragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.diaconnG8Pumpstatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
binding.history.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.diaconn.activities.DiaconnG8HistoryActivity::class.java)) }
binding.history.setOnClickListener { startActivity(Intent(context, DiaconnG8HistoryActivity::class.java)) }
binding.stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, info.nightscout.androidaps.diaconn.activities.DiaconnG8UserOptionsActivity::class.java)) }
binding.userOptions.setOnClickListener { startActivity(Intent(context, DiaconnG8UserOptionsActivity::class.java)) }
binding.btconnection.setOnClickListener {
aapsLogger.debug(LTag.PUMP, "Clicked connect to pump")
diaconnG8Pump.lastConnection = 0

View file

@ -36,6 +36,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/pumpStatusBackground"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -678,7 +679,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:drawableTop="@drawable/ic_danarhistory"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/pumphistory" />

View file

@ -21,7 +21,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/pumphistory"
app:srcCompat="@drawable/ic_danarhistory" />
app:srcCompat="@drawable/ic_pump_history" />
<TextView
android:layout_width="match_parent"

View file

@ -90,8 +90,6 @@ class MedtronicFragment : DaggerFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.pumpStatus.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
binding.rlStatus.text = resourceHelper.gs(RileyLinkServiceState.NotStarted.resourceId)
binding.pumpStatusIcon.setTextColor(Color.WHITE)

View file

@ -32,6 +32,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@color/pumpStatusBackground"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceSmall" />
@ -557,7 +558,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/ic_danarhistory"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/pumphistory" />