49 @NonNull TextServicesManager textServicesManager,
50 @NonNull SpellCheckChannel spellCheckChannel) {
51 mTextServicesManager = textServicesManager;
52 mSpellCheckChannel = spellCheckChannel;
54 mSpellCheckChannel.setSpellCheckMethodHandler(
this);
92 Locale localeFromString = LocalizationPlugin.localeFromString(locale);
94 if (mSpellCheckerSession ==
null) {
95 mSpellCheckerSession =
96 mTextServicesManager.newSpellCheckerSession(
104 TextInfo[] textInfos =
new TextInfo[] {
new TextInfo(
text)};
105 mSpellCheckerSession.getSentenceSuggestions(textInfos, MAX_SPELL_CHECK_SUGGESTIONS);
126 if (results.length == 0) {
127 pendingResult.success(
new ArrayList<HashMap<String, Object>>());
132 ArrayList<HashMap<String, Object>> spellCheckerSuggestionSpans =
133 new ArrayList<HashMap<String, Object>>();
134 SentenceSuggestionsInfo spellCheckResults = results[0];
135 if (spellCheckResults ==
null) {
136 pendingResult.success(
new ArrayList<HashMap<String, Object>>());
141 for (
int i = 0; i < spellCheckResults.getSuggestionsCount(); i++) {
142 SuggestionsInfo suggestionsInfo = spellCheckResults.getSuggestionsInfoAt(i);
143 int suggestionsCount = suggestionsInfo.getSuggestionsCount();
145 if (suggestionsCount <= 0) {
149 HashMap<String, Object> spellCheckerSuggestionSpan =
new HashMap<String, Object>();
150 int start = spellCheckResults.getOffsetAt(i);
151 int end =
start + spellCheckResults.getLengthAt(i);
156 ArrayList<String> suggestions =
new ArrayList<String>();
157 boolean validSuggestionsFound =
false;
158 for (
int j = 0; j < suggestionsCount; j++) {
159 String suggestion = suggestionsInfo.getSuggestionAt(j);
162 if (!suggestion.equals(
"")) {
163 validSuggestionsFound =
true;
164 suggestions.add(suggestion);
168 if (!validSuggestionsFound) {
172 spellCheckerSuggestionSpans.add(spellCheckerSuggestionSpan);