Adds content descriptions and hints to non-textual elements so they can be described by screen readers.

This commit is contained in:
Vavassor 2017-04-12 00:21:52 -04:00
parent 4ea04bb576
commit f6a165a50a
12 changed files with 91 additions and 63 deletions

View File

@ -289,6 +289,16 @@ public class AccountActivity extends BaseActivity {
updateButtons(); 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() { private void updateButtons() {
invalidateOptionsMenu(); invalidateOptionsMenu();
@ -297,24 +307,13 @@ public class AccountActivity extends BaseActivity {
if(!isSelf && !blocking) { if(!isSelf && !blocking) {
floatingBtn.show(); floatingBtn.show();
if (following) { updateFollowButton(floatingBtn);
floatingBtn.setImageResource(R.drawable.ic_person_minus_24px);
} else {
floatingBtn.setImageResource(R.drawable.ic_person_add_24dp);
}
floatingBtn.setOnClickListener(new View.OnClickListener() { floatingBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
follow(accountId); follow(accountId);
updateFollowButton(floatingBtn);
if (following) {
floatingBtn.setImageResource(R.drawable.ic_person_minus_24px);
} else {
floatingBtn.setImageResource(R.drawable.ic_person_add_24dp);
}
} }
}); });
} }

View File

@ -36,7 +36,8 @@
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_alignTop="@+id/account_header_info" android:layout_alignTop="@+id/account_header_info"
android:layout_alignBottom="@id/account_header_info" /> android:layout_alignBottom="@id/account_header_info"
android:contentDescription="@null" />
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
@ -101,7 +102,8 @@
android:layout_toEndOf="@id/account_username" android:layout_toEndOf="@id/account_username"
app:srcCompat="@drawable/reblog_disabled_light" app:srcCompat="@drawable/reblog_disabled_light"
android:tint="?android:textColorSecondary" android:tint="?android:textColorSecondary"
android:layout_toRightOf="@id/account_username" /> android:layout_toRightOf="@id/account_username"
android:contentDescription="@string/description_account_locked"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
@ -181,6 +183,7 @@
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="16dp" android:layout_margin="16dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_person_add_24dp"/> app:srcCompat="@drawable/ic_person_add_24dp"
android:contentDescription="@string/action_follow" />
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_compose" android:id="@+id/activity_compose"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -96,7 +97,8 @@
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
app:srcCompat="@drawable/ic_attach_file_24dp" /> app:srcCompat="@drawable/ic_attach_file_24dp"
android:contentDescription="@string/action_photo_pick" />
<ImageButton <ImageButton
android:id="@+id/action_toggle_visibility" android:id="@+id/action_toggle_visibility"
@ -104,7 +106,8 @@
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
app:srcCompat="@drawable/ic_public_24dp" /> app:srcCompat="@drawable/ic_public_24dp"
android:contentDescription="@string/action_compose_options" />
<Button <Button
android:id="@+id/action_toggle_nsfw" android:id="@+id/action_toggle_nsfw"

View File

@ -17,7 +17,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="50dp" android:layout_marginBottom="50dp"
android:src="@drawable/elephant_friend"/> android:src="@drawable/elephant_friend"
android:contentDescription="@string/description_elephant_friend" />
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -36,7 +37,6 @@
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:elevation="0dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:text="@string/action_login" /> android:text="@string/action_login" />

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main" android:id="@+id/activity_main"
@ -80,7 +81,6 @@
android:background="@drawable/material_drawer_shadow_bottom" android:background="@drawable/material_drawer_shadow_bottom"
android:visibility="visible" /> android:visibility="visible" />
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/floating_btn" android:id="@+id/floating_btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -89,10 +89,13 @@
android:clickable="true" android:clickable="true"
android:layout_margin="16dp" android:layout_margin="16dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_create_24dp"/> app:srcCompat="@drawable/ic_create_24dp"
android:contentDescription="@string/action_compose" />
<FrameLayout <FrameLayout
android:id="@+id/overlay_fragment_container" android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout> android:layout_height="match_parent">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>

View File

