Exemplo n.º 1
0
 public virtual bool notifySuggestionPicked(android.text.style.SuggestionSpan span
                                            , string originalString, int index)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 2
0
 public abstract bool notifySuggestionPicked(android.text.style.SuggestionSpan arg1
                                             , string arg2, int arg3);
Exemplo n.º 3
0
        private void createMisspelledSuggestionSpan(android.text.Editable editable, android.view.textservice.SuggestionsInfo
                                                    suggestionsInfo, android.text.style.SpellCheckSpan spellCheckSpan)
        {
            int start = editable.getSpanStart(spellCheckSpan);
            int end   = editable.getSpanEnd(spellCheckSpan);

            // 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.
            android.text.style.SuggestionSpan[] suggestionSpans = editable.getSpans <android.text.style.SuggestionSpan
                                                                                     >(start, end);
            int length = suggestionSpans.Length;
            {
                for (int i = 0; i < length; i++)
                {
                    int spanStart = editable.getSpanStart(suggestionSpans[i]);
                    int spanEnd   = editable.getSpanEnd(suggestionSpans[i]);
                    if (spanStart != start || spanEnd != end)
                    {
                        suggestionSpans[i] = null;
                        break;
                    }
                }
            }
            int suggestionsCount = suggestionsInfo.getSuggestionsCount();

            string[] suggestions;
            if (suggestionsCount <= 0)
            {
                // A negative suggestion count is possible
                suggestions = new string[0];
            }
            else
            {
                int numberOfSuggestions = 0;
                suggestions = new string[suggestionsCount];
                {
                    for (int i_1 = 0; i_1 < suggestionsCount; i_1++)
                    {
                        string spellSuggestion = suggestionsInfo.getSuggestionAt(i_1);
                        if (spellSuggestion == null)
                        {
                            break;
                        }
                        bool suggestionFound = false;
                        {
                            for (int j = 0; j < length && !suggestionFound; j++)
                            {
                                if (suggestionSpans[j] == null)
                                {
                                    break;
                                }
                                string[] suggests = suggestionSpans[j].getSuggestions();
                                {
                                    for (int k = 0; k < suggests.Length; k++)
                                    {
                                        if (spellSuggestion.Equals(suggests[k]))
                                        {
                                            // The suggestion is already provided by an other SuggestionSpan
                                            suggestionFound = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        if (!suggestionFound)
                        {
                            suggestions[numberOfSuggestions++] = spellSuggestion;
                        }
                    }
                }
                if (numberOfSuggestions != suggestionsCount)
                {
                    string[] newSuggestions = new string[numberOfSuggestions];
                    System.Array.Copy(suggestions, 0, newSuggestions, 0, numberOfSuggestions);
                    suggestions = newSuggestions;
                }
            }
            android.text.style.SuggestionSpan suggestionSpan = new android.text.style.SuggestionSpan
                                                                   (mTextView.getContext(), suggestions, android.text.style.SuggestionSpan.FLAG_EASY_CORRECT
                                                                   | android.text.style.SuggestionSpan.FLAG_MISSPELLED);
            editable.setSpan(suggestionSpan, start, end, android.text.SpannedClass.SPAN_EXCLUSIVE_EXCLUSIVE
                             );
            // TODO limit to the word rectangle region
            mTextView.invalidate();
        }