From 58f418cd6cb6906fe74f8c341ee1fc6d9fafcd35 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 2 Feb 2022 19:04:32 +0100 Subject: [PATCH 1/3] feat: show pod icon instead of cannula --- .../plugins/general/actions/ActionsFragment.kt | 6 ++++++ .../plugins/general/overview/OverviewFragment.kt | 10 +++++++++- .../plugins/general/overview/StatusLightHandler.kt | 9 +++------ app/src/main/res/drawable/ic_pod_outline.xml | 13 +++++++++++++ .../main/res/layout/careportal_stats_fragment.xml | 1 + .../res/layout/overview_statuslights_layout.xml | 11 ++++++----- app/src/main/res/values/strings.xml | 2 ++ 7 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/ic_pod_outline.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 8b2be42563..57f3351ac0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -107,6 +107,7 @@ class ActionsFragment : DaggerFragment() { private var sensorLevelLabel: TextView? = null private var insulinLevelLabel: TextView? = null private var pbLevelLabel: TextView? = null + private var cannulaOrAge: TextView? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -153,6 +154,7 @@ class ActionsFragment : DaggerFragment() { sensorLevelLabel = view.findViewById(R.id.sensor_level_label) insulinLevelLabel = view.findViewById(R.id.insulin_level_label) pbLevelLabel = view.findViewById(R.id.pb_level_label) + cannulaOrAge = view.findViewById(R.id.cannula_or_pod) profileSwitch?.setOnClickListener { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") @@ -319,6 +321,10 @@ class ActionsFragment : DaggerFragment() { tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility() tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() + cannulaOrAge?.text = if (statusLightHandler.isOmnipod) rh.gs(R.string.omnipod_eros_name_short) else rh.gs(R.string.cannula) + val imageResource = if (statusLightHandler.isOmnipod) R.drawable.ic_pod_outline else R.drawable.ic_cp_age_cannula + cannulaOrAge?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0) + if (!config.NSCLIENT) { statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel) sensorLevelLabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 50ce24891a..ac12860fc6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -823,7 +823,15 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList fun updateTime(from: String) { binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now()) // Status lights - binding.statusLightsLayout.statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() + val isPod = statusLightHandler.isOmnipod + binding.statusLightsLayout.apply { + cannulaOrPod.setImageResource(if (isPod) R.drawable.ic_pod_outline else R.drawable.ic_cp_age_cannula) + cannulaOrPod.contentDescription = rh.gs(if (isPod) R.string.statuslights_pod_age else R.string.statuslights_cannula_age) + cannulaOrPod.scaleX = if (isPod) 1.4f else 2f + cannulaOrPod.scaleY = cannulaOrPod.scaleX + insulinAge.visibility = (!isPod).toVisibility() + statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() + } statusLightHandler.updateStatusLights( binding.statusLightsLayout.cannulaAge, binding.statusLightsLayout.insulinAge, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index 61e632306b..156fbf15b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -40,12 +40,7 @@ class StatusLightHandler @Inject constructor( val pump = activePlugin.activePump 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) - 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) 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) @@ -77,6 +72,8 @@ class StatusLightHandler @Inject constructor( } } + val isOmnipod: Boolean get() = activePlugin.activePump.model() == PumpType.OMNIPOD_EROS || activePlugin.activePump.model() == PumpType.OMNIPOD_DASH + private fun handleAge(view: TextView?, type: TherapyEvent.Type, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) { val warn = sp.getDouble(warnSettings, defaultWarnThreshold) val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold) diff --git a/app/src/main/res/drawable/ic_pod_outline.xml b/app/src/main/res/drawable/ic_pod_outline.xml new file mode 100644 index 0000000000..6e95a27545 --- /dev/null +++ b/app/src/main/res/drawable/ic_pod_outline.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index b42553aa31..d59a4e98e9 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -161,6 +161,7 @@ android:layout_height="wrap_content"> + android:contentDescription="@string/statuslights_cannula_age" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a34eb64e49..9c959b3cd7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1133,6 +1133,8 @@ Errors Slow down uploads BG data status + cannula age + pod age Recalculated data used BG too close:\n%1$s\n%2$s last_processed_glunovo_timestamp From f51df08c1fd8ebb31a16101e84f4aa24d72c3b48 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 9 Feb 2022 09:06:31 +0100 Subject: [PATCH 2/3] Add isPatchPump to pump description for Omnipod --- .../plugins/general/actions/ActionsFragment.kt | 10 +++++----- .../plugins/general/overview/OverviewFragment.kt | 12 ++++++------ .../plugins/general/overview/StatusLightHandler.kt | 2 -- ...{ic_pod_outline.xml => ic_patch_pump_outline.xml} | 0 .../main/res/layout/careportal_stats_fragment.xml | 2 +- .../main/res/layout/overview_statuslights_layout.xml | 2 +- app/src/main/res/values/strings.xml | 3 ++- .../androidaps/interfaces/PumpDescription.kt | 2 ++ .../androidaps/plugins/pump/common/defs/PumpType.kt | 6 ++++++ 9 files changed, 23 insertions(+), 16 deletions(-) rename app/src/main/res/drawable/{ic_pod_outline.xml => ic_patch_pump_outline.xml} (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 57f3351ac0..111df21369 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -107,7 +107,7 @@ class ActionsFragment : DaggerFragment() { private var sensorLevelLabel: TextView? = null private var insulinLevelLabel: TextView? = null private var pbLevelLabel: TextView? = null - private var cannulaOrAge: TextView? = null + private var cannulaOrPatch: TextView? = null override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -154,7 +154,7 @@ class ActionsFragment : DaggerFragment() { sensorLevelLabel = view.findViewById(R.id.sensor_level_label) insulinLevelLabel = view.findViewById(R.id.insulin_level_label) pbLevelLabel = view.findViewById(R.id.pb_level_label) - cannulaOrAge = view.findViewById(R.id.cannula_or_pod) + cannulaOrPatch = view.findViewById(R.id.cannula_or_patch) profileSwitch?.setOnClickListener { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog") @@ -321,9 +321,9 @@ class ActionsFragment : DaggerFragment() { tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility() tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility() - cannulaOrAge?.text = if (statusLightHandler.isOmnipod) rh.gs(R.string.omnipod_eros_name_short) else rh.gs(R.string.cannula) - val imageResource = if (statusLightHandler.isOmnipod) R.drawable.ic_pod_outline else R.drawable.ic_cp_age_cannula - cannulaOrAge?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0) + 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) { statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index ac12860fc6..6655c51c32 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -823,13 +823,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList fun updateTime(from: String) { binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now()) // Status lights - val isPod = statusLightHandler.isOmnipod + val isPatchPump = activePlugin.activePump.pumpDescription.isPatchPump binding.statusLightsLayout.apply { - cannulaOrPod.setImageResource(if (isPod) R.drawable.ic_pod_outline else R.drawable.ic_cp_age_cannula) - cannulaOrPod.contentDescription = rh.gs(if (isPod) R.string.statuslights_pod_age else R.string.statuslights_cannula_age) - cannulaOrPod.scaleX = if (isPod) 1.4f else 2f - cannulaOrPod.scaleY = cannulaOrPod.scaleX - insulinAge.visibility = (!isPod).toVisibility() + 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).toVisibility() statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() } statusLightHandler.updateStatusLights( diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index 156fbf15b5..ba73fab429 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -72,8 +72,6 @@ class StatusLightHandler @Inject constructor( } } - val isOmnipod: Boolean get() = activePlugin.activePump.model() == PumpType.OMNIPOD_EROS || activePlugin.activePump.model() == PumpType.OMNIPOD_DASH - private fun handleAge(view: TextView?, type: TherapyEvent.Type, @StringRes warnSettings: Int, defaultWarnThreshold: Double, @StringRes urgentSettings: Int, defaultUrgentThreshold: Double) { val warn = sp.getDouble(warnSettings, defaultWarnThreshold) val urgent = sp.getDouble(urgentSettings, defaultUrgentThreshold) diff --git a/app/src/main/res/drawable/ic_pod_outline.xml b/app/src/main/res/drawable/ic_patch_pump_outline.xml similarity index 100% rename from app/src/main/res/drawable/ic_pod_outline.xml rename to app/src/main/res/drawable/ic_patch_pump_outline.xml diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index d59a4e98e9..548396e9aa 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -161,7 +161,7 @@ android:layout_height="wrap_content"> Slow down uploads BG data status cannula age - pod age + patch pump age + Patch pump Recalculated data used BG too close:\n%1$s\n%2$s last_processed_glunovo_timestamp diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.kt index 003d8f569e..6651791efa 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.kt @@ -38,6 +38,7 @@ class PumpDescription() { var supportsTDDs = false var needsManualTDDLoad = false var hasCustomUnreachableAlertCheck = false + var isPatchPump = false fun resetSettings() { isBolusCapable = true @@ -103,6 +104,7 @@ class PumpDescription() { needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad) is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min) hasCustomUnreachableAlertCheck = pumpType.hasCustomUnreachableAlertCheck + isPatchPump = pumpType.isPatchPump } companion object { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt index a36883adae..575fd2a536 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/pump/common/defs/PumpType.kt @@ -184,6 +184,7 @@ enum class PumpType { baseBasalSpecialSteps = null, pumpCapability = PumpCapability.OmnipodCapabilities, hasCustomUnreachableAlertCheck = true, + isPatchPump = true, source = Sources.OmnipodEros), OMNIPOD_DASH(description = "Omnipod Dash", manufacturer = ManufacturerType.Insulet, @@ -198,6 +199,7 @@ enum class PumpType { baseBasalMaxValue = null, baseBasalStep = 0.05, baseBasalSpecialSteps = null, + isPatchPump = true, pumpCapability = PumpCapability.OmnipodCapabilities, hasCustomUnreachableAlertCheck = false), MEDTRONIC_512_712(description = "Medtronic 512/712", @@ -352,6 +354,8 @@ enum class PumpType { private set var hasCustomUnreachableAlertCheck = false private set + var isPatchPump = false + private set private var parent: PumpType? = null val source: Sources @@ -419,6 +423,7 @@ enum class PumpType { baseBasalSpecialSteps: DoseStepSize? = null, pumpCapability: PumpCapability, hasCustomUnreachableAlertCheck: Boolean = false, + isPatchPump: Boolean = false, source: Sources = Sources.VirtualPump) { this.description = description this.manufacturer = manufacturer @@ -435,6 +440,7 @@ enum class PumpType { this.baseBasalSpecialSteps = baseBasalSpecialSteps this.pumpCapability = pumpCapability this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck + this.isPatchPump = isPatchPump this.source = source } From d9ad3e35d9588888f2dd8a2b26ede88fb9d397ad Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 10 Feb 2022 20:21:22 +0100 Subject: [PATCH 3/3] chore: rewrite to use not function --- .../androidaps/plugins/general/overview/OverviewFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 6655c51c32..d82e315359 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -829,7 +829,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList 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).toVisibility() + insulinAge.visibility = isPatchPump.not().toVisibility() statusLights.visibility = (sp.getBoolean(R.string.key_show_statuslights, true) || config.NSCLIENT).toVisibility() } statusLightHandler.updateStatusLights(