am 9d014cde: am 8eb20652: Merge "Log for geometric input" into jb-mr1-dev

* commit '9d014cde85b820dc095d6ac0bcbe3647fae6d5e1':
  Log for geometric input
main
Satoshi Kataoka 2012-09-19 15:19:27 -07:00 committed by Android Git Automerger
commit d7db8728ac
4 changed files with 52 additions and 14 deletions

View File

@ -72,6 +72,7 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MainKeyboardView; import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.Utils.Stats;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.suggestions.SuggestionStripView; import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
@ -148,7 +149,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mIsUserDictionaryAvailable; private boolean mIsUserDictionaryAvailable;
private LastComposedWord mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD; private LastComposedWord mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
private WordComposer mWordComposer = new WordComposer(); private final WordComposer mWordComposer = new WordComposer();
private RichInputConnection mConnection = new RichInputConnection(this); private RichInputConnection mConnection = new RichInputConnection(this);
// Keep track of the last selection range to decide if we need to show word alternatives // Keep track of the last selection range to decide if we need to show word alternatives
@ -1331,6 +1332,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState); didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
} else { } else {
if (SPACE_STATE_PHANTOM == spaceState) { if (SPACE_STATE_PHANTOM == spaceState) {
if (ProductionFlag.IS_INTERNAL) {
if (mWordComposer.isComposingWord() && mWordComposer.isBatchMode()) {
Stats.onAutoCorrection(
"", mWordComposer.getTypedWord(), " ", mWordComposer);
}
}
commitTyped(LastComposedWord.NOT_A_SEPARATOR); commitTyped(LastComposedWord.NOT_A_SEPARATOR);
} }
final int keyX, keyY; final int keyX, keyY;
@ -1389,6 +1396,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onStartBatchInput() { public void onStartBatchInput() {
mConnection.beginBatchEdit(); mConnection.beginBatchEdit();
if (mWordComposer.isComposingWord()) { if (mWordComposer.isComposingWord()) {
if (ProductionFlag.IS_INTERNAL) {
if (mWordComposer.isBatchMode()) {
Stats.onAutoCorrection("", mWordComposer.getTypedWord(), " ", mWordComposer);
}
}
commitTyped(LastComposedWord.NOT_A_SEPARATOR); commitTyped(LastComposedWord.NOT_A_SEPARATOR);
mExpectingUpdateSelection = true; mExpectingUpdateSelection = true;
// The following is necessary for the case where the user typed something but didn't // The following is necessary for the case where the user typed something but didn't
@ -1547,7 +1559,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
} else { } else {
if (mLastComposedWord.canRevertCommit()) { if (mLastComposedWord.canRevertCommit()) {
Utils.Stats.onAutoCorrectionCancellation(); if (ProductionFlag.IS_INTERNAL) {
Stats.onAutoCorrectionCancellation();
}
revertCommit(); revertCommit();
return; return;
} }
@ -1696,7 +1710,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (null != mSuggestionStripView) mSuggestionStripView.dismissAddToDictionaryHint(); if (null != mSuggestionStripView) mSuggestionStripView.dismissAddToDictionaryHint();
} }
mHandler.postUpdateSuggestionStrip(); mHandler.postUpdateSuggestionStrip();
Utils.Stats.onNonSeparator((char)primaryCode, x, y); if (ProductionFlag.IS_INTERNAL) {
Utils.Stats.onNonSeparator((char)primaryCode, x, y);
}
} }
// Returns true if we did an autocorrection, false otherwise. // Returns true if we did an autocorrection, false otherwise.
@ -1760,8 +1776,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// already displayed or not, so it's okay. // already displayed or not, so it's okay.
setPunctuationSuggestions(); setPunctuationSuggestions();
} }
if (ProductionFlag.IS_INTERNAL) {
Utils.Stats.onSeparator((char)primaryCode, x, y); Utils.Stats.onSeparator((char)primaryCode, x, y);
}
mHandler.postUpdateShiftState(); mHandler.postUpdateShiftState();
return didAutoCorrect; return didAutoCorrect;
@ -1930,7 +1947,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
throw new RuntimeException("We have an auto-correction but the typed word " throw new RuntimeException("We have an auto-correction but the typed word "
+ "is empty? Impossible! I must commit suicide."); + "is empty? Impossible! I must commit suicide.");
} }
Utils.Stats.onAutoCorrection(typedWord, autoCorrection.toString(), separatorString); if (ProductionFlag.IS_INTERNAL) {
Stats.onAutoCorrection(
typedWord, autoCorrection.toString(), separatorString, mWordComposer);
}
mExpectingUpdateSelection = true; mExpectingUpdateSelection = true;
commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD, commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD,
separatorString); separatorString);
@ -2020,8 +2040,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// If the suggestion is not in the dictionary, the hint should be shown. // If the suggestion is not in the dictionary, the hint should be shown.
&& !AutoCorrection.isValidWord(mSuggest.getUnigramDictionaries(), suggestion, true); && !AutoCorrection.isValidWord(mSuggest.getUnigramDictionaries(), suggestion, true);
Utils.Stats.onSeparator((char)Keyboard.CODE_SPACE, if (ProductionFlag.IS_INTERNAL) {
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); Stats.onSeparator((char)Keyboard.CODE_SPACE,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
}
if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) { if (showingAddToDictionaryHint && mIsUserDictionaryAvailable) {
mSuggestionStripView.showAddToDictionaryHint( mSuggestionStripView.showAddToDictionaryHint(
suggestion, mCurrentSettings.mHintToSaveText); suggestion, mCurrentSettings.mHintToSaveText);
@ -2138,8 +2160,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
previousWord.toString(), committedWord.toString()); previousWord.toString(), committedWord.toString());
} }
mConnection.commitText(originallyTypedWord + mLastComposedWord.mSeparatorString, 1); mConnection.commitText(originallyTypedWord + mLastComposedWord.mSeparatorString, 1);
Utils.Stats.onSeparator(mLastComposedWord.mSeparatorString, if (ProductionFlag.IS_INTERNAL) {
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); Stats.onSeparator(mLastComposedWord.mSeparatorString,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
}
if (ProductionFlag.IS_EXPERIMENTAL) { if (ProductionFlag.IS_EXPERIMENTAL) {
ResearchLogger.latinIME_revertCommit(originallyTypedWord); ResearchLogger.latinIME_revertCommit(originallyTypedWord);
} }

View File

@ -49,7 +49,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
} }
public static void logOnAutoCorrectionForGeometric(String before, String after, public static void logOnAutoCorrectionForGeometric(String before, String after,
int separatorCode, int[] xCoordinates, int[] yCoordinates, int[] relativeTimes) { int separatorCode, InputPointers inputPointers) {
} }
public static void logOnAutoCorrectionCancelled() { public static void logOnAutoCorrectionCancelled() {

View File

@ -306,6 +306,10 @@ public class Suggest {
wordComposer, prevWordForBigram, proximityInfo, sessionId)); wordComposer, prevWordForBigram, proximityInfo, sessionId));
} }
for (SuggestedWordInfo wordInfo : suggestionsSet) {
LatinImeLogger.onAddSuggestedWord(wordInfo.mWord.toString(), wordInfo.mSourceDict);
}
final ArrayList<SuggestedWordInfo> suggestionsContainer = final ArrayList<SuggestedWordInfo> suggestionsContainer =
CollectionUtils.newArrayList(suggestionsSet); CollectionUtils.newArrayList(suggestionsSet);
final int suggestionsCount = suggestionsContainer.size(); final int suggestionsCount = suggestionsContainer.size();

