Set content descrition of words in suggestions strip
Bug: 14849593 Change-Id: If020e2352c8e950ce87dc4711c39b8a6a41f66fcmain
parent
48b96a6a52
commit
f3c852efad
|
@ -23,6 +23,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:src="@drawable/suggestions_strip_divider"
|
android:src="@drawable/suggestions_strip_divider"
|
||||||
|
android:clickable="false"
|
||||||
|
android:longClickable="false"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
android:padding="0dp"
|
android:padding="0dp"
|
||||||
android:gravity="center" />
|
android:gravity="center" />
|
||||||
|
|
|
@ -379,10 +379,9 @@ final class SuggestionStripLayoutHelper {
|
||||||
} else {
|
} else {
|
||||||
wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
wordView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
// {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack.
|
||||||
// Disable this suggestion if the suggestion is null or empty.
|
// Use a simple {@link String} to avoid the issue.
|
||||||
// TODO: Fix disabled {@link TextView}'s content description.
|
wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString());
|
||||||
wordView.setEnabled(!TextUtils.isEmpty(word));
|
|
||||||
final CharSequence text = getEllipsizedText(word, width, wordView.getPaint());
|
final CharSequence text = getEllipsizedText(word, width, wordView.getPaint());
|
||||||
final float scaleX = getTextScaleX(word, width, wordView.getPaint());
|
final float scaleX = getTextScaleX(word, width, wordView.getPaint());
|
||||||
wordView.setText(text); // TextView.setText() resets text scale x to 1.0.
|
wordView.setText(text); // TextView.setText() resets text scale x to 1.0.
|
||||||
|
@ -461,14 +460,15 @@ final class SuggestionStripLayoutHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextView wordView = mWordViews.get(positionInStrip);
|
final TextView wordView = mWordViews.get(positionInStrip);
|
||||||
wordView.setEnabled(true);
|
final String punctuation = punctuationSuggestions.getLabel(positionInStrip);
|
||||||
wordView.setTextColor(mColorAutoCorrect);
|
|
||||||
// {@link TextView#getTag()} is used to get the index in suggestedWords at
|
// {@link TextView#getTag()} is used to get the index in suggestedWords at
|
||||||
// {@link SuggestionStripView#onClick(View)}.
|
// {@link SuggestionStripView#onClick(View)}.
|
||||||
wordView.setTag(positionInStrip);
|
wordView.setTag(positionInStrip);
|
||||||
wordView.setText(punctuationSuggestions.getLabel(positionInStrip));
|
wordView.setText(punctuation);
|
||||||
|
wordView.setContentDescription(punctuation);
|
||||||
wordView.setTextScaleX(1.0f);
|
wordView.setTextScaleX(1.0f);
|
||||||
wordView.setCompoundDrawables(null, null, null, null);
|
wordView.setCompoundDrawables(null, null, null, null);
|
||||||
|
wordView.setTextColor(mColorAutoCorrect);
|
||||||
stripView.addView(wordView);
|
stripView.addView(wordView);
|
||||||
setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
|
setLayoutWeight(wordView, 1.0f, mSuggestionsStripHeight);
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
|
||||||
word.setOnLongClickListener(this);
|
word.setOnLongClickListener(this);
|
||||||
mWordViews.add(word);
|
mWordViews.add(word);
|
||||||
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
final View divider = inflater.inflate(R.layout.suggestion_divider, null);
|
||||||
divider.setOnClickListener(this);
|
|
||||||
mDividerViews.add(divider);
|
mDividerViews.add(divider);
|
||||||
final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
|
final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
|
||||||
info.setTextColor(Color.WHITE);
|
info.setTextColor(Color.WHITE);
|
||||||
|
|
Loading…
Reference in New Issue