diff options
| author | Gilles Debunne <debunne@google.com> | 2011-12-06 11:20:18 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-12-06 11:20:18 -0800 |
| commit | 98a85c2de6b3f27ba1ccb2cfd44a775b4f490f72 (patch) | |
| tree | b22f8ba576e60957ae00df709d9328f21fa634cc /core/java/android/widget/SpellChecker.java | |
| parent | 58ad16cfeaac1c2124d0f9e9d2b5c493e163128c (diff) | |
| parent | 8615ac9e049cdf4ab77b0897aca9bceec142c9fa (diff) | |
Merge "Invalidated bounds tightened in TextView" into ics-mr1
Diffstat (limited to 'core/java/android/widget/SpellChecker.java')
| -rw-r--r-- | core/java/android/widget/SpellChecker.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java index 5bb6bba938e5..f72cb873880a 100644 --- a/core/java/android/widget/SpellChecker.java +++ b/core/java/android/widget/SpellChecker.java @@ -274,9 +274,11 @@ public class SpellChecker implements SpellCheckerSessionListener { ((attributes & SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) > 0); SpellCheckSpan spellCheckSpan = mSpellCheckSpans[j]; + if (!isInDictionary && looksLikeTypo) { createMisspelledSuggestionSpan(editable, suggestionsInfo, spellCheckSpan); } + editable.removeSpan(spellCheckSpan); break; } @@ -292,20 +294,21 @@ public class SpellChecker implements SpellCheckerSessionListener { } } - private void createMisspelledSuggestionSpan(Editable editable, - SuggestionsInfo suggestionsInfo, SpellCheckSpan spellCheckSpan) { + private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo suggestionsInfo, + SpellCheckSpan spellCheckSpan) { final int start = editable.getSpanStart(spellCheckSpan); final int end = editable.getSpanEnd(spellCheckSpan); - if (start < 0 || end < 0) return; // span was removed in the meantime + if (start < 0 || end <= start) return; // span was removed in the meantime // Other suggestion spans may exist on that region, with identical suggestions, filter - // them out to avoid duplicates. First, filter suggestion spans on that exact region. + // them out to avoid duplicates. SuggestionSpan[] suggestionSpans = editable.getSpans(start, end, SuggestionSpan.class); final int length = suggestionSpans.length; for (int i = 0; i < length; i++) { final int spanStart = editable.getSpanStart(suggestionSpans[i]); final int spanEnd = editable.getSpanEnd(suggestionSpans[i]); if (spanStart != start || spanEnd != end) { + // Nulled (to avoid new array allocation) if not on that exact same region suggestionSpans[i] = null; } } @@ -353,8 +356,7 @@ public class SpellChecker implements SpellCheckerSessionListener { SuggestionSpan.FLAG_EASY_CORRECT | SuggestionSpan.FLAG_MISSPELLED); editable.setSpan(suggestionSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - // TODO limit to the word rectangle region - mTextView.invalidate(); + mTextView.invalidateRegion(start, end); } private class SpellParser { |
