android.view.inputmethod.CorrectionInfo Java Examples

The following examples show how to use android.view.inputmethod.CorrectionInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RichInputConnection.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public void commitCorrection(final CorrectionInfo correctionInfo) {
    if (DEBUG_BATCH_NESTING) checkBatchEdit();
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
    // This has no effect on the text field and does not change its content. It only makes
    // TextView flash the text for a second based on indices contained in the argument.
    if (isConnected()) {
        mIC.commitCorrection(correctionInfo);
    }
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
}
 
Example #2
Source File: RichInputConnection.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void commitCorrection(final CorrectionInfo correctionInfo) {
    if (DEBUG_BATCH_NESTING) checkBatchEdit();
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
    // This has no effect on the text field and does not change its content. It only makes
    // TextView flash the text for a second based on indices contained in the argument.
    if (isConnected()) {
        mIC.commitCorrection(correctionInfo);
    }
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
}
 
Example #3
Source File: EditText.java    From material with Apache License 2.0 5 votes vote down vote up
/**
    * Called by the framework in response to a text auto-correction (such as fixing a typo using a
    * a dictionnary) from the current input method, provided by it calling
    * {@link InputConnection#commitCorrection} InputConnection.commitCorrection()}. The default
    * implementation flashes the background of the corrected word to provide feedback to the user.
    *
    * @param info The auto correct info about the text that was corrected.
    */
public void onCommitCorrection (CorrectionInfo info){
       if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE)
           ((InternalEditText)mInputView).superOnCommitCorrection(info);
       else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE)
           ((InternalAutoCompleteTextView)mInputView).superOnCommitCorrection(info);
       else
           ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCorrection(info);
}
 
Example #4
Source File: ThreadedInputConnection.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @see InputConnection#commitCorrection(android.view.inputmethod.CorrectionInfo)
 */
@Override
public boolean commitCorrection(CorrectionInfo correctionInfo) {
    if (DEBUG_LOGS) {
        Log.i(TAG, "commitCorrection [%s]",
                ImeUtils.getCorrectionInfoDebugString(correctionInfo));
    }
    return false;
}
 
Example #5
Source File: EditText.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
/**
    * Called by the framework in response to a text auto-correction (such as fixing a typo using a
    * a dictionnary) from the current input method, provided by it calling
    * {@link InputConnection#commitCorrection} InputConnection.commitCorrection()}. The default
    * implementation flashes the background of the corrected word to provide feedback to the user.
    *
    * @param info The auto correct info about the text that was corrected.
    */
public void onCommitCorrection (CorrectionInfo info){
       if(mAutoCompleteMode == AUTOCOMPLETE_MODE_NONE)
           ((InternalEditText)mInputView).superOnCommitCorrection(info);
       else if(mAutoCompleteMode == AUTOCOMPLETE_MODE_SINGLE)
           ((InternalAutoCompleteTextView)mInputView).superOnCommitCorrection(info);
       else
           ((InternalMultiAutoCompleteTextView)mInputView).superOnCommitCorrection(info);
}
 
Example #6
Source File: RichInputConnection.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public void commitCorrection(final CorrectionInfo correctionInfo) {
    if (DEBUG_BATCH_NESTING) checkBatchEdit();
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
    // This has no effect on the text field and does not change its content. It only makes
    // TextView flash the text for a second based on indices contained in the argument.
    if (isConnected()) {
        mIC.commitCorrection(correctionInfo);
    }
    if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
}
 
Example #7
Source File: ImeUtils.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * @param correctionInfo The correction info.
 * @return Debug string for the given {@CorrectionInfo}.
 */
static String getCorrectionInfoDebugString(CorrectionInfo correctionInfo) {
    // TODO(changwan): implement it properly if needed.
    return correctionInfo.toString();
}
 
Example #8
Source File: InputLogic.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Commit the current auto-correction.
 *
 * This will commit the best guess of the keyboard regarding what the user meant by typing
 * the currently composing word. The IME computes suggestions and assigns a confidence score
 * to each of them; when it's confident enough in one suggestion, it replaces the typed string
 * by this suggestion at commit time. When it's not confident enough, or when it has no
 * suggestions, or when the settings or environment does not allow for auto-correction, then
 * this method just commits the typed string.
 * Note that if suggestions are currently being computed in the background, this method will
 * block until the computation returns. This is necessary for consistency (it would be very
 * strange if pressing space would commit a different word depending on how fast you press).
 *
 * @param settingsValues the current value of the settings.
 * @param separator the separator that's causing the commit to happen.
 */
