From d94522c6d9b3afad6b6796bc58d5a31b11d7b16d Mon Sep 17 00:00:00 2001 From: Ben Komalo Date: Thu, 20 Oct 2011 21:32:20 -0700 Subject: [PATCH] Make Email widget more accessible. Bug: 5480096 Change-Id: I58fe6bd070c7d8058f2a920012c3260bfed614b9 --- src/com/android/email/widget/EmailWidget.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/com/android/email/widget/EmailWidget.java b/src/com/android/email/widget/EmailWidget.java index 21961447d..a46a2904d 100644 --- a/src/com/android/email/widget/EmailWidget.java +++ b/src/com/android/email/widget/EmailWidget.java @@ -270,16 +270,21 @@ public class EmailWidget implements RemoteViewsService.RemoteViewsFactory, }); } + private void setTextViewTextAndDesc(RemoteViews views, final int id, String text) { + views.setTextViewText(id, text); + views.setContentDescription(id, text); + } + private void setupTitleAndCount(RemoteViews views) { // Set up the title (view type + count of messages) - views.setTextViewText(R.id.widget_title, mMailboxName); + setTextViewTextAndDesc(views, R.id.widget_title, mMailboxName); views.setViewVisibility(R.id.widget_tap, View.VISIBLE); - views.setTextViewText(R.id.widget_tap, mAccountName); + setTextViewTextAndDesc(views, R.id.widget_tap, mAccountName); String count = ""; if (isCursorValid()) { count = UiUtilities.getMessageCountForUi(mContext, mCursor.getMessageCount(), false); } - views.setTextViewText(R.id.widget_count, count); + setTextViewTextAndDesc(views, R.id.widget_count, count); } /** @@ -409,16 +414,17 @@ public class EmailWidget implements RemoteViewsService.RemoteViewsFactory, views.setInt(R.id.widget_message, "setBackgroundResource", drawableId); // Add style to sender - String cursorString = + String rawSender = mCursor.isNull(EmailWidgetLoader.WIDGET_COLUMN_DISPLAY_NAME) ? "" // an empty string : mCursor.getString(EmailWidgetLoader.WIDGET_COLUMN_DISPLAY_NAME); - SpannableStringBuilder from = new SpannableStringBuilder(cursorString); + SpannableStringBuilder from = new SpannableStringBuilder(rawSender); from.setSpan( isUnread ? new StyleSpan(Typeface.BOLD) : new StyleSpan(Typeface.NORMAL), 0, from.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); CharSequence styledFrom = addStyle(from, sSenderFontSize, sDefaultTextColor); views.setTextViewText(R.id.widget_from, styledFrom); + views.setContentDescription(R.id.widget_from, rawSender); long timestamp = mCursor.getLong(EmailWidgetLoader.WIDGET_COLUMN_TIMESTAMP); // Get a nicely formatted date string (relative to today) @@ -426,12 +432,14 @@ public class EmailWidget implements RemoteViewsService.RemoteViewsFactory, // Add style to date CharSequence styledDate = addStyle(date, sDateFontSize, sDefaultTextColor); views.setTextViewText(R.id.widget_date, styledDate); + views.setContentDescription(R.id.widget_date, date); // Add style to subject/snippet String subject = mCursor.getString(EmailWidgetLoader.WIDGET_COLUMN_SUBJECT); String snippet = mCursor.getString(EmailWidgetLoader.WIDGET_COLUMN_SNIPPET); CharSequence subjectAndSnippet = getStyledSubjectSnippet(subject, snippet, !isUnread); views.setTextViewText(R.id.widget_subject, subjectAndSnippet); + views.setContentDescription(R.id.widget_subject, subject); int messageFlags = mCursor.getInt(EmailWidgetLoader.WIDGET_COLUMN_FLAGS); boolean hasInvite = (messageFlags & Message.FLAG_INCOMING_MEETING_INVITE) != 0;