From 2e5827f27f241780c1de087c267176ca694fced9 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Sat, 12 Feb 2022 08:26:07 +0100 Subject: [PATCH] a11y: apply screenreaders labels for numberpickers --- .../activities/ProfileHelperActivity.kt | 4 ++++ .../androidaps/dialogs/CalibrationDialog.kt | 1 + .../androidaps/dialogs/CarbsDialog.kt | 20 ++++++++++++---- .../androidaps/dialogs/CareDialog.kt | 2 ++ .../androidaps/dialogs/ExtendedBolusDialog.kt | 2 ++ .../androidaps/dialogs/FillDialog.kt | 2 +- .../androidaps/dialogs/InsulinDialog.kt | 17 ++++++++++--- .../androidaps/dialogs/ProfileSwitchDialog.kt | 3 +++ .../androidaps/dialogs/TempBasalDialog.kt | 3 +++ .../androidaps/dialogs/TempTargetDialog.kt | 2 ++ .../androidaps/dialogs/TreatmentDialog.kt | 2 ++ .../profile/local/LocalProfileFragment.kt | 1 + .../androidaps/utils/ui/TimeListEdit.java | 2 +- .../res/layout/activity_profilehelper.xml | 18 +++++++------- .../main/res/layout/dialog_calibration.xml | 4 +++- app/src/main/res/layout/dialog_carbs.xml | 24 +++++++++++-------- app/src/main/res/layout/dialog_care.xml | 8 +++++-- .../main/res/layout/dialog_extendedbolus.xml | 8 +++++-- app/src/main/res/layout/dialog_fill.xml | 4 +++- app/src/main/res/layout/dialog_insulin.xml | 9 +++++-- .../main/res/layout/dialog_profileswitch.xml | 13 +++++++--- app/src/main/res/layout/dialog_tempbasal.xml | 12 +++++++--- app/src/main/res/layout/dialog_temptarget.xml | 9 +++++-- app/src/main/res/layout/dialog_treatment.xml | 8 +++++-- .../main/res/layout/localprofile_fragment.xml | 13 ++++++---- app/src/main/res/values/strings.xml | 11 ++++++--- .../main/res/drawable-hdpi/border_gray.xml | 1 - core/src/main/res/layout/datetime.xml | 2 +- 28 files changed, 148 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index 1f45202ab0..25fc86cf2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -239,6 +239,10 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { } ToastUtils.showToastInUiThread(this, R.string.invalidinput) } + binding.age.editText?.id?.let { binding.ageLabel.labelFor = it } + binding.tdd.editText?.id?.let { binding.tddLabel.labelFor = it } + binding.weight.editText?.id?.let { binding.weightLabel.labelFor = it } + binding.basalpctfromtdd.editText?.id?.let { binding.basalpctfromtddLabel.labelFor = it } switchTab(0, typeSelected[0], false) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt index 35f387144c..bd5daaf965 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -64,6 +64,7 @@ class CalibrationDialog : DialogFragmentWithDate() { binding.bg.setParams(savedInstanceState?.getDouble("bg") ?: bg, 36.0, 500.0, 1.0, DecimalFormat("0"), false, binding.okcancel.ok) binding.units.text = if (units == GlucoseUnit.MMOL) rh.gs(R.string.mmol) else rh.gs(R.string.mgdl) + binding.bg.editText?.id?.let { binding.bgLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index 6f57680102..e6635ac1fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -137,32 +137,39 @@ class CarbsDialog : DialogFragmentWithDate() { savedInstanceState?.getDouble("carbs") ?: 0.0, 0.0, maxCarbs, 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher ) - - binding.plus1.text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)) + val plus1text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT)) + binding.plus1.text = plus1text + binding.plus1.contentDescription = rh.gs(R.string.treatments_wizard_carbs_label) + " " + plus1text binding.plus1.setOnClickListener { binding.carbs.value = max( 0.0, binding.carbs.value + sp.getInt(R.string.key_carbs_button_increment_1, FAV1_DEFAULT) ) validateInputs() + binding.carbs.announceValue() } - binding.plus2.text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT)) + val plus2text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT)) + binding.plus2.text = plus2text + binding.plus2.contentDescription = rh.gs(R.string.treatments_wizard_carbs_label) + " " + plus2text binding.plus2.setOnClickListener { binding.carbs.value = max( 0.0, binding.carbs.value + sp.getInt(R.string.key_carbs_button_increment_2, FAV2_DEFAULT) ) validateInputs() + binding.carbs.announceValue() } - - binding.plus3.text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)) + val plus3text = toSignedString(sp.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT)) + binding.plus3.text = plus3text + binding.plus2.contentDescription = rh.gs(R.string.treatments_wizard_carbs_label) + " " + plus3text binding.plus3.setOnClickListener { binding.carbs.value = max( 0.0, binding.carbs.value + sp.getInt(R.string.key_carbs_button_increment_3, FAV3_DEFAULT) ) validateInputs() + binding.carbs.announceValue() } setOnValueChangedListener { eventTime: Long -> @@ -188,6 +195,9 @@ class CarbsDialog : DialogFragmentWithDate() { binding.hypoTt.isChecked = false binding.activityTt.isChecked = false } + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } + binding.time.editText?.id?.let { binding.timeLabel.labelFor = it } + binding.carbs.editText?.id?.let { binding.carbsLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index ecab62f458..94b9cf1f38 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -165,6 +165,8 @@ class CareDialog : DialogFragmentWithDate() { ?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok) if (options == EventType.NOTE || options == EventType.QUESTION || options == EventType.ANNOUNCEMENT || options == EventType.EXERCISE) binding.notesLayout.root.visibility = View.VISIBLE // independent to preferences + binding.bg.editText?.id?.let { binding.bgLabel.labelFor = it } + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt index 4c86819465..7205a36939 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt @@ -70,6 +70,8 @@ class ExtendedBolusDialog : DialogFragmentWithDate() { val extendedMaxDuration = pumpDescription.extendedBolusMaxDuration binding.duration.setParams(savedInstanceState?.getDouble("duration") ?: extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, DecimalFormat("0"), false, binding.okcancel.ok) + binding.insulin.editText?.id?.let { binding.insulinLabel.labelFor = it } + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index fd8920fc07..7f94aab493 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -96,7 +96,7 @@ class FillDialog : DialogFragmentWithDate() { } else { binding.fillPresetButton3.visibility = View.GONE } - + binding.fillInsulinamount.editText?.id?.let { binding.fillLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index 9cbb2426f8..b785861b5b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -116,29 +116,40 @@ class InsulinDialog : DialogFragmentWithDate() { binding.amount.setParams(savedInstanceState?.getDouble("amount") ?: 0.0, 0.0, maxInsulin, activePlugin.activePump.pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher) - binding.plus05.text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT).toSignedString(activePlugin.activePump) + val plus05Text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT).toSignedString(activePlugin.activePump) + binding.plus05.text = plus05Text + binding.plus05.contentDescription = rh.gs(R.string.overview_insulin_label) + " " + plus05Text binding.plus05.setOnClickListener { binding.amount.value = max(0.0, binding.amount.value + sp.getDouble(rh.gs(R.string.key_insulin_button_increment_1), PLUS1_DEFAULT)) validateInputs() + binding.amount.announceValue() } - binding.plus10.text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT).toSignedString(activePlugin.activePump) + val plus10Text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT).toSignedString(activePlugin.activePump) + binding.plus10.text = plus10Text + binding.plus10.contentDescription = rh.gs(R.string.overview_insulin_label) + " " + plus10Text binding.plus10.setOnClickListener { binding.amount.value = max(0.0, binding.amount.value + sp.getDouble(rh.gs(R.string.key_insulin_button_increment_2), PLUS2_DEFAULT)) validateInputs() + binding.amount.announceValue() } - binding.plus20.text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT).toSignedString(activePlugin.activePump) + val plus20Text = sp.getDouble(rh.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT).toSignedString(activePlugin.activePump) + binding.plus20.text = plus20Text + binding.plus20.contentDescription = rh.gs(R.string.overview_insulin_label) + " " + plus20Text binding.plus20.setOnClickListener { binding.amount.value = max(0.0, binding.amount.value + sp.getDouble(rh.gs(R.string.key_insulin_button_increment_3), PLUS3_DEFAULT)) validateInputs() + binding.amount.announceValue() } binding.timeLayout.visibility = View.GONE binding.recordOnly.setOnCheckedChangeListener { _, isChecked: Boolean -> binding.timeLayout.visibility = isChecked.toVisibility() } + binding.amount.editText?.id?.let { binding.insulinLabel.labelFor = it } + binding.time.editText?.id?.let { binding.timeLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 306aee9b56..0bed01e852 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -148,6 +148,9 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { } } binding.ttLayout.visibility = View.GONE + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } + binding.percentage.editText?.id?.let { binding.percentageLabel.labelFor = it } + binding.timeshift.editText?.id?.let { binding.timeshiftLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index 65ee820eeb..d458055b9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -86,6 +86,9 @@ class TempBasalDialog : DialogFragmentWithDate() { binding.percentLayout.visibility = View.GONE binding.absoluteLayout.visibility = View.VISIBLE } + binding.basalPercentInput.editText?.id?.let { binding.basalPercentLabel.labelFor = it } + binding.basalAbsoluteInput.editText?.id?.let { binding.basalAbsoluteLabel.labelFor = it } + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 2374c48c90..7e449950e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -120,6 +120,8 @@ class TempTargetDialog : DialogFragmentWithDate() { longClick(it) return@setOnLongClickListener true } + binding.duration.editText?.id?.let { binding.durationLabel.labelFor = it } + binding.temptarget.editText?.id?.let { binding.temptargetLabel.labelFor = it } } } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index 29e6290571..46b97a3f0a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -106,6 +106,8 @@ class TreatmentDialog : DialogFragmentWithDate() { binding.insulin.setParams(savedInstanceState?.getDouble("insulin") ?: 0.0, 0.0, maxInsulin, pumpDescription.bolusStep, DecimalFormatter.pumpSupportedBolusFormat(activePlugin.activePump), false, binding.okcancel.ok, textWatcher) binding.recordOnlyLayout.visibility = View.GONE + binding.insulin.editText?.id?.let { binding.insulinLabel.labelFor = it } + binding.carbs.editText?.id?.let { binding.carbsLabel.labelFor = it } } override fun onDestroyView() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 8892c397a9..1fa1f3711f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -121,6 +121,7 @@ class LocalProfileFragment : DaggerFragment() { processVisibilityOnClick(it) binding.target.visibility = View.VISIBLE } + binding.dia.editText?.id?.let { binding.diaLabel.labelFor = it } } fun build() { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java index 918758fce4..1d79a9205e 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/ui/TimeListEdit.java @@ -112,7 +112,7 @@ public class TimeListEdit { float factor = layout.getContext().getResources().getDisplayMetrics().density; finalAdd = new ImageView(context); finalAdd.setImageResource(R.drawable.ic_add); - finalAdd.setContentDescription(layout.getContext().getResources().getString(R.string.addnew)); + finalAdd.setContentDescription(layout.getContext().getResources().getString(R.string.a11y_add_new_to_list)); LinearLayout.LayoutParams illp = new LinearLayout.LayoutParams((int) (35d * factor), (int) (35 * factor)); illp.setMargins(0, 25, 0, 25); // llp.setMargins(left, top, right, bottom); illp.gravity = Gravity.CENTER; diff --git a/app/src/main/res/layout/activity_profilehelper.xml b/app/src/main/res/layout/activity_profilehelper.xml index 224df803f1..d87aca5296 100644 --- a/app/src/main/res/layout/activity_profilehelper.xml +++ b/app/src/main/res/layout/activity_profilehelper.xml @@ -83,14 +83,14 @@ android:layout_width="150dp" android:layout_height="wrap_content" android:layout_marginStart="10dp" - android:labelFor="@+id/age" android:text="@string/age" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> + android:layout_height="40dp" + app:customContentDescription="@string/age" /> @@ -105,14 +105,14 @@ android:layout_width="150dp" android:layout_height="wrap_content" android:layout_marginStart="10dp" - android:labelFor="@+id/weight" android:text="@string/tdd_total" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> + android:layout_height="40dp" + app:customContentDescription="@string/tdd_total" /> @@ -123,18 +123,18 @@ android:gravity="center_vertical"> + android:layout_height="40dp" + app:customContentDescription="@string/weight_label" /> @@ -149,14 +149,14 @@ android:layout_width="150dp" android:layout_height="wrap_content" android:layout_marginStart="10dp" - android:labelFor="@+id/basalpctfromtdd" android:text="@string/basalpctfromtdd_label" android:textAppearance="@style/TextAppearance.AppCompat.Medium" /> + android:layout_height="40dp" + app:customContentDescription="@string/basalpctfromtdd_label" /> diff --git a/app/src/main/res/layout/dialog_calibration.xml b/app/src/main/res/layout/dialog_calibration.xml index 5190ecc325..9698f5311e 100644 --- a/app/src/main/res/layout/dialog_calibration.xml +++ b/app/src/main/res/layout/dialog_calibration.xml @@ -58,6 +58,7 @@ android:paddingTop="10dp"> + android:layout_height="40dp" + app:customContentDescription="@string/treatments_wizard_bg_label" /> - - + android:padding="2dp" + android:layoutDirection="rtl" + android:contentDescription="@string/a11y_carb_reminder" + android:drawableEnd="@drawable/ic_access_alarm_24dp" /> + + android:layout_height="40dp" + app:customContentDescription="@string/time_offset" /> + android:layout_gravity="center_horizontal" + app:customContentDescription="@string/careportal_newnstreatment_duration_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/treatments_wizard_carbs_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/treatments_wizard_bg_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/careportal_newnstreatment_duration_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/overview_insulin_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/careportal_newnstreatment_duration_label" /> + android:paddingRight="5dp" + app:customContentDescription="@string/overview_insulin_label" /> + android:layout_height="40dp" + app:customContentDescription="@string/time_offset"/> + android:layout_height="40dp" + app:customContentDescription="@string/overview_insulin_label"/>