Merge pull request #1264 from Andries-Smit/feat/status-light-icon

feat: show patch pump icon instead of cannula
This commit is contained in:
Milos Kozak 2022-02-10 22:35:41 +01:00 committed by GitHub
commit fa2029b9ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 47 additions and 12 deletions

View file

@ -107,6 +107,7 @@ class ActionsFragment : DaggerFragment() {
private var sensorLevelLabel: TextView? = null private var sensorLevelLabel: TextView? = null
private var insulinLevelLabel: TextView? = null private var insulinLevelLabel: TextView? = null
private var pbLevelLabel: TextView? = null private var pbLevelLabel: TextView? = null
private var cannulaOrPatch: TextView? = null
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
@ -153,6 +154,7 @@ class ActionsFragment : DaggerFragment() {
sensorLevelLabel = view.findViewById(R.id.sensor_level_label) sensorLevelLabel = view.findViewById(R.id.sensor_level_label)
insulinLevelLabel = view.findViewById(R.id.insulin_level_label) insulinLevelLabel = view.findViewById(R.id.insulin_level_label)
pbLevelLabel = view.findViewById(R.id.pb_level_label) pbLevelLabel = view.findViewById(R.id.pb_level_label)
cannulaOrPatch = view.findViewById(R.id.cannula_or_patch)
profileSwitch?.setOnClickListener { profileSwitch?.setOnClickListener {
ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog")
@ -319,6 +321,10 @@ class ActionsFragment : DaggerFragment() {
tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility() tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility()
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
cannulaOrPatch?.text = if (pump.pumpDescription.isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
val imageResource = if (pump.pumpDescription.isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula
cannulaOrPatch?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0)
if (!config.NSCLIENT) { if (!config.NSCLIENT) {
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel) statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
sensorLevelLabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label) sensorLevelLabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label)

View file

@ -823,7 +823,15 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
fun updateTime(from: String) { fun updateTime(from: String) {
binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now()) binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now())
// Status lights // Status lights
binding.statusLightsLayout.statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() val isPatchPump = activePlugin.activePump.pumpDescription.isPatchPump
binding.statusLightsLayout.apply {
cannulaOrPatch.setImageResource(if (isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula)
cannulaOrPatch.contentDescription = rh.gs(if (isPatchPump) R.string.statuslights_patch_pump_age else R.string.statuslights_cannula_age)
cannulaOrPatch.scaleX = if (isPatchPump) 1.4f else 2f
cannulaOrPatch.scaleY = cannulaOrPatch.scaleX
insulinAge.visibility = isPatchPump.not().toVisibility()
statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility()
}
statusLightHandler.updateStatusLights( statusLightHandler.updateStatusLights(
binding.statusLightsLayout.cannulaAge, binding.statusLightsLayout.cannulaAge,
binding.statusLightsLayout.insulinAge, binding.statusLightsLayout.insulinAge,

View file

@ -40,12 +40,7 @@ class StatusLightHandler @Inject constructor(
val pump = activePlugin.activePump val pump = activePlugin.activePump
val bgSource = activePlugin.activeBgSource val bgSource = activePlugin.activeBgSource
handleAge(careportal_cannula_age, TherapyEvent.Type.CANNULA_CHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0) handleAge(careportal_cannula_age, TherapyEvent.Type.CANNULA_CHANGE, R.string.key_statuslights_cage_warning, 48.0, R.string.key_statuslights_cage_critical, 72.0)
if (pump.model() == PumpType.OMNIPOD_EROS || pump.model() == PumpType.OMNIPOD_DASH) {
careportal_insulin_age?.visibility = View.GONE
} else {
careportal_insulin_age?.visibility = View.VISIBLE
handleAge(careportal_insulin_age, TherapyEvent.Type.INSULIN_CHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0) handleAge(careportal_insulin_age, TherapyEvent.Type.INSULIN_CHANGE, R.string.key_statuslights_iage_warning, 72.0, R.string.key_statuslights_iage_critical, 144.0)
}
handleAge(careportal_sensor_age, TherapyEvent.Type.SENSOR_CHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0) handleAge(careportal_sensor_age, TherapyEvent.Type.SENSOR_CHANGE, R.string.key_statuslights_sage_warning, 216.0, R.string.key_statuslights_sage_critical, 240.0)
if (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)) { if (pump.pumpDescription.isBatteryReplaceable || (pump is OmnipodErosPumpPlugin && pump.isUseRileyLinkBatteryLevel && pump.isBatteryChangeLoggingEnabled)) {
handleAge(careportal_pb_age, TherapyEvent.Type.PUMP_BATTERY_CHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0) handleAge(careportal_pb_age, TherapyEvent.Type.PUMP_BATTERY_CHANGE, R.string.key_statuslights_bage_warning, 216.0, R.string.key_statuslights_bage_critical, 240.0)

View file

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="80"
android:viewportHeight="80">
<path
android:fillAlpha="0.5"
android:fillColor="#FFFFFF"
android:pathData="M 18 54 a 3 3 0 0 0 3 3 L 45 57 A 19 19 0 0 0 62 40 A 19 19 0 0 0 45 24 L 21 24 a 3 3 0 0 0 -3 3 Z M 67 40 A 22 22 0 0 1 45 62 L 19 62 a 6 6 0 0 1 -6 -6 L 13 25 a 6 6 0 0 1 6 -6 L 45 19 A 22 22 0 0 1 67 40"
android:strokeAlpha="0.5" />
</vector>

View file

@ -161,6 +161,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/cannula_or_patch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="25dp" android:layout_height="25dp"
android:gravity="center_vertical" android:gravity="center_vertical"

View file

@ -12,15 +12,16 @@
android:paddingBottom="4dp"> android:paddingBottom="4dp">
<ImageView <ImageView
android:id="@+id/cannula_or_patch"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:scaleX = "2"
android:scaleY = "2"
android:gravity="center_vertical" android:gravity="center_vertical"
android:scaleType="centerInside" android:scaleType="centerInside"
android:scaleX="2"
android:scaleY="2"
app:srcCompat="@drawable/ic_cp_age_cannula" app:srcCompat="@drawable/ic_cp_age_cannula"
android:contentDescription="@string/cannula" /> android:contentDescription="@string/statuslights_cannula_age" />
<TextView <TextView
android:id="@+id/cannula_age" android:id="@+id/cannula_age"
@ -37,8 +38,8 @@
android:layout_weight="1" android:layout_weight="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:scaleType="centerInside" android:scaleType="centerInside"
android:scaleX="1.8" android:scaleX="1.6"
android:scaleY="1.8" android:scaleY="1.6"
app:srcCompat="@drawable/ic_cp_age_insulin" app:srcCompat="@drawable/ic_cp_age_insulin"
android:contentDescription="@string/insulin_label" /> android:contentDescription="@string/insulin_label" />

View file

@ -1133,6 +1133,9 @@
<string name="errors">Errors</string> <string name="errors">Errors</string>
<string name="ns_sync_slow">Slow down uploads</string> <string name="ns_sync_slow">Slow down uploads</string>
<string name="data_status">BG data status</string> <string name="data_status">BG data status</string>
<string name="statuslights_cannula_age">cannula age</string>
<string name="statuslights_patch_pump_age">patch pump age</string>
<string name="patch_pump">Patch pump</string>
<string name="recalculated_data_used">Recalculated data used</string> <string name="recalculated_data_used">Recalculated data used</string>
<string name="bg_too_close">BG too close:\n%1$s\n%2$s</string> <string name="bg_too_close">BG too close:\n%1$s\n%2$s</string>
<string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string> <string name="key_last_processed_glunovo_timestamp" translatable="false">last_processed_glunovo_timestamp</string>

View file

@ -38,6 +38,7 @@ class PumpDescription() {
var supportsTDDs = false var supportsTDDs = false
var needsManualTDDLoad = false var needsManualTDDLoad = false
var hasCustomUnreachableAlertCheck = false var hasCustomUnreachableAlertCheck = false
var isPatchPump = false
fun resetSettings() { fun resetSettings() {
isBolusCapable = true isBolusCapable = true
@ -103,6 +104,7 @@ class PumpDescription() {
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad) needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad)
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min) is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min)
hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck
isPatchPump = pumpType.isPatchPump
} }
companion object { companion object {

View file

@ -184,6 +184,7 @@ enum class PumpType {
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = true, hasCustomUnreachableAlertCheck = true,
isPatchPump = true,
source = Sources.OmnipodEros), source = Sources.OmnipodEros),
OMNIPOD_DASH(description = "Omnipod Dash", OMNIPOD_DASH(description = "Omnipod Dash",
manufacturer = ManufacturerType.Insulet, manufacturer = ManufacturerType.Insulet,
@ -198,6 +199,7 @@ enum class PumpType {
baseBasalMaxValue = null, baseBasalMaxValue = null,
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
isPatchPump = true,
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = false), hasCustomUnreachableAlertCheck = false),
MEDTRONIC_512_712(description = "Medtronic 512/712", MEDTRONIC_512_712(description = "Medtronic 512/712",
@ -352,6 +354,8 @@ enum class PumpType {
private set private set
var hasCustomUnreachableAlertCheck = false var hasCustomUnreachableAlertCheck = false
private set private set
var isPatchPump = false
private set
private var parent: PumpType? = null private var parent: PumpType? = null
val source: Sources val source: Sources
@ -419,6 +423,7 @@ enum class PumpType {
baseBasalSpecialSteps: DoseStepSize? = null, baseBasalSpecialSteps: DoseStepSize? = null,
pumpCapability: PumpCapability, pumpCapability: PumpCapability,
hasCustomUnreachableAlertCheck: Boolean = false, hasCustomUnreachableAlertCheck: Boolean = false,
isPatchPump: Boolean = false,
source: Sources = Sources.VirtualPump) { source: Sources = Sources.VirtualPump) {
this.description = description this.description = description
this.manufacturer = manufacturer this.manufacturer = manufacturer
@ -435,6 +440,7 @@ enum class PumpType {
this.baseBasalSpecialSteps = baseBasalSpecialSteps this.baseBasalSpecialSteps = baseBasalSpecialSteps
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck
this.isPatchPump = isPatchPump
this.source = source this.source = source
} }