From cd3e529716ef54bd4bc473f968e85b8f61a29c03 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 31 Jan 2022 14:34:19 +0100 Subject: [PATCH 01/52] a11y table strucutre focus row for screenreaders --- .../res/layout/careportal_stats_fragment.xml | 13 +++--- .../careportal_stats_fragment_lowres.xml | 12 +++-- app/src/main/res/layout/loop_fragment.xml | 14 +++++- .../main/res/layout/openapsama_fragment.xml | 33 +++++++++----- .../main/res/layout/virtualpump_fragment.xml | 26 ++++++----- .../main/res/layout/combopump_fragment.xml | 30 ++++++++----- .../main/res/layout/dialog_profileviewer.xml | 16 ++++--- dana/src/main/res/layout/danar_fragment.xml | 36 ++++++++++----- .../main/res/layout/diaconn_g8_fragment.xml | 39 ++++++++++------ .../main/res/layout/medtronic_fragment.xml | 27 +++++++---- .../omnipod_common_overview_pod_info.xml | 45 ++++++++++++------- ...omnipod_dash_overview_bluetooth_status.xml | 12 +++-- ...mnipod_eros_overview_riley_link_status.xml | 3 +- .../res/layout/rileylink_status_general.xml | 36 ++++++++++----- 14 files changed, 230 insertions(+), 112 deletions(-) diff --git a/app/src/main/res/layout/careportal_stats_fragment.xml b/app/src/main/res/layout/careportal_stats_fragment.xml index b42553aa31..ffa1f6dfcc 100644 --- a/app/src/main/res/layout/careportal_stats_fragment.xml +++ b/app/src/main/res/layout/careportal_stats_fragment.xml @@ -8,7 +8,8 @@ + android:layout_height="wrap_content" + android:focusable="true"> - + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:layout_height="wrap_content" + android:focusable="true"> + android:focusable="true" + android:orientation="horizontal" + android:screenReaderFocusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> - - diff --git a/combo/src/main/res/layout/combopump_fragment.xml b/combo/src/main/res/layout/combopump_fragment.xml index 8e13a5fb8f..0ea1d9c0cb 100644 --- a/combo/src/main/res/layout/combopump_fragment.xml +++ b/combo/src/main/res/layout/combopump_fragment.xml @@ -22,7 +22,8 @@ + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:visibility="gone" + android:focusable="true"> + android:visibility="gone" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:visibility="gone" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> + android:orientation="horizontal" + android:focusable="true"> Date: Wed, 2 Feb 2022 19:04:32 +0100 Subject: [PATCH 02/52] 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 43619b32f3c83a901d1b658684cadb801f1a7d43 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Mon, 31 Jan 2022 22:22:20 +0100 Subject: [PATCH 03/52] a11y improve wizard dialog --- .../androidaps/dialogs/WizardDialog.kt | 101 ++++--- app/src/main/res/drawable/cb_backgroud_bg.xml | 7 + .../main/res/drawable/cb_backgroud_cob.xml | 7 + .../main/res/drawable/cb_backgroud_iob.xml | 7 + .../main/res/drawable/cb_backgroud_trend.xml | 7 + .../main/res/drawable/checkbox_bg_icon.xml | 4 + .../main/res/drawable/checkbox_cob_icon.xml | 4 + .../main/res/drawable/checkbox_iob_icon.xml | 4 + .../main/res/drawable/checkbox_trend_icon.xml | 4 + app/src/main/res/layout/dialog_wizard.xml | 283 ++++++++---------- app/src/main/res/values/strings.xml | 21 ++ .../androidaps/utils/ui/NumberPicker.kt | 49 ++- core/src/main/res/values/attrs.xml | 3 + core/src/main/res/values/strings.xml | 2 + 14 files changed, 302 insertions(+), 201 deletions(-) create mode 100644 app/src/main/res/drawable/cb_backgroud_bg.xml create mode 100644 app/src/main/res/drawable/cb_backgroud_cob.xml create mode 100644 app/src/main/res/drawable/cb_backgroud_iob.xml create mode 100644 app/src/main/res/drawable/cb_backgroud_trend.xml create mode 100644 app/src/main/res/drawable/checkbox_bg_icon.xml create mode 100644 app/src/main/res/drawable/checkbox_cob_icon.xml create mode 100644 app/src/main/res/drawable/checkbox_iob_icon.xml create mode 100644 app/src/main/res/drawable/checkbox_trend_icon.xml diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index c6624bb3d3..e686a6ed12 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -4,11 +4,7 @@ import android.content.Context import android.os.Bundle import android.text.Editable import android.text.TextWatcher -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.Window -import android.view.WindowManager +import android.view.* import android.widget.AdapterView import android.widget.AdapterView.OnItemSelectedListener import android.widget.ArrayAdapter @@ -136,33 +132,36 @@ class WizardDialog : DaggerDialogFragment() { val maxCorrection = constraintChecker.getMaxBolusAllowed().value() bolusStep = activePlugin.activePump.pumpDescription.bolusStep - if (profileFunction.getUnits() == GlucoseUnit.MGDL) - binding.bgInput.setParams(savedInstanceState?.getDouble("bg_input") - ?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, binding.ok, timeTextWatcher) - else - binding.bgInput.setParams(savedInstanceState?.getDouble("bg_input") - ?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, binding.ok, textWatcher) + if (profileFunction.getUnits() == GlucoseUnit.MGDL) { + binding.bgInput.setParams( + savedInstanceState?.getDouble("bg_input") + ?: 0.0, 0.0, 500.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, timeTextWatcher) + } else { + binding.bgInput.setParams( + savedInstanceState?.getDouble("bg_input") + ?: 0.0, 0.0, 30.0, 0.1, DecimalFormat("0.0"), false, binding.okcancel.ok, textWatcher) + } binding.carbsInput.setParams(savedInstanceState?.getDouble("carbs_input") - ?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, binding.ok, textWatcher) + ?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher) if (correctionPercent) { calculatedPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100).toDouble() - binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.ok, textWatcher) + binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher) binding.correctionInput.value = calculatedPercentage binding.correctionUnit.text = "%" } else { binding.correctionInput.setParams( savedInstanceState?.getDouble("correction_input") - ?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.ok, textWatcher) + ?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher) binding.correctionUnit.text = rh.gs(R.string.insulin_unit_shortname) } binding.carbTimeInput.setParams(savedInstanceState?.getDouble("carb_time_input") - ?: 0.0, -60.0, 60.0, 5.0, DecimalFormat("0"), false, binding.ok, timeTextWatcher) + ?: 0.0, -60.0, 60.0, 5.0, DecimalFormat("0"), false, binding.okcancel.ok, timeTextWatcher) initDialog() calculatedPercentage = sp.getInt(R.string.key_boluswizard_percentage, 100).toDouble() binding.percentUsed.text = rh.gs(R.string.format_percent, sp.getInt(R.string.key_boluswizard_percentage, 100)) // ok button - binding.ok.setOnClickListener { + binding.okcancel.ok.setOnClickListener { if (okClicked) { aapsLogger.debug(LTag.UI, "guarding: ok already clicked") } else { @@ -175,12 +174,12 @@ class WizardDialog : DaggerDialogFragment() { } dismiss() } - binding.bgEnabledIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked } - binding.trendEnabledIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked } - binding.cobEnabledIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked; processCobCheckBox(); } - binding.iobEnabledIcon.setOnClickListener { if (!binding.cobCheckbox.isChecked) binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked } + binding.bgCheckboxIcon.setOnClickListener { binding.bgCheckbox.isChecked = !binding.bgCheckbox.isChecked } + binding.trendCheckboxIcon.setOnClickListener { binding.bgTrendCheckbox.isChecked = !binding.bgTrendCheckbox.isChecked } + binding.cobCheckboxIcon.setOnClickListener { binding.cobCheckbox.isChecked = !binding.cobCheckbox.isChecked; processCobCheckBox(); } + binding.iobCheckboxIcon.setOnClickListener { if (!binding.cobCheckbox.isChecked) binding.iobCheckbox.isChecked = !binding.iobCheckbox.isChecked } // cancel button - binding.cancel.setOnClickListener { + binding.okcancel.cancel.setOnClickListener { aapsLogger.debug(LTag.APS, "Dialog canceled: ${this.javaClass.name}") dismiss() } @@ -212,11 +211,17 @@ class WizardDialog : DaggerDialogFragment() { sp.putBoolean(rh.gs(R.string.key_wizard_correction_percent), isChecked) binding.correctionUnit.text = if (isChecked) "%" else rh.gs(R.string.insulin_unit_shortname) correctionPercent = binding.correctionPercent.isChecked - if (correctionPercent) - binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.ok, textWatcher) - else - binding.correctionInput.setParams(savedInstanceState?.getDouble("correction_input") - ?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.ok, textWatcher) + if (correctionPercent) { + binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher) + binding.correctionInput.customContentDescription = rh.gs(R.string.a11_correction_percentage) + } else { + binding.correctionInput.setParams( + savedInstanceState?.getDouble("correction_input") + ?: 0.0, -maxCorrection, maxCorrection, bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher + ) + binding.correctionInput.customContentDescription = rh.gs(R.string.a11_correction_units) + } + binding.correctionInput.updateA11yDescription() binding.correctionInput.value = if (correctionPercent) calculatedPercentage else Round.roundTo(calculatedCorrection, bolusStep) } } @@ -224,12 +229,12 @@ class WizardDialog : DaggerDialogFragment() { binding.profile.onItemSelectedListener = object : OnItemSelectedListener { override fun onNothingSelected(parent: AdapterView<*>?) { ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.noprofileset)) - binding.ok.visibility = View.GONE + binding.okcancel.ok.visibility = View.GONE } override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { calculateInsulin() - binding.ok.visibility = View.VISIBLE + binding.okcancel.ok.visibility = View.VISIBLE } } // bus @@ -241,6 +246,26 @@ class WizardDialog : DaggerDialogFragment() { }, fabricPrivacy::logException) ) + setA11yLabels() + } + + private fun setA11yLabels() { + val bgInputTextId = binding.bgInput.editText?.id + if (bgInputTextId != null) { + binding.bgInputLabel.labelFor = bgInputTextId + } + val carbsTextId = binding.carbsInput.editText?.id + if (carbsTextId != null) { + binding.carbsInputLabel.labelFor = carbsTextId + } + val corrTextId = binding.correctionInput.editText?.id + if (corrTextId != null) { + binding.correctionInputLabel.labelFor = corrTextId + } + val carbTimeTextId = binding.carbTimeInput.editText?.id + if (carbTimeTextId != null) { + binding.carbTimeInputLabel.labelFor = carbTimeTextId + } } override fun onDestroyView() { @@ -268,14 +293,14 @@ class WizardDialog : DaggerDialogFragment() { } private fun processEnabledIcons() { - binding.bgEnabledIcon.alpha = if (binding.bgCheckbox.isChecked) 1.0f else 0.2f - binding.trendEnabledIcon.alpha = if (binding.bgTrendCheckbox.isChecked) 1.0f else 0.2f - binding.iobEnabledIcon.alpha = if (binding.iobCheckbox.isChecked) 1.0f else 0.2f - binding.cobEnabledIcon.alpha = if (binding.cobCheckbox.isChecked) 1.0f else 0.2f - binding.bgEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() - binding.trendEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() - binding.iobEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() - binding.cobEnabledIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() + binding.bgCheckboxIcon.alpha = if (binding.bgCheckbox.isChecked) 1.0f else 0.2f + binding.trendCheckboxIcon.alpha = if (binding.bgTrendCheckbox.isChecked) 1.0f else 0.2f + binding.iobCheckboxIcon.alpha = if (binding.iobCheckbox.isChecked) 1.0f else 0.2f + binding.cobCheckboxIcon.alpha = if (binding.cobCheckbox.isChecked) 1.0f else 0.2f + binding.bgCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() + binding.trendCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() + binding.iobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() + binding.cobCheckboxIcon.visibility = binding.calculationCheckbox.isChecked.not().toVisibility() } private fun saveCheckedStates() { @@ -442,10 +467,10 @@ class WizardDialog : DaggerDialogFragment() { val insulinText = if (wizard.calculatedTotalInsulin > 0.0) rh.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin).formatColor(rh, R.color.bolus) else "" val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(R.string.format_carbs, carbsAfterConstraint).formatColor(rh, R.color.carbs) else "" binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.result_insulin_carbs, insulinText, carbsText)) - binding.ok.visibility = View.VISIBLE + binding.okcancel.ok.visibility = View.VISIBLE } else { binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.missing_carbs, wizard.carbsEquivalent.toInt()).formatColor(rh, R.color.carbs)) - binding.ok.visibility = View.INVISIBLE + binding.okcancel.ok.visibility = View.INVISIBLE } binding.percentUsed.text = rh.gs(R.string.format_percent, wizard.percentageCorrection) calculatedPercentage = wizard.calculatedPercentage diff --git a/app/src/main/res/drawable/cb_backgroud_bg.xml b/app/src/main/res/drawable/cb_backgroud_bg.xml new file mode 100644 index 0000000000..cf493051a9 --- /dev/null +++ b/app/src/main/res/drawable/cb_backgroud_bg.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/drawable/cb_backgroud_cob.xml b/app/src/main/res/drawable/cb_backgroud_cob.xml new file mode 100644 index 0000000000..b73f1f3b39 --- /dev/null +++ b/app/src/main/res/drawable/cb_backgroud_cob.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/drawable/cb_backgroud_iob.xml b/app/src/main/res/drawable/cb_backgroud_iob.xml new file mode 100644 index 0000000000..bce5594f2a --- /dev/null +++ b/app/src/main/res/drawable/cb_backgroud_iob.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/drawable/cb_backgroud_trend.xml b/app/src/main/res/drawable/cb_backgroud_trend.xml new file mode 100644 index 0000000000..74e90acb2f --- /dev/null +++ b/app/src/main/res/drawable/cb_backgroud_trend.xml @@ -0,0 +1,7 @@ + + + + diff --git a/app/src/main/res/drawable/checkbox_bg_icon.xml b/app/src/main/res/drawable/checkbox_bg_icon.xml new file mode 100644 index 0000000000..0e2e6b7ed9 --- /dev/null +++ b/app/src/main/res/drawable/checkbox_bg_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/checkbox_cob_icon.xml b/app/src/main/res/drawable/checkbox_cob_icon.xml new file mode 100644 index 0000000000..01184068a2 --- /dev/null +++ b/app/src/main/res/drawable/checkbox_cob_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/checkbox_iob_icon.xml b/app/src/main/res/drawable/checkbox_iob_icon.xml new file mode 100644 index 0000000000..aba6d56c20 --- /dev/null +++ b/app/src/main/res/drawable/checkbox_iob_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/drawable/checkbox_trend_icon.xml b/app/src/main/res/drawable/checkbox_trend_icon.xml new file mode 100644 index 0000000000..de7ca8e81d --- /dev/null +++ b/app/src/main/res/drawable/checkbox_trend_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/app/src/main/res/layout/dialog_wizard.xml b/app/src/main/res/layout/dialog_wizard.xml index 0fe3d2f660..296f9b8ba8 100644 --- a/app/src/main/res/layout/dialog_wizard.xml +++ b/app/src/main/res/layout/dialog_wizard.xml @@ -59,6 +59,7 @@ android:layout_height="match_parent"> + android:layout_height="40dp" + app:customContentDescription="@string/a11y_current_bg" /> - + android:layout_gravity="center_horizontal" + app:customContentDescription="@string/treatments_wizard_carbs_label" /> - - - + android:layoutDirection="rtl" + android:padding="2dp" + android:text="%" + android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textStyle="bold" /> - + android:layout_gravity="center_horizontal" + app:customContentDescription="@string/a11_correction_units" /> - - + android:drawableEnd="@drawable/ic_visibility" /> - + android:layout_height="fill_parent" + android:button="@drawable/checkbox_bg_icon" + android:checked="true" + android:contentDescription="@string/treatments_wizard_bg_label" /> - + android:layout_height="fill_parent" + android:button="@drawable/checkbox_trend_icon" + android:checked="true" + android:contentDescription="@string/bg_trend_label" /> - + android:layout_height="fill_parent" + android:button="@drawable/checkbox_iob_icon" + android:checked="true" + android:contentDescription="@string/iob" /> - + android:layout_height="fill_parent" + android:button="@drawable/checkbox_cob_icon" + android:checked="true" + android:contentDescription="@string/treatments_wizard_cob_label" /> -