Merge "Pre-populate contentDescription for MessageListItems"

This commit is contained in:
Jorge Lugo 2011-08-09 17:26:09 -07:00 committed by Android (Google) Code Review
commit 0ce564962c

View File

@ -57,13 +57,6 @@ public class MessageListItem extends View {
/* package */ long mMailboxId; /* package */ long mMailboxId;
/* package */ long mAccountId; /* package */ long mAccountId;
/**
* Set to true when testing. Enables pre-populating items with content descriptions so that
* automated testing can see it without first selecting each item one-by-one.
*/
@VisibleForTesting
public boolean isTesting = false;
private MessagesAdapter mAdapter; private MessagesAdapter mAdapter;
private MessageListItemCoordinates mCoordinates; private MessageListItemCoordinates mCoordinates;
private Context mContext; private Context mContext;
@ -193,7 +186,7 @@ public class MessageListItem extends View {
if (!Objects.equal(mSubject, subject)) { if (!Objects.equal(mSubject, subject)) {
mSubject = subject; mSubject = subject;
changed = true; changed = true;
setContentDescription(null); populateContentDescription();
} }
if (!Objects.equal(mSnippet, snippet)) { if (!Objects.equal(mSnippet, snippet)) {
@ -219,11 +212,6 @@ public class MessageListItem extends View {
ssb.append(mSnippet); ssb.append(mSnippet);
} }
mText = ssb; mText = ssb;
// Avoid setting the contentDescription for every item unless needed.
if (isTesting) {
populateContentDescription();
}
} }
} }
@ -529,7 +517,6 @@ public class MessageListItem extends View {
@Override @Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
populateContentDescription();
event.setClassName(getClass().getName()); event.setClassName(getClass().getName());
event.setPackageName(getContext().getPackageName()); event.setPackageName(getContext().getPackageName());
event.setEnabled(true); event.setEnabled(true);
@ -541,12 +528,10 @@ public class MessageListItem extends View {
* Sets the content description for this item, used for accessibility. * Sets the content description for this item, used for accessibility.
*/ */
private void populateContentDescription() { private void populateContentDescription() {
if (TextUtils.isEmpty(getContentDescription())) { if (!TextUtils.isEmpty(mSubject)) {
if (!TextUtils.isEmpty(mSubject)) { setContentDescription(sSubjectDescription + mSubject);
setContentDescription(sSubjectDescription + mSubject); } else {
} else { setContentDescription(sSubjectEmptyDescription);
setContentDescription(sSubjectEmptyDescription);
}
} }
} }
} }