am 9770336a: Merge "Label empty suggestions."
* commit '9770336a9b9b65fc62bde6f361e90909d4259769':
Label empty suggestions.
diff --git a/java/res/values/strings-talkback-descriptions.xml b/java/res/values/strings-talkback-descriptions.xml
index 36fa7b3..9644271 100644
--- a/java/res/values/strings-talkback-descriptions.xml
+++ b/java/res/values/strings-talkback-descriptions.xml
@@ -31,6 +31,9 @@
<!-- Spoken description used during obscured (e.g. password) entry to let the user know that auto-correction will be performed when a key is pressed. -->
<string name="spoken_auto_correct_obscured"><xliff:g id="KEY_NAME" example="Space">%1$s</xliff:g> performs auto-correction</string>
+ <!-- Spoken description of a suggestion when nothing is specified and the field is blank. -->
+ <string name="spoken_empty_suggestion">No suggestion</string>
+
<!-- Spoken description for unknown keyboard keys. -->
<string name="spoken_description_unknown">Unknown character</string>
<!-- Spoken description for the "Shift" keyboard key when "Shift" is off. -->
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
index a9d1207..d8926ff 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java
@@ -342,8 +342,11 @@
* @param placerView the view where the debug info will be placed.
* @return the start index of more suggestions.
*/
- public int layoutAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords,
- final ViewGroup stripView, final ViewGroup placerView) {
+ public int layoutAndReturnStartIndexOfMoreSuggestions(
+ final Context context,
+ final SuggestedWords suggestedWords,
+ final ViewGroup stripView,
+ final ViewGroup placerView) {
if (suggestedWords.isPunctuationSuggestions()) {
return layoutPunctuationsAndReturnStartIndexOfMoreSuggestions(
(PunctuationSuggestions)suggestedWords, stripView);
@@ -362,7 +365,7 @@
// by consolidating all slots in the strip.
final int countInStrip = 1;
mMoreSuggestionsAvailable = (wordCountToShow > countInStrip);
- layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
+ layoutWord(context, mCenterPositionInStrip, stripWidth - mPadding);
stripView.addView(centerWordView);
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
if (SuggestionStripView.DBG) {
@@ -385,7 +388,7 @@
}
final int width = getSuggestionWidth(positionInStrip, stripWidth);
- final TextView wordView = layoutWord(positionInStrip, width);
+ final TextView wordView = layoutWord(context, positionInStrip, width);
stripView.addView(wordView);
setLayoutWeight(wordView, getSuggestionWeight(positionInStrip),
ViewGroup.LayoutParams.MATCH_PARENT);
@@ -414,7 +417,7 @@
* @param width the maximum width for layout in pixels.
* @return the {@link TextView} containing the suggested word appropriately formatted.
*/
- private TextView layoutWord(final int positionInStrip, final int width) {
+ private TextView layoutWord(final Context context, final int positionInStrip, final int width) {
final TextView wordView = mWordViews.get(positionInStrip);
final CharSequence word = wordView.getText();
if (positionInStrip == mCenterPositionInStrip && mMoreSuggestionsAvailable) {
@@ -428,7 +431,10 @@
}
// {@link StyleSpan} in a content description may cause an issue of TTS/TalkBack.
// Use a simple {@link String} to avoid the issue.
- wordView.setContentDescription(TextUtils.isEmpty(word) ? null : word.toString());
+ wordView.setContentDescription(
+ TextUtils.isEmpty(word)
+ ? context.getResources().getString(R.string.spoken_empty_suggestion)
+ : word.toString());
final CharSequence text = getEllipsizedTextWithSettingScaleX(
word, width, wordView.getPaint());
final float scaleX = wordView.getTextScaleX();
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 4b84949..17525f6 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -146,6 +146,7 @@
for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
+ word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
word.setOnClickListener(this);
word.setOnLongClickListener(this);
mWordViews.add(word);
@@ -200,7 +201,7 @@
mStripVisibilityGroup.setLayoutDirection(isRtlLanguage);
mSuggestedWords = suggestedWords;
mStartIndexOfMoreSuggestions = mLayoutHelper.layoutAndReturnStartIndexOfMoreSuggestions(
- mSuggestedWords, mSuggestionsStrip, this);
+ getContext(), mSuggestedWords, mSuggestionsStrip, this);
mStripVisibilityGroup.showSuggestionsStrip();
}