Search in sources :

Example 1 with SuggestionsInfo

use of android.view.textservice.SuggestionsInfo in project XobotOS by xamarin.

the class SpellChecker method onGetSuggestions.

@Override
public void onGetSuggestions(SuggestionsInfo[] results) {
    Editable editable = (Editable) mTextView.getText();
    for (int i = 0; i < results.length; i++) {
        SuggestionsInfo suggestionsInfo = results[i];
        if (suggestionsInfo.getCookie() != mCookie)
            continue;
        final int sequenceNumber = suggestionsInfo.getSequence();
        for (int j = 0; j < mLength; j++) {
            if (sequenceNumber == mIds[j]) {
                final int attributes = suggestionsInfo.getSuggestionsAttributes();
                boolean isInDictionary = ((attributes & SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY) > 0);
                boolean looksLikeTypo = ((attributes & SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) > 0);
                SpellCheckSpan spellCheckSpan = mSpellCheckSpans[j];
                if (!isInDictionary && looksLikeTypo) {
                    createMisspelledSuggestionSpan(editable, suggestionsInfo, spellCheckSpan);
                }
                editable.removeSpan(spellCheckSpan);
                break;
            }
        }
    }
    final int length = mSpellParsers.length;
    for (int i = 0; i < length; i++) {
        final SpellParser spellParser = mSpellParsers[i];
        if (!spellParser.isDone()) {
            spellParser.parse();
        }
    }
}
Also used : SpellCheckSpan(android.text.style.SpellCheckSpan) Editable(android.text.Editable) SuggestionsInfo(android.view.textservice.SuggestionsInfo)

Example 2 with SuggestionsInfo

use of android.view.textservice.SuggestionsInfo in project android_frameworks_base by ParanoidAndroid.

the class SpellChecker method onGetSentenceSuggestions.

@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
    final Editable editable = (Editable) mTextView.getText();
    for (int i = 0; i < results.length; ++i) {
        final SentenceSuggestionsInfo ssi = results[i];
        if (ssi == null) {
            continue;
        }
        SpellCheckSpan spellCheckSpan = null;
        for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
            final SuggestionsInfo suggestionsInfo = ssi.getSuggestionsInfoAt(j);
            if (suggestionsInfo == null) {
                continue;
            }
            final int offset = ssi.getOffsetAt(j);
            final int length = ssi.getLengthAt(j);
            final SpellCheckSpan scs = onGetSuggestionsInternal(suggestionsInfo, offset, length);
            if (spellCheckSpan == null && scs != null) {
                // the spellCheckSpan is shared by all the "SuggestionsInfo"s in the same
                // SentenceSuggestionsInfo. Removal is deferred after this loop.
                spellCheckSpan = scs;
            }
        }
        if (spellCheckSpan != null) {
            // onSpellCheckSpanRemoved will recycle this span in the pool
            editable.removeSpan(spellCheckSpan);
        }
    }
    scheduleNewSpellCheck();
}
Also used : SpellCheckSpan(android.text.style.SpellCheckSpan) Editable(android.text.Editable) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SuggestionsInfo(android.view.textservice.SuggestionsInfo)

Example 3 with SuggestionsInfo

use of android.view.textservice.SuggestionsInfo in project platform_frameworks_base by android.

the class SpellChecker method onGetSentenceSuggestions.

@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
    final Editable editable = (Editable) mTextView.getText();
    for (int i = 0; i < results.length; ++i) {
        final SentenceSuggestionsInfo ssi = results[i];
        if (ssi == null) {
            continue;
        }
        SpellCheckSpan spellCheckSpan = null;
        for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
            final SuggestionsInfo suggestionsInfo = ssi.getSuggestionsInfoAt(j);
            if (suggestionsInfo == null) {
                continue;
            }
            final int offset = ssi.getOffsetAt(j);
            final int length = ssi.getLengthAt(j);
            final SpellCheckSpan scs = onGetSuggestionsInternal(suggestionsInfo, offset, length);
            if (spellCheckSpan == null && scs != null) {
                // the spellCheckSpan is shared by all the "SuggestionsInfo"s in the same
                // SentenceSuggestionsInfo. Removal is deferred after this loop.
                spellCheckSpan = scs;
            }
        }
        if (spellCheckSpan != null) {
            // onSpellCheckSpanRemoved will recycle this span in the pool
            editable.removeSpan(spellCheckSpan);
        }
    }
    scheduleNewSpellCheck();
}
Also used : SpellCheckSpan(android.text.style.SpellCheckSpan) Editable(android.text.Editable) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SuggestionsInfo(android.view.textservice.SuggestionsInfo)

