From 348b7fd19be8afd71b325f003fea5e3f548364fe Mon Sep 17 00:00:00 2001
From: Anita W <1918555+anitawoodruff@users.noreply.github.com>
Date: Mon, 4 May 2020 16:25:14 +0100
Subject: [PATCH] Further Talkback improvements for main activity (#1309)
* Add content description for Avatar icon
* Add content descriptions for plus and minus buttons
* Make bottom_navigation_background no longer clickable/focusable
- Previously it was set as clickable, even though clicking on it did
nothing. This had the side effect of making it focusable, adding an
unnecessary item to scroll through when using Talkback.
- Now it is no longer set as clickable, this is enough to make it no
longer focusable either.
* Add currency units to content descriptions of currency values
---
Habitica/res/layout/avatar_with_bars.xml | 1 +
Habitica/res/layout/habit_item_card.xml | 6 ++++--
Habitica/res/layout/main_navigation_view.xml | 3 +--
.../android/habitica/ui/views/CurrencyView.kt | 16 +++++++++++++++-
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/Habitica/res/layout/avatar_with_bars.xml b/Habitica/res/layout/avatar_with_bars.xml
index faa19c233..6b2798b7b 100644
--- a/Habitica/res/layout/avatar_with_bars.xml
+++ b/Habitica/res/layout/avatar_with_bars.xml
@@ -26,6 +26,7 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
+ android:contentDescription="@string/sidebar_avatar"
app:showBackground="true"
app:showMount="true"
app:showPet="true"/>
diff --git a/Habitica/res/layout/habit_item_card.xml b/Habitica/res/layout/habit_item_card.xml
index d707610c2..66632b7e8 100644
--- a/Habitica/res/layout/habit_item_card.xml
+++ b/Habitica/res/layout/habit_item_card.xml
@@ -38,7 +38,8 @@
style="@style/HabitButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/selection_highlight" />
+ android:background="@drawable/selection_highlight"
+ android:contentDescription="@string/positive_habit_form" />
+ android:background="@drawable/selection_highlight"
+ android:contentDescription="@string/negative_habit_form" />
diff --git a/Habitica/res/layout/main_navigation_view.xml b/Habitica/res/layout/main_navigation_view.xml
index d44ef55ce..43a1d455f 100644
--- a/Habitica/res/layout/main_navigation_view.xml
+++ b/Habitica/res/layout/main_navigation_view.xml
@@ -12,8 +12,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_alignTop="@id/item_wrapper"
- android:clickable="true">
+ android:layout_alignTop="@id/item_wrapper">
this.currencyContentDescription = context.getString(R.string.gold_plural)
+ "gems" -> this.currencyContentDescription = context.getString(R.string.gems)
+ "hourglasses" -> this.currencyContentDescription = context.getString(R.string.mystic_hourglasses)
+ else -> this.currencyContentDescription = ""
+ }
+ }
+
private fun configureCurrency() {
if ("gold" == currency) {
icon = HabiticaIconsHelper.imageOfGold()
@@ -87,7 +99,9 @@ class CurrencyView : androidx.appcompat.widget.AppCompatTextView {
var value = 0.0
set(value) {
field = value
- text = NumberAbbreviator.abbreviate(context, value)
+ val abbreviatedValue = NumberAbbreviator.abbreviate(context, value)
+ text = abbreviatedValue
+ contentDescription = "$abbreviatedValue $currencyContentDescription"
updateVisibility()
}