private void commitCurrentAutoCorrection(final SettingsValues settingsValues,
        final String separator, final LatinIME.UIHandler handler) {
    // Complete any pending suggestions query first
    if (handler.hasPendingUpdateSuggestions()) {
        handler.cancelUpdateSuggestionStrip();
        // To know the input style here, we should retrieve the in-flight "update suggestions"
        // message and read its arg1 member here. However, the Handler class does not let
        // us retrieve this message, so we can't do that. But in fact, we notice that
        // we only ever come here when the input style was typing. In the case of batch
        // input, we update the suggestions synchronously when the tail batch comes. Likewise
        // for application-specified completions. As for recorrections, we never auto-correct,
        // so we don't come here either. Hence, the input style is necessarily
        // INPUT_STYLE_TYPING.
        performUpdateSuggestionStripSync(settingsValues, SuggestedWords.INPUT_STYLE_TYPING);
    }
    final SuggestedWordInfo autoCorrectionOrNull = mWordComposer.getAutoCorrectionOrNull();
    final String typedWord = mWordComposer.getTypedWord();
    final String stringToCommit = (autoCorrectionOrNull != null)
            ? autoCorrectionOrNull.mWord : typedWord;
    if (stringToCommit != null) {
        if (TextUtils.isEmpty(typedWord)) {
            throw new RuntimeException("We have an auto-correction but the typed word "
                    + "is empty? Impossible! I must commit suicide.");
        }
        final boolean isBatchMode = mWordComposer.isBatchMode();
        commitChosenWord(settingsValues, stringToCommit,
                LastComposedWord.COMMIT_TYPE_DECIDED_WORD, separator);
        if (!typedWord.equals(stringToCommit)) {
            // This will make the correction flash for a short while as a visual clue
            // to the user that auto-correction happened. It has no other effect; in particular
            // note that this won't affect the text inside the text field AT ALL: it only makes
            // the segment of text starting at the supplied index and running for the length
            // of the auto-correction flash. At this moment, the "typedWord" argument is
            // ignored by TextView.
            mConnection.commitCorrection(new CorrectionInfo(
                    mConnection.getExpectedSelectionEnd() - stringToCommit.length(),
                    typedWord, stringToCommit));
            String prevWordsContext = (autoCorrectionOrNull != null)
                    ? autoCorrectionOrNull.mPrevWordsContext
                    : "";
            StatsUtils.onAutoCorrection(typedWord, stringToCommit, isBatchMode,
                    mDictionaryFacilitator, prevWordsContext);
            StatsUtils.onWordCommitAutoCorrect(stringToCommit, isBatchMode);
        } else {
            StatsUtils.onWordCommitUserTyped(stringToCommit, isBatchMode);
        }
    }
}
 
Example #9
Source File: InputLogic.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
/**
 * Commit the current auto-correction.
 *
 * This will commit the best guess of the keyboard regarding what the user meant by typing
 * the currently composing word. The IME computes suggestions and assigns a confidence score
 * to each of them; when it's confident enough in one suggestion, it replaces the typed string
 * by this suggestion at commit time. When it's not confident enough, or when it has no
 * suggestions, or when the settings or environment does not allow for auto-correction, then
 * this method just commits the typed string.
 * Note that if suggestions are currently being computed in the background, this method will
 * block until the computation returns. This is necessary for consistency (it would be very
 * strange if pressing space would commit a different word depending on how fast you press).
 *
 * @param settingsValues the current value of the settings.
 * @param separator the separator that's causing the commit to happen.
 */
private void commitCurrentAutoCorrection(final SettingsValues settingsValues,
        final String separator, final LatinIME.UIHandler handler) {
    // Complete any pending suggestions query first
    if (handler.hasPendingUpdateSuggestions()) {
        handler.cancelUpdateSuggestionStrip();
        // To know the input style here, we should retrieve the in-flight "update suggestions"
        // message and read its arg1 member here. However, the Handler class does not let
        // us retrieve this message, so we can't do that. But in fact, we notice that
        // we only ever come here when the input style was typing. In the case of batch
        // input, we update the suggestions synchronously when the tail batch comes. Likewise
        // for application-specified completions. As for recorrections, we never auto-correct,
        // so we don't come here either. Hence, the input style is necessarily
        // INPUT_STYLE_TYPING.
        performUpdateSuggestionStripSync(settingsValues, SuggestedWords.INPUT_STYLE_TYPING);
    }
    final SuggestedWordInfo autoCorrectionOrNull = mWordComposer.getAutoCorrectionOrNull();
    final String typedWord = mWordComposer.getTypedWord();
    final String stringToCommit = (autoCorrectionOrNull != null)
            ? autoCorrectionOrNull.mWord : typedWord;
    if (stringToCommit != null) {
        if (TextUtils.isEmpty(typedWord)) {
            throw new RuntimeException("We have an auto-correction but the typed word "
                    + "is empty? Impossible! I must commit suicide.");
        }
        final boolean isBatchMode = mWordComposer.isBatchMode();
        commitChosenWord(settingsValues, stringToCommit,
                LastComposedWord.COMMIT_TYPE_DECIDED_WORD, separator);
        if (!typedWord.equals(stringToCommit)) {
            // This will make the correction flash for a short while as a visual clue
            // to the user that auto-correction happened. It has no other effect; in particular
            // note that this won't affect the text inside the text field AT ALL: it only makes
            // the segment of text starting at the supplied index and running for the length
            // of the auto-correction flash. At this moment, the "typedWord" argument is
            // ignored by TextView.
            mConnection.commitCorrection(new CorrectionInfo(
                    mConnection.getExpectedSelectionEnd() - stringToCommit.length(),
                    typedWord, stringToCommit));
            String prevWordsContext = (autoCorrectionOrNull != null)
                    ? autoCorrectionOrNull.mPrevWordsContext
                    : "";
            StatsUtils.onAutoCorrection(typedWord, stringToCommit, isBatchMode,
                    mDictionaryFacilitator, prevWordsContext);
            StatsUtils.onWordCommitAutoCorrect(stringToCommit, isBatchMode);
        } else {
            StatsUtils.onWordCommitUserTyped(stringToCommit, isBatchMode);
        }
    }
}
 
