Tweak accessibility so that visually impaird people can use F-Droid well.

Things that are still not right:

 * BottomNavigationView doesn't read out the title of items when selected.
   Created this issue: https://code.google.com/p/android/issues/detail?id=230595&thanks=230595&ts=1482125499
 * TTS reader combines the app name and summary without a pause which is jarring.
 * Touching the background of the recycler view in the categories view reads all category names.
 * Likely other problems too.
This commit is contained in:
Peter Serwylo 2016-12-19 16:15:14 +11:00
parent 6ad1f0faef
commit 9acc34c9ba
10 changed files with 36 additions and 17 deletions

View File

@ -139,7 +139,8 @@ public class CategoryTextWatcher implements TextWatcher {
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
// For accessibility reasons, make this more clear to screen readers that the // For accessibility reasons, make this more clear to screen readers that the
// span we just added semantically represents a category. // span we just added semantically represents a category.
TtsSpan ttsSpan = new TtsSpan.TextBuilder(context.getString(R.string.category)).build(); CharSequence categoryName = textToSpannify.subSequence(0, colonIndex);
TtsSpan ttsSpan = new TtsSpan.TextBuilder(context.getString(R.string.tts_category_name, categoryName)).build();
textToSpannify.setSpan(ttsSpan, 0, 0, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textToSpannify.setSpan(ttsSpan, 0, 0, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
} }

View File

@ -121,6 +121,7 @@ public class CategoryController extends RecyclerView.ViewHolder implements Loade
int numAppsInCategory = cursor.getInt(0); int numAppsInCategory = cursor.getInt(0);
viewAll.setVisibility(View.VISIBLE); viewAll.setVisibility(View.VISIBLE);
viewAll.setText(activity.getResources().getQuantityString(R.plurals.button_view_all_apps_in_category, numAppsInCategory, numAppsInCategory)); viewAll.setText(activity.getResources().getQuantityString(R.plurals.button_view_all_apps_in_category, numAppsInCategory, numAppsInCategory));
viewAll.setContentDescription(activity.getResources().getQuantityString(R.plurals.tts_view_all_in_category, numAppsInCategory, numAppsInCategory, currentCategory));
} }
} }

View File

@ -40,15 +40,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="12dp"> android:layout_margin="12dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:contentDescription="@string/app_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
tools:src="@drawable/ic_launcher" tools:src="@drawable/ic_launcher"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView <TextView
tools:text="F-Droid An application summary which takes up too much space and must ellipsize, perhaps after wrapping to a new line" tools:text="F-Droid An application summary which takes up too much space and must ellipsize, perhaps after wrapping to a new line"

View File

@ -10,15 +10,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp"> android:layout_margin="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:contentDescription="@string/app_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
tools:src="@drawable/ic_launcher" tools:src="@drawable/ic_launcher"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView <TextView
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" tools:text="F-Droid An application summary which takes up too much space and must ellipsize"

View File

@ -10,9 +10,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="8dp"> android:layout_margin="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:contentDescription="@string/app_icon"
android:layout_width="96dip" android:layout_width="96dip"
android:layout_height="96dip" android:layout_height="96dip"
tools:src="@drawable/ic_launcher" tools:src="@drawable/ic_launcher"
@ -25,7 +26,8 @@
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView <TextView
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" tools:text="F-Droid An application summary which takes up too much space and must ellipsize"

View File

@ -10,15 +10,17 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="8dp"> android:layout_margin="8dp">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:contentDescription="@string/app_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
tools:src="@drawable/ic_launcher" tools:src="@drawable/ic_launcher"
android:scaleType="fitCenter" android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView <TextView
tools:text="F-Droid An application summary which takes up too much space and must ellipsize" tools:text="F-Droid An application summary which takes up too much space and must ellipsize"

View File

@ -6,18 +6,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<!-- Ignore ContentDescription because it is kind of meaningless to have TTS read out "App icon"
when it will inevitably read out the name of the app straight after. -->
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/app_icon"
android:layout_width="48dp" android:layout_width="48dp"
android:layout_height="48dp" android:layout_height="48dp"
tools:src="@drawable/ic_launcher" tools:src="@drawable/ic_launcher"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginTop="8dp" /> android:layout_marginTop="8dp"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/app_name" android:id="@+id/app_name"

View File

@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/btn_search" android:id="@+id/btn_search"
android:src="@drawable/ic_search_white" android:src="@drawable/ic_search_white"
android:contentDescription="@string/menu_search"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"

View File

@ -4,26 +4,26 @@
<item <item
android:title="@string/main_menu__latest_apps" android:title="@string/main_menu__latest_apps"
android:icon="@drawable/ic_overview" android:icon="@drawable/ic_overview"
app:showAsAction="ifRoom" app:showAsAction="ifRoom|withText"
android:id="@+id/whats_new" /> android:id="@+id/whats_new" />
<item <item
android:title="@string/main_menu__categories" android:title="@string/main_menu__categories"
android:icon="@drawable/ic_category" android:icon="@drawable/ic_category"
app:showAsAction="ifRoom" app:showAsAction="ifRoom|withText"
android:id="@+id/categories" /> android:id="@+id/categories" />
<item <item
android:title="@string/main_menu__swap_nearby" android:title="@string/main_menu__swap_nearby"
android:icon="@drawable/ic_nearby" android:icon="@drawable/ic_nearby"
app:showAsAction="ifRoom" app:showAsAction="ifRoom|withText"
android:id="@+id/nearby" /> android:id="@+id/nearby" />
<item <item
android:title="@string/main_menu__my_apps" android:title="@string/main_menu__my_apps"
android:icon="@drawable/ic_my_apps" android:icon="@drawable/ic_my_apps"
app:showAsAction="ifRoom" app:showAsAction="ifRoom|withText"
android:id="@+id/my_apps" /> android:id="@+id/my_apps" />
<item <item
android:title="@string/menu_settings" android:title="@string/menu_settings"
android:icon="@drawable/ic_settings" android:icon="@drawable/ic_settings"
app:showAsAction="ifRoom" app:showAsAction="ifRoom|withText"
android:id="@+id/settings" /> android:id="@+id/settings" />
</menu> </menu>

View File

@ -444,5 +444,11 @@
<string name="notification_action_cancel">Cancel</string> <string name="notification_action_cancel">Cancel</string>
<string name="notification_action_install">Install</string> <string name="notification_action_install">Install</string>
<string name="category">Category</string> <!-- Used by the TTS engine when showing a category "Chip" in the search box -->
<string name="tts_category_name">Category %1$s</string>
<plurals name="tts_view_all_in_category">
<item quantity="one">View the single one app in the %2$s category</item>
<item quantity="other">View all %1$d apps from the %2$s category</item>
</plurals>
</resources> </resources>