Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Make temporary fix for Samsung spell checker giving blank results for all words #40924

Merged
merged 3 commits into from Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -149,10 +149,20 @@ public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
spellCheckerSuggestionSpan.put(END_INDEX_KEY, end);

ArrayList<String> suggestions = new ArrayList<String>();
boolean validSuggestionsFound = false;
for (int j = 0; j < suggestionsCount; j++) {
suggestions.add(suggestionsInfo.getSuggestionAt(j));
String suggestion = suggestionsInfo.getSuggestionAt(j);
// TODO(camsim99): Support spell check on Samsung by retrieving accurate spell check
// results, then remove this check: https://github.com/flutter/flutter/issues/120608.
if (!suggestion.equals("")) {
validSuggestionsFound = true;
suggestions.add(suggestion);
}
}

if (!validSuggestionsFound) {
continue;
}
spellCheckerSuggestionSpan.put(SUGGESTIONS_KEY, suggestions);
spellCheckerSuggestionSpans.add(spellCheckerSuggestionSpan);
}
Expand Down
Expand Up @@ -222,4 +222,29 @@ public void onGetSentenceSuggestionsResultsWithSuccessAndResultsProperly() {

verify(mockResult).success(expectedResults);
}

@Test
public void onGetSentenceSuggestionsResultsWithSuccessAndNoResultsWhenSuggestionsAreInvalid() {
TextServicesManager fakeTextServicesManager = mock(TextServicesManager.class);
SpellCheckChannel fakeSpellCheckChannel = mock(SpellCheckChannel.class);
SpellCheckPlugin spellCheckPlugin =
spy(new SpellCheckPlugin(fakeTextServicesManager, fakeSpellCheckChannel));
MethodChannel.Result mockResult = mock(MethodChannel.Result.class);
spellCheckPlugin.pendingResult = mockResult;

spellCheckPlugin.onGetSentenceSuggestions(
new SentenceSuggestionsInfo[] {
new SentenceSuggestionsInfo(
(new SuggestionsInfo[] {
new SuggestionsInfo(
SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO,
// This is the suggestion that may be provided by the Samsung spell checker:
new String[] {""})
}),
new int[] {7},
new int[] {5})
});

verify(mockResult).success(new ArrayList<HashMap<String, Object>>());
}
}