From 7667632eb24653ef208261651298996f5fdf6911 Mon Sep 17 00:00:00 2001 From: Jorge Lugo Date: Thu, 7 Jul 2011 20:10:54 -0700 Subject: [PATCH] Improve accessibility for stars and settings Adding and removing a star triggers the appropriate accessibility In incoming/outgoing settings, added EditText contentDescriptions. Change-Id: Ibab461f1425b3ebf3579ebc1d0b36d1a9a5efdb2 --- .../account_setup_exchange_fragment.xml | 3 ++ .../account_setup_incoming_fragment.xml | 11 ++++- .../account_setup_exchange_fragment.xml | 6 ++- .../account_setup_incoming_fragment.xml | 44 +++++++++++-------- .../email/activity/MessageViewFragment.java | 22 ++++++++++ .../setup/AccountSetupIncomingFragment.java | 4 ++ 6 files changed, 68 insertions(+), 22 deletions(-) diff --git a/res/layout-sw600dp/account_setup_exchange_fragment.xml b/res/layout-sw600dp/account_setup_exchange_fragment.xml index 2291a8284..e99df3c4f 100644 --- a/res/layout-sw600dp/account_setup_exchange_fragment.xml +++ b/res/layout-sw600dp/account_setup_exchange_fragment.xml @@ -33,6 +33,7 @@ android:id="@+id/account_username" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_exchange_username_label" android:inputType="textEmailAddress" android:imeOptions="actionDone" /> @@ -47,6 +48,7 @@ android:id="@+id/account_password" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_password_label" android:inputType="textPassword" android:imeOptions="actionDone" /> @@ -62,6 +64,7 @@ android:id="@+id/account_server" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_exchange_server_label" android:inputType="textUri" android:imeOptions="actionDone" /> diff --git a/res/layout-sw600dp/account_setup_incoming_fragment.xml b/res/layout-sw600dp/account_setup_incoming_fragment.xml index 60c4dafd9..826ad2676 100644 --- a/res/layout-sw600dp/account_setup_incoming_fragment.xml +++ b/res/layout-sw600dp/account_setup_incoming_fragment.xml @@ -33,6 +33,7 @@ android:id="@+id/account_username" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_username_label" android:inputType="textEmailAddress" android:imeOptions="actionDone" /> @@ -47,6 +48,7 @@ android:id="@+id/account_password" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_password_label" android:inputType="textPassword" android:imeOptions="actionDone" /> @@ -64,6 +66,7 @@ android:id="@+id/account_server" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_pop_server_label" android:inputType="textUri" android:imeOptions="actionDone" /> @@ -77,7 +80,8 @@ + android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_security_label" /> @@ -90,6 +94,7 @@ android:id="@+id/account_port" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_port_label" android:inputType="number" android:imeOptions="actionDone" /> @@ -104,7 +109,8 @@ + android:layout_height="wrap_content" + android:contentDescription="@string/account_setup_incoming_delete_policy_label" /> diff --git a/res/layout/account_setup_exchange_fragment.xml b/res/layout/account_setup_exchange_fragment.xml index e0e86da07..86b443e3a 100644 --- a/res/layout/account_setup_exchange_fragment.xml +++ b/res/layout/account_setup_exchange_fragment.xml @@ -32,7 +32,8 @@ android:inputType="textEmailAddress" android:imeOptions="actionDone" android:layout_height="wrap_content" - android:layout_width="match_parent" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_exchange_username_label" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_exchange_server_label" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_username_label" + android:inputType="textEmailAddress" + android:imeOptions="actionDone" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_password_label" + android:inputType="textPassword" + android:imeOptions="actionDone" /> + + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_pop_server_label" + android:inputType="textUri" + android:imeOptions="actionDone" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_port_label" + android:inputType="number" + android:imeOptions="actionDone" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_security_label" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_delete_policy_label" /> + android:layout_width="match_parent" + android:contentDescription="@string/account_setup_incoming_imap_path_prefix_label" + android:hint="@string/account_setup_incoming_imap_path_prefix_hint" + android:inputType="text" + android:imeOptions="actionDone" /> diff --git a/src/com/android/email/activity/MessageViewFragment.java b/src/com/android/email/activity/MessageViewFragment.java index 40ca1cf28..82783256f 100644 --- a/src/com/android/email/activity/MessageViewFragment.java +++ b/src/com/android/email/activity/MessageViewFragment.java @@ -36,6 +36,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.accessibility.AccessibilityEvent; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; @@ -252,6 +253,19 @@ public class MessageViewFragment extends MessageViewFragmentBase enableReplyForwardButtons(Mailbox.isMailboxTypeReplyAndForwardable(mailboxType)); } + /** + * Sets the content description for the star icon based on whether it's currently starred. + */ + private void setStarContentDescription(boolean isFavorite) { + if (isFavorite) { + mFavoriteIcon.setContentDescription( + mContext.getResources().getString(R.string.remove_star_action)); + } else { + mFavoriteIcon.setContentDescription( + mContext.getResources().getString(R.string.set_star_action)); + } + } + /** * Toggle favorite status and write back to provider */ @@ -263,6 +277,10 @@ public class MessageViewFragment extends MessageViewFragmentBase boolean newFavorite = ! message.mFlagFavorite; mFavoriteIcon.setImageDrawable(newFavorite ? mFavoriteIconOn : mFavoriteIconOff); + // Handle accessibility event + setStarContentDescription(newFavorite); + mFavoriteIcon.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); + // Update provider message.mFlagFavorite = newFavorite; getController().setMessageFavorite(message.mId, newFavorite); @@ -402,6 +420,10 @@ public class MessageViewFragment extends MessageViewFragmentBase @Override protected void onPostLoadBody() { onMarkMessageAsRead(true); + + // Initialize star content description for accessibility + Message message = getMessage(); + setStarContentDescription(message.mFlagFavorite); } @Override diff --git a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java index 7b37775e1..41f5a1813 100644 --- a/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java +++ b/src/com/android/email/activity/setup/AccountSetupIncomingFragment.java @@ -286,9 +286,13 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment { mBaseScheme = account.mHostAuthRecv.mProtocol; if (HostAuth.SCHEME_POP3.equals(mBaseScheme)) { mServerLabelView.setText(R.string.account_setup_incoming_pop_server_label); + mServerView.setContentDescription( + getResources().getString(R.string.account_setup_incoming_pop_server_label)); mImapPathPrefixSectionView.setVisibility(View.GONE); } else if (HostAuth.SCHEME_IMAP.equals(mBaseScheme)) { mServerLabelView.setText(R.string.account_setup_incoming_imap_server_label); + mServerView.setContentDescription( + getResources().getString(R.string.account_setup_incoming_imap_server_label)); mDeletePolicyLabelView.setVisibility(View.GONE); mDeletePolicyView.setVisibility(View.GONE); } else {