aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-12-19 18:18:18 +0900
committerJean Chalard <jchalard@google.com>2013-12-19 19:30:20 +0900
commit69a57bcdcd254b8e2dfbc367ef130114634c51a5 (patch)
tree5834e00a392e4830c4e6e82c3ffe6bae8fee760e /java/src
parent035e3885ac5db4944f3b244019ee73208a88fd39 (diff)
downloadlatinime-69a57bcdcd254b8e2dfbc367ef130114634c51a5.tar.gz
latinime-69a57bcdcd254b8e2dfbc367ef130114634c51a5.tar.xz
latinime-69a57bcdcd254b8e2dfbc367ef130114634c51a5.zip
[IL9] Move commitCurrentAutoCorrection to InputLogic
Bug: 8636060 Change-Id: I405c4a537858a6d5ab0b29502a2792e8c3b2564e
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java48
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java46
2 files changed, 50 insertions, 44 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 2fff8d25e..b837f3f71 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1357,7 +1357,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onTextInput(final String rawText) {
mInputLogic.mConnection.beginBatchEdit();
if (mInputLogic.mWordComposer.isComposingWord()) {
- commitCurrentAutoCorrection(rawText);
+ mInputLogic.commitCurrentAutoCorrection(mSettings.getCurrent(), rawText, mHandler);
} else {
mInputLogic.resetComposingState(true /* alsoResetLastComposedWord */);
}
@@ -1412,7 +1412,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// tapping probably is that the word you intend to type is not in the dictionary,
// so we do not attempt to correct, on the assumption that if that was a dictionary
// word, the user would probably have gestured instead.
- commitCurrentAutoCorrection(LastComposedWord.NOT_A_SEPARATOR);
+ mInputLogic.commitCurrentAutoCorrection(currentSettingsValues,
+ LastComposedWord.NOT_A_SEPARATOR, mHandler);
} else {
mInputLogic.commitTyped(LastComposedWord.NOT_A_SEPARATOR);
}
@@ -1769,7 +1770,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
- private void updateSuggestionStrip() {
+ // TODO[IL]: Move this to InputLogic and make private again
+ public void updateSuggestionStrip() {
mHandler.cancelUpdateSuggestionStrip();
final SettingsValues currentSettings = mSettings.getCurrent();
@@ -1934,46 +1936,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD));
}
- // TODO[IL]: Move this to InputLogic and make private again
- public void commitCurrentAutoCorrection(final String separator) {
- // Complete any pending suggestions query first
- if (mHandler.hasPendingUpdateSuggestions()) {
- updateSuggestionStrip();
- }
- final String typedAutoCorrection = mInputLogic.mWordComposer.getAutoCorrectionOrNull();
- final String typedWord = mInputLogic.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()) {
- LatinImeLoggerUtils.onAutoCorrection(
- typedWord, autoCorrection, separator, mInputLogic.mWordComposer);
- }
- if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
- final SuggestedWords suggestedWords = mInputLogic.mSuggestedWords;
- ResearchLogger.latinIme_commitCurrentAutoCorrection(typedWord, autoCorrection,
- separator, mInputLogic.mWordComposer.isBatchMode(), suggestedWords);
- }
- commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD,
- separator);
- 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.
- mInputLogic.mConnection.commitCorrection(
- new CorrectionInfo(mInputLogic.mLastSelectionEnd - typedWord.length(),
- typedWord, autoCorrection));
- }
- }
- }
-
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
@Override
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 33ca25c00..78f8885bc 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -21,6 +21,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
+import android.view.inputmethod.CorrectionInfo;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.compat.SuggestionSpanUtils;
@@ -401,7 +402,7 @@ public final class InputLogic {
if (settingsValues.mCorrectionEnabled) {
final String separator = shouldAvoidSendingCode ? LastComposedWord.NOT_A_SEPARATOR
: StringUtils.newSingleCodePointString(codePoint);
- mLatinIME.commitCurrentAutoCorrection(separator);
+ commitCurrentAutoCorrection(settingsValues, separator, handler);
didAutoCorrect = true;
} else {
commitTyped(StringUtils.newSingleCodePointString(codePoint));
@@ -904,4 +905,47 @@ public final class InputLogic {
separatorString);
}
}
+
+ // TODO: Make this private
+ public void commitCurrentAutoCorrection(final SettingsValues settingsValues,
+ final String separator,
+ // TODO: Remove this argument.
+ final LatinIME.UIHandler handler) {
+ // Complete any pending suggestions query first
+ if (handler.hasPendingUpdateSuggestions()) {
+ mLatinIME.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 (settingsValues.mIsInternal) {
+ LatinImeLoggerUtils.onAutoCorrection(
+ typedWord, autoCorrection, separator, mWordComposer);
+ }
+ if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
+ final SuggestedWords suggestedWords = mSuggestedWords;
+ ResearchLogger.latinIme_commitCurrentAutoCorrection(typedWord, autoCorrection,
+ separator, mWordComposer.isBatchMode(), suggestedWords);
+ }
+ mLatinIME.commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD,
+ separator);
+ 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));
+ }
+ }
+ }
}