From f6a165a50ad2038cb37c01b5108e3fa340c71d9a Mon Sep 17 00:00:00 2001 From: Vavassor Date: Wed, 12 Apr 2017 00:21:52 -0400 Subject: [PATCH] Adds content descriptions and hints to non-textual elements so they can be described by screen readers. --- .../keylesspalace/tusky/AccountActivity.java | 25 +++++++------ app/src/main/res/layout/activity_account.xml | 9 +++-- app/src/main/res/layout/activity_compose.xml | 9 +++-- app/src/main/res/layout/activity_login.xml | 4 +-- app/src/main/res/layout/activity_main.xml | 11 +++--- app/src/main/res/layout/item_blocked_user.xml | 3 +- app/src/main/res/layout/item_follow.xml | 6 ++-- app/src/main/res/layout/item_status.xml | 35 ++++++++++++------ .../res/layout/item_status_notification.xml | 3 +- app/src/main/res/layout/tab_account.xml | 36 ++++++++----------- app/src/main/res/values/strings.xml | 11 +++++- app/src/main/res/xml/preferences.xml | 2 +- 12 files changed, 91 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java index bbdaf4e3..ebf1ebd9 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/AccountActivity.java @@ -289,6 +289,16 @@ public class AccountActivity extends BaseActivity { updateButtons(); } + private void updateFollowButton(FloatingActionButton button) { + if (following) { + button.setImageResource(R.drawable.ic_person_minus_24px); + button.setContentDescription(getString(R.string.action_unfollow)); + } else { + button.setImageResource(R.drawable.ic_person_add_24dp); + button.setContentDescription(getString(R.string.action_follow)); + } + } + private void updateButtons() { invalidateOptionsMenu(); @@ -297,24 +307,13 @@ public class AccountActivity extends BaseActivity { if(!isSelf && !blocking) { floatingBtn.show(); - if (following) { - floatingBtn.setImageResource(R.drawable.ic_person_minus_24px); - } else { - floatingBtn.setImageResource(R.drawable.ic_person_add_24dp); - } + updateFollowButton(floatingBtn); floatingBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - follow(accountId); - - if (following) { - floatingBtn.setImageResource(R.drawable.ic_person_minus_24px); - } else { - floatingBtn.setImageResource(R.drawable.ic_person_add_24dp); - } - + updateFollowButton(floatingBtn); } }); } diff --git a/app/src/main/res/layout/activity_account.xml b/app/src/main/res/layout/activity_account.xml index 41b8c1e2..e3504dd6 100644 --- a/app/src/main/res/layout/activity_account.xml +++ b/app/src/main/res/layout/activity_account.xml @@ -36,7 +36,8 @@ app:layout_collapseMode="pin" android:fitsSystemWindows="true" android:layout_alignTop="@+id/account_header_info" - android:layout_alignBottom="@id/account_header_info" /> + android:layout_alignBottom="@id/account_header_info" + android:contentDescription="@null" /> + android:layout_toRightOf="@id/account_username" + android:contentDescription="@string/description_account_locked"/> @@ -181,6 +183,7 @@ android:layout_gravity="bottom|end" android:layout_margin="16dp" android:layout_height="wrap_content" - app:srcCompat="@drawable/ic_person_add_24dp"/> + app:srcCompat="@drawable/ic_person_add_24dp" + android:contentDescription="@string/action_follow" /> diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index fd3dd798..8361da98 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -1,5 +1,6 @@ - + app:srcCompat="@drawable/ic_attach_file_24dp" + android:contentDescription="@string/action_photo_pick" /> + app:srcCompat="@drawable/ic_public_24dp" + android:contentDescription="@string/action_compose_options" />