Example #10
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #11
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
Example #12
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #13
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
Example #14
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #15
Source File: EditText.java    From material with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
Example #16
Source File: TEditText.java    From timecat with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    super.onCommitCorrection(info);
}
 
Example #17
Source File: InputLogic.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 4 votes vote down vote up
/**
 * Commit the current auto-correction.
 *
 * This will commit the best guess of the keyboard regarding what the user meant by typing
 * the currently composing word. The IME computes suggestions and assigns a confidence score
 * to each of them; when it's confident enough in one suggestion, it replaces the typed string
 * by this suggestion at commit time. When it's not confident enough, or when it has no
 * suggestions, or when the settings or environment does not allow for auto-correction, then
 * this method just commits the typed string.
 * Note that if suggestions are currently being computed in the background, this method will
 * block until the computation returns. This is necessary for consistency (it would be very
 * strange if pressing space would commit a different word depending on how fast you press).
 *
 * @param settingsValues the current value of the settings.
 * @param separator the separator that's causing the commit to happen.
 */
private void commitCurrentAutoCorrection(final SettingsValues settingsValues,
        final String separator, final LatinIME.UIHandler handler) {
    // Complete any pending suggestions query first
    if (handler.hasPendingUpdateSuggestions()) {
        handler.cancelUpdateSuggestionStrip();
        // To know the input style here, we should retrieve the in-flight "update suggestions"
        // message and read its arg1 member here. However, the Handler class does not let
        // us retrieve this message, so we can't do that. But in fact, we notice that
        // we only ever come here when the input style was typing. In the case of batch
        // input, we update the suggestions synchronously when the tail batch comes. Likewise
        // for application-specified completions. As for recorrections, we never auto-correct,
        // so we don't come here either. Hence, the input style is necessarily
        // INPUT_STYLE_TYPING.
        performUpdateSuggestionStripSync(settingsValues, SuggestedWords.INPUT_STYLE_TYPING);
    }
    final SuggestedWordInfo autoCorrectionOrNull = mWordComposer.getAutoCorrectionOrNull();
    final String typedWord = mWordComposer.getTypedWord();
    final String stringToCommit = (autoCorrectionOrNull != null)
            ? autoCorrectionOrNull.mWord : typedWord;
    if (stringToCommit != null) {
        if (TextUtils.isEmpty(typedWord)) {
            throw new RuntimeException("We have an auto-correction but the typed word "
                    + "is empty? Impossible! I must commit suicide.");
        }
        final boolean isBatchMode = mWordComposer.isBatchMode();
        commitChosenWord(settingsValues, stringToCommit,
                LastComposedWord.COMMIT_TYPE_DECIDED_WORD, separator);
        if (!typedWord.equals(stringToCommit)) {
            // This will make the correction flash for a short while as a visual clue
            // to the user that auto-correction happened. It has no other effect; in particular
            // note that this won't affect the text inside the text field AT ALL: it only makes
            // the segment of text starting at the supplied index and running for the length
            // of the auto-correction flash. At this moment, the "typedWord" argument is
            // ignored by TextView.
            mConnection.commitCorrection(new CorrectionInfo(
                    mConnection.getExpectedSelectionEnd() - stringToCommit.length(),
                    typedWord, stringToCommit));
            String prevWordsContext = (autoCorrectionOrNull != null)
                    ? autoCorrectionOrNull.mPrevWordsContext
                    : "";
            StatsUtils.onAutoCorrection(typedWord, stringToCommit, isBatchMode,
                    mDictionaryFacilitator, prevWordsContext);
            StatsUtils.onWordCommitAutoCorrect(stringToCommit, isBatchMode);
        } else {
            StatsUtils.onWordCommitUserTyped(stringToCommit, isBatchMode);
        }
    }
}
 
Example #18
Source File: InputConnectionHacker.java    From 920-text-editor-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public boolean commitCorrection(CorrectionInfo correctionInfo) {
    return ic.commitCorrection(correctionInfo);
}
 
Example #19
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #20
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
Example #21
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #22
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
Example #23
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
Example #24
Source File: EditText.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}