@ -24,7 +24,8 @@
style="?attr/image_button_style" style="?attr/image_button_style"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_centerVertical="true" /> android:layout_centerVertical="true"
android:contentDescription="@string/action_unblock" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -24,7 +24,8 @@
app:srcCompat="@drawable/ic_person_add_24dp" app:srcCompat="@drawable/ic_person_add_24dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:tint="?attr/colorAccent" /> android:tint="?attr/colorAccent"
android:contentDescription="@string/action_follow" />
<TextView <TextView
android:id="@+id/notification_text" android:id="@+id/notification_text"
@ -50,7 +51,8 @@
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_alignParentLeft="true" /> android:layout_alignParentLeft="true"
android:contentDescription="@null" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -22,7 +22,8 @@
android:id="@+id/status_reblogged_icon" android:id="@+id/status_reblogged_icon"
android:paddingRight="10dp" android:paddingRight="10dp"
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:tint="?android:textColorTertiary" /> android:tint="?android:textColorTertiary"
android:contentDescription="@null" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -41,7 +42,8 @@
android:id="@+id/status_avatar" android:id="@+id/status_avatar"
android:layout_below="@+id/status_reblogged_bar" android:layout_below="@+id/status_reblogged_bar"
android:layout_marginTop="11dp" android:layout_marginTop="11dp"
android:layout_marginRight="10dp" /> android:layout_marginRight="10dp"
android:contentDescription="@null" />
<RelativeLayout <RelativeLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -58,7 +60,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:text="20m ago" android:text="20m"
android:textColor="?android:textColorSecondary" /> android:textColor="?android:textColorSecondary" />
<LinearLayout <LinearLayout
@ -147,6 +149,7 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -160,7 +163,8 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="2dp" android:layout_marginRight="2dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:layout_marginTop="@dimen/status_media_preview_top_margin" /> android:layout_marginTop="@dimen/status_media_preview_top_margin"
android:contentDescription="@null" />
<ImageView <ImageView
android:id="@+id/status_media_preview_1" android:id="@+id/status_media_preview_1"
@ -169,7 +173,9 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginLeft="2dp" android:layout_marginLeft="2dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:layout_marginTop="@dimen/status_media_preview_top_margin" /> android:layout_marginTop="@dimen/status_media_preview_top_margin"
android:contentDescription="@null" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -184,7 +190,8 @@
android:layout_height="@dimen/status_media_preview_height" android:layout_height="@dimen/status_media_preview_height"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="2dp" android:layout_marginRight="2dp"
android:scaleType="centerCrop" /> android:scaleType="centerCrop"
android:contentDescription="@null" />
<ImageView <ImageView
android:id="@+id/status_media_preview_3" android:id="@+id/status_media_preview_3"
@ -192,9 +199,11 @@
android:layout_height="@dimen/status_media_preview_height" android:layout_height="@dimen/status_media_preview_height"
android:layout_marginLeft="2dp" android:layout_marginLeft="2dp"
android:layout_weight="1" android:layout_weight="1"
android:scaleType="centerCrop" /> android:scaleType="centerCrop"
android:contentDescription="@null" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -241,7 +250,8 @@
android:id="@+id/status_reply" android:id="@+id/status_reply"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
style="?attr/image_button_style" /> style="?attr/image_button_style"
android:contentDescription="@string/action_reply" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"
@ -257,7 +267,8 @@
app:sparkbutton_primaryColor="@color/status_reblog_button_marked_dark" app:sparkbutton_primaryColor="@color/status_reblog_button_marked_dark"
app:sparkbutton_secondaryColor="@color/status_reblog_button_marked_light" app:sparkbutton_secondaryColor="@color/status_reblog_button_marked_light"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" /> android:layout_height="32dp"
android:contentDescription="@string/action_reblog" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"
@ -273,7 +284,8 @@
android:layout_gravity="center" android:layout_gravity="center"
app:sparkbutton_primaryColor="@color/status_favourite_button_marked_dark" app:sparkbutton_primaryColor="@color/status_favourite_button_marked_dark"
app:sparkbutton_secondaryColor="@color/status_favourite_button_marked_light" app:sparkbutton_secondaryColor="@color/status_favourite_button_marked_light"
android:id="@+id/status_favourite" /> android:id="@+id/status_favourite"
android:contentDescription="@string/action_favourite" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"
@ -285,7 +297,8 @@
android:id="@+id/status_more" android:id="@+id/status_more"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
style="?attr/image_button_style" /> style="?attr/image_button_style"
android:contentDescription="@string/action_more" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"

