类android.view.inputmethod.CorrectionInfo源码实例Demo

下面列出了怎么用android.view.inputmethod.CorrectionInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openboard   文件: RichInputConnection.java
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();
}
 
源代码2 项目: AOSP-Kayboard-7.1.2   文件: RichInputConnection.java
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();
}
 
源代码3 项目: MDPreference   文件: EditText.java
/**
    * 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);
}
 
源代码4 项目: 365browser   文件: ThreadedInputConnection.java
/**
 * @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;
}
 
源代码5 项目: material   文件: EditText.java
/**
    * 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);
}
 
源代码6 项目: Indic-Keyboard   文件: RichInputConnection.java
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();
}
 
源代码7 项目: openboard   文件: InputLogic.java
/**
 * 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);
        }
    }
}
 
源代码8 项目: timecat   文件: TEditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    super.onCommitCorrection(info);
}
 
源代码9 项目: AOSP-Kayboard-7.1.2   文件: InputLogic.java
/**
 * 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);
        }
    }
}
 
源代码10 项目: MDPreference   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码11 项目: MDPreference   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码12 项目: MDPreference   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码13 项目: MDPreference   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码14 项目: MDPreference   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码15 项目: MDPreference   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码16 项目: 920-text-editor-v2   文件: InputConnectionHacker.java
@Override
public boolean commitCorrection(CorrectionInfo correctionInfo) {
    return ic.commitCorrection(correctionInfo);
}
 
源代码17 项目: 365browser   文件: ImeUtils.java
/**
 * @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();
}
 
源代码18 项目: material   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码19 项目: material   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码20 项目: material   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码21 项目: material   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码22 项目: material   文件: EditText.java
@Override
public void onCommitCorrection(CorrectionInfo info) {
    EditText.this.onCommitCorrection(info);
}
 
源代码23 项目: material   文件: EditText.java
void superOnCommitCorrection(CorrectionInfo info) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        super.onCommitCorrection(info);
}
 
源代码24 项目: Indic-Keyboard   文件: InputLogic.java
/**
 * 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);
        }
    }
}
 
 类所在包
 同包方法