Add logOnSeparator
This is a supplement for I9abb8141f23100d Change-Id: I529d2a78f4fe630611db4cba830d933370c8c34fmain
parent
50cce07f59
commit
b5d17e52fc
|
@ -30,7 +30,6 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.KeyboardView;
|
import com.android.inputmethod.keyboard.KeyboardView;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
import com.android.inputmethod.keyboard.LatinKeyboard;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
@ -1174,10 +1173,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (primaryCode != Keyboard.CODE_ENTER) {
|
if (primaryCode != Keyboard.CODE_ENTER) {
|
||||||
mJustAddedAutoSpace = false;
|
mJustAddedAutoSpace = false;
|
||||||
}
|
}
|
||||||
RingCharBuffer.getInstance().push((char)primaryCode, x, y);
|
|
||||||
LatinImeLogger.logOnInputChar();
|
|
||||||
if (isWordSeparator(primaryCode)) {
|
if (isWordSeparator(primaryCode)) {
|
||||||
handleSeparator(primaryCode);
|
handleSeparator(primaryCode, x, y);
|
||||||
} else {
|
} else {
|
||||||
handleCharacter(primaryCode, keyCodes, x, y);
|
handleCharacter(primaryCode, keyCodes, x, y);
|
||||||
}
|
}
|
||||||
|
@ -1357,10 +1354,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
switcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
if (LatinIME.PERF_DEBUG) measureCps();
|
if (LatinIME.PERF_DEBUG) measureCps();
|
||||||
TextEntryState.typedCharacter((char) code, isWordSeparator(code));
|
TextEntryState.typedCharacter((char) code, isWordSeparator(code), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSeparator(int primaryCode) {
|
private void handleSeparator(int primaryCode, int x, int y) {
|
||||||
mVoiceProxy.handleSeparator();
|
mVoiceProxy.handleSeparator();
|
||||||
|
|
||||||
// Should dismiss the "Touch again to save" message when handling separator
|
// Should dismiss the "Touch again to save" message when handling separator
|
||||||
|
@ -1381,7 +1378,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// in Italian dov' should not be expanded to dove' because the elision
|
// in Italian dov' should not be expanded to dove' because the elision
|
||||||
// requires the last vowel to be removed.
|
// requires the last vowel to be removed.
|
||||||
if (mAutoCorrectOn && primaryCode != '\'') {
|
if (mAutoCorrectOn && primaryCode != '\'') {
|
||||||
pickedDefault = pickDefaultSuggestion();
|
pickedDefault = pickDefaultSuggestion(primaryCode);
|
||||||
// Picked the suggestion by the space key. We consider this
|
// Picked the suggestion by the space key. We consider this
|
||||||
// as "added an auto space".
|
// as "added an auto space".
|
||||||
if (primaryCode == Keyboard.CODE_SPACE) {
|
if (primaryCode == Keyboard.CODE_SPACE) {
|
||||||
|
@ -1403,7 +1400,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
reswapPeriodAndSpace();
|
reswapPeriodAndSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEntryState.typedCharacter((char) primaryCode, true);
|
TextEntryState.typedCharacter((char) primaryCode, true, x, y);
|
||||||
if (TextEntryState.isPunctuationAfterAccepted() && primaryCode != Keyboard.CODE_ENTER) {
|
if (TextEntryState.isPunctuationAfterAccepted() && primaryCode != Keyboard.CODE_ENTER) {
|
||||||
swapPunctuationAndSpace();
|
swapPunctuationAndSpace();
|
||||||
} else if (isSuggestionsRequested() && primaryCode == Keyboard.CODE_SPACE) {
|
} else if (isSuggestionsRequested() && primaryCode == Keyboard.CODE_SPACE) {
|
||||||
|
@ -1592,14 +1589,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
setCandidatesViewShown(isCandidateStripVisible());
|
setCandidatesViewShown(isCandidateStripVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pickDefaultSuggestion() {
|
private boolean pickDefaultSuggestion(int separatorCode) {
|
||||||
// Complete any pending candidate query first
|
// Complete any pending candidate query first
|
||||||
if (mHandler.hasPendingUpdateSuggestions()) {
|
if (mHandler.hasPendingUpdateSuggestions()) {
|
||||||
mHandler.cancelUpdateSuggestions();
|
mHandler.cancelUpdateSuggestions();
|
||||||
updateSuggestions();
|
updateSuggestions();
|
||||||
}
|
}
|
||||||
if (mBestWord != null && mBestWord.length() > 0) {
|
if (mBestWord != null && mBestWord.length() > 0) {
|
||||||
TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord);
|
TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord, separatorCode);
|
||||||
mJustAccepted = true;
|
mJustAccepted = true;
|
||||||
pickSuggestion(mBestWord);
|
pickSuggestion(mBestWord);
|
||||||
// Add the word to the auto dictionary if it's not a known word
|
// Add the word to the auto dictionary if it's not a known word
|
||||||
|
@ -1688,7 +1685,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
|
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
|
||||||
// we just did a correction, in which case we need to stay in
|
// we just did a correction, in which case we need to stay in
|
||||||
// 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);
|
||||||
setPunctuationSuggestions();
|
setPunctuationSuggestions();
|
||||||
} else if (!showingAddToDictionaryHint) {
|
} else 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.
|
||||||
|
@ -1895,7 +1893,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
ic.commitText(mComposing, 1);
|
ic.commitText(mComposing, 1);
|
||||||
TextEntryState.acceptedTyped(mComposing);
|
TextEntryState.acceptedTyped(mComposing);
|
||||||
ic.commitText(punctuation, 1);
|
ic.commitText(punctuation, 1);
|
||||||
TextEntryState.typedCharacter(punctuation.charAt(0), true);
|
TextEntryState.typedCharacter(punctuation.charAt(0), true,
|
||||||
|
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
||||||
// Clear composing text
|
// Clear composing text
|
||||||
mComposing.setLength(0);
|
mComposing.setLength(0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -45,10 +45,10 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
String before, String after, int position, List<CharSequence> suggestions) {
|
String before, String after, int position, List<CharSequence> suggestions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logOnAutoSuggestion(String before, String after) {
|
public static void logOnAutoCorrection(String before, String after, int separatorCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logOnAutoSuggestionCanceled() {
|
public static void logOnAutoCorrectionCancelled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logOnDelete() {
|
public static void logOnDelete() {
|
||||||
|
@ -57,6 +57,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
public static void logOnInputChar() {
|
public static void logOnInputChar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void logOnInputSeparator() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void logOnException(String metaData, Throwable e) {
|
public static void logOnException(String metaData, Throwable e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class TextEntryState {
|
public class TextEntryState {
|
||||||
|
@ -43,10 +45,12 @@ public class TextEntryState {
|
||||||
sState = newState;
|
sState = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void acceptedDefault(CharSequence typedWord, CharSequence actualWord) {
|
public static void acceptedDefault(CharSequence typedWord, CharSequence actualWord,
|
||||||
|
int separatorCode) {
|
||||||
if (typedWord == null) return;
|
if (typedWord == null) return;
|
||||||
setState(ACCEPTED_DEFAULT);
|
setState(ACCEPTED_DEFAULT);
|
||||||
LatinImeLogger.logOnAutoSuggestion(typedWord.toString(), actualWord.toString());
|
LatinImeLogger.logOnAutoCorrection(
|
||||||
|
typedWord.toString(), actualWord.toString(), separatorCode);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
displayState("acceptedDefault", "typedWord", typedWord, "actualWord", actualWord);
|
displayState("acceptedDefault", "typedWord", typedWord, "actualWord", actualWord);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +99,7 @@ public class TextEntryState {
|
||||||
if (DEBUG) displayState("onAbortRecorrection");
|
if (DEBUG) displayState("onAbortRecorrection");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void typedCharacter(char c, boolean isSeparator) {
|
public static void typedCharacter(char c, boolean isSeparator, int x, int y) {
|
||||||
final boolean isSpace = (c == ' ');
|
final boolean isSpace = (c == ' ');
|
||||||
switch (sState) {
|
switch (sState) {
|
||||||
case IN_WORD:
|
case IN_WORD:
|
||||||
|
@ -149,13 +153,19 @@ public class TextEntryState {
|
||||||
setState(START);
|
setState(START);
|
||||||
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.logOnAutoSuggestionCanceled();
|
LatinImeLogger.logOnAutoCorrectionCancelled();
|
||||||
} else if (sState == UNDO_COMMIT) {
|
} else if (sState == UNDO_COMMIT) {
|
||||||
setState(IN_WORD);
|
setState(IN_WORD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,11 +209,11 @@ public class Utils {
|
||||||
return mCharBuf[mEnd];
|
return mCharBuf[mEnd];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public char getLastChar() {
|
public char getBackwardNthChar(int n) {
|
||||||
if (mLength < 1) {
|
if (mLength <= n || n < 0) {
|
||||||
return PLACEHOLDER_DELIMITER_CHAR;
|
return PLACEHOLDER_DELIMITER_CHAR;
|
||||||
} else {
|
} else {
|
||||||
return mCharBuf[normalize(mEnd - 1)];
|
return mCharBuf[normalize(mEnd - n - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int getPreviousX(char c, int back) {
|
public int getPreviousX(char c, int back) {
|
||||||
|
@ -234,9 +234,16 @@ public class Utils {
|
||||||
return mYBuf[index];
|
return mYBuf[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public String getLastString() {
|
public String getLastWord(int ignoreCharCount) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < mLength; ++i) {
|
int i = ignoreCharCount;
|
||||||
|
for (; i < mLength; ++i) {
|
||||||
|
char c = mCharBuf[normalize(mEnd - 1 - i)];
|
||||||
|
if (!((LatinIME)mContext).isWordSeparator(c)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; i < mLength; ++i) {
|
||||||
char c = mCharBuf[normalize(mEnd - 1 - i)];
|
char c = mCharBuf[normalize(mEnd - 1 - i)];
|
||||||
if (!((LatinIME)mContext).isWordSeparator(c)) {
|
if (!((LatinIME)mContext).isWordSeparator(c)) {
|
||||||
sb.append(c);
|
sb.append(c);
|
||||||
|
|
Loading…
Reference in New Issue