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(); }
/** * 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); }
/** * 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 android.view.inputmethod.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); }
/** * @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; }
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 (null != mIC) { mIC.commitCorrection(correctionInfo); } if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); }
private void commitCurrentAutoCorrection(final String separatorString) { // Complete any pending suggestions query first if (mHandler.hasPendingUpdateSuggestions()) { updateSuggestionStrip(); } final String typedAutoCorrection = mWordComposer.getAutoCorrectionOrNull(); final String typedWord = mWordComposer.getTypedWord(); final String autoCorrection = (typedAutoCorrection != null) ? typedAutoCorrection : typedWord; if (autoCorrection != null) { if (TextUtils.isEmpty(typedWord)) { throw new RuntimeException("We have an auto-correction but the typed word " + "is empty? Impossible! I must commit suicide."); } if (mSettings.isInternal()) { Stats.onAutoCorrection(typedWord, autoCorrection, separatorString, mWordComposer); } if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { final SuggestedWords suggestedWords = mSuggestedWords; ResearchLogger.latinIme_commitCurrentAutoCorrection(typedWord, autoCorrection, separatorString, mWordComposer.isBatchMode(), suggestedWords); } mExpectingUpdateSelection = true; commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD, separatorString); if (!typedWord.equals(autoCorrection)) { // 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(mLastSelectionEnd - typedWord.length(), typedWord, autoCorrection)); } } }
@Override public boolean commitCorrection(CorrectionInfo correctionInfo) { return mInputConnection.commitCorrection(correctionInfo); }
/** * 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); } } }
@Override public void onCommitCorrection(CorrectionInfo info) { EditText.this.onCommitCorrection(info); }
void superOnCommitCorrection(CorrectionInfo info) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) super.onCommitCorrection(info); }
@Override public boolean commitCorrection(CorrectionInfo correctionInfo) { return ic.commitCorrection(correctionInfo); }
/** * @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(); }
@Override public boolean commitCorrection(CorrectionInfo correctionInfo) { return enabled && super.commitCorrection(correctionInfo); }
/** * 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 (mEditor != null) mEditor.onCommitCorrection(info); }