Merge "Add RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS."
This commit is contained in:
committed by
Android (Google) Code Review
commit
7bcdf29c37
@@ -52151,6 +52151,7 @@ package android.view.textservice {
|
||||
method public void setCookieAndSequence(int, int);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.view.textservice.SuggestionsInfo> CREATOR;
|
||||
field public static final int RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS = 16; // 0x10
|
||||
field public static final int RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS = 4; // 0x4
|
||||
field public static final int RESULT_ATTR_IN_THE_DICTIONARY = 1; // 0x1
|
||||
field public static final int RESULT_ATTR_LOOKS_LIKE_GRAMMAR_ERROR = 8; // 0x8
|
||||
|
||||
@@ -402,6 +402,10 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan {
|
||||
}
|
||||
} else if (autoCorrection) {
|
||||
tp.setUnderlineText(mAutoCorrectionUnderlineColor, mAutoCorrectionUnderlineThickness);
|
||||
} else if (misspelled) {
|
||||
tp.setUnderlineText(mMisspelledUnderlineColor, mMisspelledUnderlineThickness);
|
||||
} else if (grammarError) {
|
||||
tp.setUnderlineText(mGrammarErrorUnderlineColor, mGrammarErrorUnderlineThickness);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,6 +429,10 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan {
|
||||
}
|
||||
} else if (autoCorrection) {
|
||||
return mAutoCorrectionUnderlineColor;
|
||||
} else if (misspelled) {
|
||||
return mMisspelledUnderlineColor;
|
||||
} else if (grammarError) {
|
||||
return mGrammarErrorUnderlineColor;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,16 @@ public final class SuggestionsInfo implements Parcelable {
|
||||
*/
|
||||
public static final int RESULT_ATTR_LOOKS_LIKE_GRAMMAR_ERROR = 0x0008;
|
||||
|
||||
/**
|
||||
* Flag of the attributes of the suggestions that can be obtained by
|
||||
* {@link #getSuggestionsAttributes}: this tells that the text service has an alternative way to
|
||||
* show UI for the list of correction suggestions to the user. When this flag is set, the
|
||||
* receiver of the result suggestions should mark the erroneous part of the text with a text
|
||||
* signifier (for example, underline), but should not show any UI for the list of correction
|
||||
* suggestions to the user (for example, in a popup window).
|
||||
*/
|
||||
public static final int RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS = 0x0010;
|
||||
|
||||
private final int mSuggestionsAttributes;
|
||||
private final String[] mSuggestions;
|
||||
private final boolean mSuggestionsAvailable;
|
||||
|
||||
@@ -477,6 +477,8 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
||||
mTextView.postDelayed(mSpellRunnable, SPELL_PAUSE_DURATION);
|
||||
}
|
||||
|
||||
// When calling this method, RESULT_ATTR_LOOKS_LIKE_TYPO or RESULT_ATTR_LOOKS_LIKE_GRAMMAR_ERROR
|
||||
// (or both) should be set in suggestionsInfo.
|
||||
private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo suggestionsInfo,
|
||||
SpellCheckSpan spellCheckSpan, int offset, int length) {
|
||||
final int spellCheckSpanStart = editable.getSpanStart(spellCheckSpan);
|
||||
@@ -506,7 +508,10 @@ public class SpellChecker implements SpellCheckerSessionListener {
|
||||
}
|
||||
|
||||
final int suggestionsAttrs = suggestionsInfo.getSuggestionsAttributes();
|
||||
int flags = SuggestionSpan.FLAG_EASY_CORRECT;
|
||||
int flags = 0;
|
||||
if ((suggestionsAttrs & SuggestionsInfo.RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS) == 0) {
|
||||
flags |= SuggestionSpan.FLAG_EASY_CORRECT;
|
||||
}
|
||||
if ((suggestionsAttrs & SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) != 0) {
|
||||
flags |= SuggestionSpan.FLAG_MISSPELLED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user