Example 4 with SuggestionsInfo

use of android.view.textservice.SuggestionsInfo in project android_frameworks_base by AOSPA.

the class SpellChecker method onGetSentenceSuggestions.

@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
    final Editable editable = (Editable) mTextView.getText();
    for (int i = 0; i < results.length; ++i) {
        final SentenceSuggestionsInfo ssi = results[i];
        if (ssi == null) {
            continue;
        }
        SpellCheckSpan spellCheckSpan = null;
        for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
            final SuggestionsInfo suggestionsInfo = ssi.getSuggestionsInfoAt(j);
            if (suggestionsInfo == null) {
                continue;
            }
            final int offset = ssi.getOffsetAt(j);
            final int length = ssi.getLengthAt(j);
            final SpellCheckSpan scs = onGetSuggestionsInternal(suggestionsInfo, offset, length);
            if (spellCheckSpan == null && scs != null) {
                // the spellCheckSpan is shared by all the "SuggestionsInfo"s in the same
                // SentenceSuggestionsInfo. Removal is deferred after this loop.
                spellCheckSpan = scs;
            }
        }
        if (spellCheckSpan != null) {
            // onSpellCheckSpanRemoved will recycle this span in the pool
            editable.removeSpan(spellCheckSpan);
        }
    }
    scheduleNewSpellCheck();
}
Also used : SpellCheckSpan(android.text.style.SpellCheckSpan) Editable(android.text.Editable) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SuggestionsInfo(android.view.textservice.SuggestionsInfo)

Example 5 with SuggestionsInfo

use of android.view.textservice.SuggestionsInfo in project android_frameworks_base by ResurrectionRemix.

the class SpellChecker method onGetSentenceSuggestions.

@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
    final Editable editable = (Editable) mTextView.getText();
    for (int i = 0; i < results.length; ++i) {
        final SentenceSuggestionsInfo ssi = results[i];
        if (ssi == null) {
            continue;
        }
        SpellCheckSpan spellCheckSpan = null;
        for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
            final SuggestionsInfo suggestionsInfo = ssi.getSuggestionsInfoAt(j);
            if (suggestionsInfo == null) {
                continue;
            }
            final int offset = ssi.getOffsetAt(j);
            final int length = ssi.getLengthAt(j);
            final SpellCheckSpan scs = onGetSuggestionsInternal(suggestionsInfo, offset, length);
            if (spellCheckSpan == null && scs != null) {
                // the spellCheckSpan is shared by all the "SuggestionsInfo"s in the same
                // SentenceSuggestionsInfo. Removal is deferred after this loop.
                spellCheckSpan = scs;
            }
        }
        if (spellCheckSpan != null) {
            // onSpellCheckSpanRemoved will recycle this span in the pool
            editable.removeSpan(spellCheckSpan);
        }
    }
    scheduleNewSpellCheck();
}
Also used : SpellCheckSpan(android.text.style.SpellCheckSpan) Editable(android.text.Editable) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SentenceSuggestionsInfo(android.view.textservice.SentenceSuggestionsInfo) SuggestionsInfo(android.view.textservice.SuggestionsInfo)

Aggregations

SuggestionsInfo (android.view.textservice.SuggestionsInfo)11 SentenceSuggestionsInfo (android.view.textservice.SentenceSuggestionsInfo)9 Editable (android.text.Editable)7 SpellCheckSpan (android.text.style.SpellCheckSpan)7 TargetApi (android.annotation.TargetApi)2 NgramContext (com.android.inputmethod.latin.NgramContext)2 TextInfo (android.view.textservice.TextInfo)1 Keyboard (com.android.inputmethod.keyboard.Keyboard)1 WordComposer (com.android.inputmethod.latin.WordComposer)1 SuggestionResults (com.android.inputmethod.latin.utils.SuggestionResults)1 ArrayList (java.util.ArrayList)1