View File

@ -21,7 +21,8 @@
android:id="@+id/notification_icon" android:id="@+id/notification_icon"
android:paddingRight="10dp" android:paddingRight="10dp"
android:paddingLeft="24dp" android:paddingLeft="24dp"
app:srcCompat="@drawable/ic_repeat_24dp" /> app:srcCompat="@drawable/ic_repeat_24dp"
android:contentDescription="@null" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -1,30 +1,24 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="match_parent"> android:layout_height="wrap_content"
android:layout_centerInParent="true">
<RelativeLayout <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true"> android:id="@+id/title"
android:layout_centerHorizontal="true"
android:textAllCaps="true"
android:textStyle="normal|bold" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/title" android:id="@+id/total"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:textAllCaps="true" android:layout_below="@id/title"
android:textStyle="normal|bold" /> android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/total"
android:layout_centerHorizontal="true"
android:layout_below="@id/title"
android:textSize="10sp" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -46,6 +46,10 @@
<string name="report_username_format">Report @%s</string> <string name="report_username_format">Report @%s</string>
<string name="report_comment_hint">Additional comments?</string> <string name="report_comment_hint">Additional comments?</string>
<string name="action_reply">Reply</string>
<string name="action_reblog">Boost</string>
<string name="action_favourite">Favourite</string>
<string name="action_more">More</string>
<string name="action_compose">Compose</string> <string name="action_compose">Compose</string>
<string name="action_login">Login with Mastodon</string> <string name="action_login">Login with Mastodon</string>
<string name="action_logout">Log Out</string> <string name="action_logout">Log Out</string>
@ -76,6 +80,7 @@
<string name="action_unmute">Unmute</string> <string name="action_unmute">Unmute</string>
<string name="action_mention">Mention</string> <string name="action_mention">Mention</string>
<string name="toggle_nsfw">NSFW</string> <string name="toggle_nsfw">NSFW</string>
<string name="action_compose_options">Options</string>
<string name="send_status_to">Share toot URL to…</string> <string name="send_status_to">Share toot URL to…</string>
@ -121,7 +126,8 @@
<string name="pref_title_appearance_settings">Appearance</string> <string name="pref_title_appearance_settings">Appearance</string>
<string name="pref_title_light_theme">Use the Light Theme</string> <string name="pref_title_light_theme">Use the Light Theme</string>
<string name="pref_title_browser_settings">Browser</string> <string name="pref_title_browser_settings">Browser</string>
<string name="pre_title_custom_tabs">Use Chrome Custom Tabs</string> <string name="pref_title_custom_tabs">Use Chrome Custom Tabs</string>
<string name="pref_title_hide_follow_button">Hide follow button while scrolling</string>
<string name="notification_mention_format">%s mentioned you</string> <string name="notification_mention_format">%s mentioned you</string>
<string name="notification_summary_large">%1$s, %2$s, %3$s and %4$d others</string> <string name="notification_summary_large">%1$s, %2$s, %3$s and %4$d others</string>
@ -129,4 +135,7 @@
<string name="notification_summary_small">%1$s and %2$s</string> <string name="notification_summary_small">%1$s and %2$s</string>
<string name="notification_title_summary">%d new interactions</string> <string name="notification_title_summary">%d new interactions</string>
<string name="description_elephant_friend">Elephant Friend</string>
<string name="description_account_locked">Locked Account</string>
</resources> </resources>

View File

@ -11,7 +11,7 @@
<CheckBoxPreference <CheckBoxPreference
android:key="fabHide" android:key="fabHide"
android:title="Hide FAB while scrolling" android:title="@string/pref_title_hide_follow_button"
android:defaultValue="false" /> android:defaultValue="false" />
</PreferenceCategory> </PreferenceCategory>