View File

@ -412,14 +412,24 @@ public final class Utils {
} }
public static void onAutoCorrection(final String typedWord, final String correctedWord, public static void onAutoCorrection(final String typedWord, final String correctedWord,
final String separatorString) { final String separatorString, final WordComposer wordComposer) {
if (TextUtils.isEmpty(typedWord)) return; final boolean isBatchMode = wordComposer.isBatchMode();
if (!isBatchMode && TextUtils.isEmpty(typedWord)) return;
// TODO: this fails when the separator is more than 1 code point long, but // TODO: this fails when the separator is more than 1 code point long, but
// the backend can't handle it yet. The only case when this happens is with // the backend can't handle it yet. The only case when this happens is with
// smileys and other multi-character keys. // smileys and other multi-character keys.
final int codePoint = TextUtils.isEmpty(separatorString) ? Constants.NOT_A_CODE final int codePoint = TextUtils.isEmpty(separatorString) ? Constants.NOT_A_CODE
: separatorString.codePointAt(0); : separatorString.codePointAt(0);
LatinImeLogger.logOnAutoCorrectionForTyping(typedWord, correctedWord, codePoint); if (!isBatchMode) {
LatinImeLogger.logOnAutoCorrectionForTyping(typedWord, correctedWord, codePoint);
} else {
if (!TextUtils.isEmpty(correctedWord)) {
// We must make sure that InputPointer contains only the relative timestamps,
// not actual timestamps.
LatinImeLogger.logOnAutoCorrectionForGeometric(
"", correctedWord, codePoint, wordComposer.getInputPointers());
}
}
} }
public static void onAutoCorrectionCancellation() { public static void onAutoCorrectionCancellation() {