Merge "Remove side-effects from TextEntryState"
This commit is contained in:
commit
f162ed7ec8
3 changed files with 41 additions and 12 deletions
|
@ -1431,6 +1431,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// TODO: Merge space state with TextEntryState
|
// TODO: Merge space state with TextEntryState
|
||||||
TextEntryState.backspace();
|
TextEntryState.backspace();
|
||||||
if (null != mWordSavedForAutoCorrectCancellation) {
|
if (null != mWordSavedForAutoCorrectCancellation) {
|
||||||
|
Utils.Stats.onAutoCorrectionCancellation();
|
||||||
cancelAutoCorrect(ic);
|
cancelAutoCorrect(ic);
|
||||||
mWordSavedForAutoCorrectCancellation = null;
|
mWordSavedForAutoCorrectCancellation = null;
|
||||||
ic.endBatchEdit();
|
ic.endBatchEdit();
|
||||||
|
@ -1574,7 +1575,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
switcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
TextEntryState.typedCharacter((char) code, mSettingsValues.isWordSeparator(code), x, y);
|
if (mSettingsValues.isWordSeparator(code)) {
|
||||||
|
TextEntryState.typedCharacter((char) code, true, x, y);
|
||||||
|
Utils.Stats.onSeparator((char)code, x, y);
|
||||||
|
} else {
|
||||||
|
TextEntryState.typedCharacter((char) code, false, x, y);
|
||||||
|
Utils.Stats.onNonSeparator((char)code, x, y);
|
||||||
|
}
|
||||||
if (null != ic) ic.endBatchEdit();
|
if (null != ic) ic.endBatchEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1657,6 +1664,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEntryState.typedCharacter((char) primaryCode, true, x, y);
|
TextEntryState.typedCharacter((char) primaryCode, true, x, y);
|
||||||
|
Utils.Stats.onSeparator((char)primaryCode, x, y);
|
||||||
|
|
||||||
if (pickedDefault) {
|
if (pickedDefault) {
|
||||||
CharSequence typedWord = mWordComposer.getTypedWord();
|
CharSequence typedWord = mWordComposer.getTypedWord();
|
||||||
|
@ -1868,7 +1876,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
}
|
}
|
||||||
if (mBestWord != null && mBestWord.length() > 0) {
|
if (mBestWord != null && mBestWord.length() > 0) {
|
||||||
TextEntryState.acceptedDefault(mWordComposer.getTypedWord(), mBestWord, separatorCode);
|
Utils.Stats.onAutoCorrection(mWordComposer.getTypedWord(), mBestWord.toString(),
|
||||||
|
separatorCode);
|
||||||
|
TextEntryState.acceptedDefault(mWordComposer.getTypedWord(), mBestWord,
|
||||||
|
separatorCode);
|
||||||
mExpectingUpdateSelection = true;
|
mExpectingUpdateSelection = true;
|
||||||
commitBestWord(mBestWord);
|
commitBestWord(mBestWord);
|
||||||
if (!mBestWord.equals(mWordComposer.getTypedWord())) {
|
if (!mBestWord.equals(mWordComposer.getTypedWord())) {
|
||||||
|
@ -1976,6 +1987,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// TextEntryState.State.PICKED_SUGGESTION state.
|
// TextEntryState.State.PICKED_SUGGESTION state.
|
||||||
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
|
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
|
||||||
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
||||||
|
Utils.Stats.onSeparator((char)Keyboard.CODE_SPACE, WordComposer.NOT_A_COORDINATE,
|
||||||
|
WordComposer.NOT_A_COORDINATE);
|
||||||
if (!showingAddToDictionaryHint) {
|
if (!showingAddToDictionaryHint) {
|
||||||
// If we're not showing the "Touch again to save", then show corrections again.
|
// If we're not showing the "Touch again to save", then show corrections again.
|
||||||
// In case the cursor position doesn't change, make sure we show the suggestions again.
|
// In case the cursor position doesn't change, make sure we show the suggestions again.
|
||||||
|
@ -2195,6 +2208,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
ic.commitText(separator, 1);
|
ic.commitText(separator, 1);
|
||||||
TextEntryState.typedCharacter(separator.charAt(0), true,
|
TextEntryState.typedCharacter(separator.charAt(0), true,
|
||||||
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
||||||
|
Utils.Stats.onSeparator(separator.charAt(0), WordComposer.NOT_A_COORDINATE,
|
||||||
|
WordComposer.NOT_A_COORDINATE);
|
||||||
mHandler.cancelUpdateBigramPredictions();
|
mHandler.cancelUpdateBigramPredictions();
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -48,8 +47,6 @@ public class TextEntryState {
|
||||||
int separatorCode) {
|
int separatorCode) {
|
||||||
if (TextUtils.isEmpty(typedWord)) return;
|
if (TextUtils.isEmpty(typedWord)) return;
|
||||||
setState(ACCEPTED_DEFAULT);
|
setState(ACCEPTED_DEFAULT);
|
||||||
LatinImeLogger.logOnAutoCorrection(
|
|
||||||
typedWord.toString(), actualWord.toString(), separatorCode);
|
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
displayState("acceptedDefault", "typedWord", typedWord, "actualWord", actualWord);
|
displayState("acceptedDefault", "typedWord", typedWord, "actualWord", actualWord);
|
||||||
}
|
}
|
||||||
|
@ -131,19 +128,12 @@ public class TextEntryState {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RingCharBuffer.getInstance().push(c, x, y);
|
|
||||||
if (isSeparator) {
|
|
||||||
LatinImeLogger.logOnInputSeparator();
|
|
||||||
} else {
|
|
||||||
LatinImeLogger.logOnInputChar();
|
|
||||||
}
|
|
||||||
if (DEBUG) displayState("typedCharacter", "char", c, "isSeparator", isSeparator);
|
if (DEBUG) displayState("typedCharacter", "char", c, "isSeparator", isSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void backspace() {
|
public static void backspace() {
|
||||||
if (sState == ACCEPTED_DEFAULT) {
|
if (sState == ACCEPTED_DEFAULT) {
|
||||||
setState(UNDO_COMMIT);
|
setState(UNDO_COMMIT);
|
||||||
LatinImeLogger.logOnAutoCorrectionCancelled();
|
|
||||||
} else if (sState == UNDO_COMMIT) {
|
} else if (sState == UNDO_COMMIT) {
|
||||||
setState(IN_WORD);
|
setState(IN_WORD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -843,4 +843,28 @@ public class Utils {
|
||||||
return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
|
return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
|
||||||
&& !suggestions.shouldBlockAutoCorrection();
|
&& !suggestions.shouldBlockAutoCorrection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Stats {
|
||||||
|
public static void onNonSeparator(final char code, final int x,
|
||||||
|
final int y) {
|
||||||
|
RingCharBuffer.getInstance().push(code, x, y);
|
||||||
|
LatinImeLogger.logOnInputChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onSeparator(final char code, final int x,
|
||||||
|
final int y) {
|
||||||
|
RingCharBuffer.getInstance().push(code, x, y);
|
||||||
|
LatinImeLogger.logOnInputSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onAutoCorrection(final String typedWord, final String correctedWord,
|
||||||
|
final int separatorCode) {
|
||||||
|
if (TextUtils.isEmpty(typedWord)) return;
|
||||||
|
LatinImeLogger.logOnAutoCorrection(typedWord, correctedWord, separatorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onAutoCorrectionCancellation() {
|
||||||
|
LatinImeLogger.logOnAutoCorrectionCancelled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue