Loading java/src/com/android/inputmethod/latin/LatinIME.java +24 −11 Original line number Diff line number Diff line Loading @@ -1131,7 +1131,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction commitChosenWord(typedWord, LastComposedWord.COMMIT_TYPE_USER_TYPED_WORD, separatorString); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.getInstance().onWordFinished(typedWord); ResearchLogger.getInstance().onWordFinished(typedWord, mWordComposer.isBatchMode()); } } } Loading Loading @@ -1163,7 +1163,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } private void swapSwapperAndSpace() { CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0); final CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0); // It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called. if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == Constants.CODE_SPACE) { Loading @@ -1171,7 +1171,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final String text = lastTwo.charAt(1) + " "; mConnection.commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_swapSwapperAndSpace(text); ResearchLogger.latinIME_swapSwapperAndSpace(lastTwo, text); } mKeyboardSwitcher.updateShiftState(); } Loading @@ -1191,7 +1191,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final String textToInsert = ". "; mConnection.commitText(textToInsert, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert); ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert, false /* isBatchMode */); } mKeyboardSwitcher.updateShiftState(); return true; Loading Loading @@ -1440,7 +1441,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } mConnection.commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_onTextInput(text); ResearchLogger.latinIME_onTextInput(text, false /* isBatchMode */); } mConnection.endBatchEdit(); // Space state must be updated before calling updateShiftState Loading Loading @@ -1665,10 +1666,13 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final int length = mWordComposer.size(); if (length > 0) { if (mWordComposer.isBatchMode()) { mWordComposer.reset(); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_handleBackspace_batch(mWordComposer.getTypedWord()); final String word = mWordComposer.getTypedWord(); ResearchLogger.latinIME_handleBackspace_batch(word); ResearchLogger.getInstance().uncommitCurrentLogUnit( word, false /* dumpCurrentLogUnit */); } mWordComposer.reset(); } else { mWordComposer.deleteLast(); } Loading Loading @@ -2084,7 +2088,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIme_commitCurrentAutoCorrection(typedWord, autoCorrection, separatorString); separatorString, mWordComposer.isBatchMode()); } mExpectingUpdateSelection = true; commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD, Loading Loading @@ -2118,7 +2122,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction onCodeInput(primaryCode, Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_punctuationSuggestion(index, suggestion); ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, false /* isBatchMode */); } return; } Loading Loading @@ -2157,7 +2162,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK, LastComposedWord.NOT_A_SEPARATOR); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion); ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion, mWordComposer.isBatchMode()); } mConnection.endBatchEdit(); // Don't allow cancellation of manual pick Loading Loading @@ -2254,6 +2260,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mConnection.getWordBeforeCursorIfAtEndOfWord(mSettings.getCurrent()); if (null != word) { restartSuggestionsOnWordBeforeCursor(word); // TODO: Handle the case where the user manually moves the cursor and then backs up over // a separator. In that case, the current log unit should not be uncommitted. if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.getInstance().uncommitCurrentLogUnit(word.toString(), true /* dumpCurrentLogUnit */); } } } Loading Loading @@ -2297,7 +2309,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_revertCommit(committedWord, originallyTypedWord); ResearchLogger.latinIME_revertCommit(committedWord, originallyTypedWord, mWordComposer.isBatchMode()); } // Don't restart suggestion yet. We'll restart if the user deletes the // separator. Loading java/src/com/android/inputmethod/latin/RichInputConnection.java +5 −4 Original line number Diff line number Diff line Loading @@ -648,19 +648,20 @@ public final class RichInputConnection { // Here we test whether we indeed have a period and a space before us. This should not // be needed, but it's there just in case something went wrong. final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0); if (!". ".equals(textBeforeCursor)) { final String periodSpace = ". "; if (!periodSpace.equals(textBeforeCursor)) { // Theoretically we should not be coming here if there isn't ". " before the // cursor, but the application may be changing the text while we are typing, so // anything goes. We should not crash. Log.d(TAG, "Tried to revert double-space combo but we didn't find " + "\". \" just before the cursor."); + "\"" + periodSpace + "\" just before the cursor."); return false; } deleteSurroundingText(2, 0); final String doubleSpace = " "; commitText(doubleSpace, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.richInputConnection_revertDoubleSpacePeriod(doubleSpace); ResearchLogger.richInputConnection_revertDoubleSpacePeriod(); } return true; } Loading @@ -685,7 +686,7 @@ public final class RichInputConnection { final String text = " " + textBeforeCursor.subSequence(0, 1); commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.richInputConnection_revertSwapPunctuation(text); ResearchLogger.richInputConnection_revertSwapPunctuation(); } return true; } Loading java/src/com/android/inputmethod/research/FixedLogBuffer.java +9 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,15 @@ public class FixedLogBuffer extends LogBuffer { mNumActualWords++; // Must be a word, or we wouldn't be here. } @Override public LogUnit unshiftIn() { final LogUnit logUnit = super.unshiftIn(); if (logUnit != null && logUnit.hasWord()) { mNumActualWords--; } return logUnit; } private void shiftOutThroughFirstWord() { final LinkedList<LogUnit> logUnits = getLogUnits(); while (!logUnits.isEmpty()) { Loading java/src/com/android/inputmethod/research/LogBuffer.java +14 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,20 @@ public class LogBuffer { mLogUnits.add(logUnit); } public LogUnit unshiftIn() { if (mLogUnits.isEmpty()) { return null; } return mLogUnits.removeLast(); } public LogUnit peekLastLogUnit() { if (mLogUnits.isEmpty()) { return null; } return mLogUnits.peekLast(); } public boolean isEmpty() { return mLogUnits.isEmpty(); } Loading java/src/com/android/inputmethod/research/LogUnit.java +10 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,7 @@ import java.util.Map; public LogUnit splitByTime(final long maxTime) { // Assume that mTimeList is in sorted order. final int length = mTimeList.size(); // TODO: find time by binary search, e.g. using Collections#binarySearch() for (int index = 0; index < length; index++) { if (mTimeList.get(index) > maxTime) { final List<LogStatement> laterLogStatements = Loading Loading @@ -267,4 +268,13 @@ import java.util.Map; } return new LogUnit(); } public void append(final LogUnit logUnit) { mLogStatementList.addAll(logUnit.mLogStatementList); mValuesList.addAll(logUnit.mValuesList); mTimeList.addAll(logUnit.mTimeList); mWord = null; mMayContainDigit = mMayContainDigit || logUnit.mMayContainDigit; mIsPartOfMegaword = false; } } Loading
java/src/com/android/inputmethod/latin/LatinIME.java +24 −11 Original line number Diff line number Diff line Loading @@ -1131,7 +1131,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction commitChosenWord(typedWord, LastComposedWord.COMMIT_TYPE_USER_TYPED_WORD, separatorString); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.getInstance().onWordFinished(typedWord); ResearchLogger.getInstance().onWordFinished(typedWord, mWordComposer.isBatchMode()); } } } Loading Loading @@ -1163,7 +1163,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } private void swapSwapperAndSpace() { CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0); final CharSequence lastTwo = mConnection.getTextBeforeCursor(2, 0); // It is guaranteed lastTwo.charAt(1) is a swapper - else this method is not called. if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == Constants.CODE_SPACE) { Loading @@ -1171,7 +1171,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final String text = lastTwo.charAt(1) + " "; mConnection.commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_swapSwapperAndSpace(text); ResearchLogger.latinIME_swapSwapperAndSpace(lastTwo, text); } mKeyboardSwitcher.updateShiftState(); } Loading @@ -1191,7 +1191,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final String textToInsert = ". "; mConnection.commitText(textToInsert, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert); ResearchLogger.latinIME_maybeDoubleSpacePeriod(textToInsert, false /* isBatchMode */); } mKeyboardSwitcher.updateShiftState(); return true; Loading Loading @@ -1440,7 +1441,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } mConnection.commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_onTextInput(text); ResearchLogger.latinIME_onTextInput(text, false /* isBatchMode */); } mConnection.endBatchEdit(); // Space state must be updated before calling updateShiftState Loading Loading @@ -1665,10 +1666,13 @@ public final class LatinIME extends InputMethodService implements KeyboardAction final int length = mWordComposer.size(); if (length > 0) { if (mWordComposer.isBatchMode()) { mWordComposer.reset(); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_handleBackspace_batch(mWordComposer.getTypedWord()); final String word = mWordComposer.getTypedWord(); ResearchLogger.latinIME_handleBackspace_batch(word); ResearchLogger.getInstance().uncommitCurrentLogUnit( word, false /* dumpCurrentLogUnit */); } mWordComposer.reset(); } else { mWordComposer.deleteLast(); } Loading Loading @@ -2084,7 +2088,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction } if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIme_commitCurrentAutoCorrection(typedWord, autoCorrection, separatorString); separatorString, mWordComposer.isBatchMode()); } mExpectingUpdateSelection = true; commitChosenWord(autoCorrection, LastComposedWord.COMMIT_TYPE_DECIDED_WORD, Loading Loading @@ -2118,7 +2122,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction onCodeInput(primaryCode, Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_punctuationSuggestion(index, suggestion); ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, false /* isBatchMode */); } return; } Loading Loading @@ -2157,7 +2162,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK, LastComposedWord.NOT_A_SEPARATOR); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion); ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion, mWordComposer.isBatchMode()); } mConnection.endBatchEdit(); // Don't allow cancellation of manual pick Loading Loading @@ -2254,6 +2260,12 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mConnection.getWordBeforeCursorIfAtEndOfWord(mSettings.getCurrent()); if (null != word) { restartSuggestionsOnWordBeforeCursor(word); // TODO: Handle the case where the user manually moves the cursor and then backs up over // a separator. In that case, the current log unit should not be uncommitted. if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.getInstance().uncommitCurrentLogUnit(word.toString(), true /* dumpCurrentLogUnit */); } } } Loading Loading @@ -2297,7 +2309,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); } if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.latinIME_revertCommit(committedWord, originallyTypedWord); ResearchLogger.latinIME_revertCommit(committedWord, originallyTypedWord, mWordComposer.isBatchMode()); } // Don't restart suggestion yet. We'll restart if the user deletes the // separator. Loading
java/src/com/android/inputmethod/latin/RichInputConnection.java +5 −4 Original line number Diff line number Diff line Loading @@ -648,19 +648,20 @@ public final class RichInputConnection { // Here we test whether we indeed have a period and a space before us. This should not // be needed, but it's there just in case something went wrong. final CharSequence textBeforeCursor = getTextBeforeCursor(2, 0); if (!". ".equals(textBeforeCursor)) { final String periodSpace = ". "; if (!periodSpace.equals(textBeforeCursor)) { // Theoretically we should not be coming here if there isn't ". " before the // cursor, but the application may be changing the text while we are typing, so // anything goes. We should not crash. Log.d(TAG, "Tried to revert double-space combo but we didn't find " + "\". \" just before the cursor."); + "\"" + periodSpace + "\" just before the cursor."); return false; } deleteSurroundingText(2, 0); final String doubleSpace = " "; commitText(doubleSpace, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.richInputConnection_revertDoubleSpacePeriod(doubleSpace); ResearchLogger.richInputConnection_revertDoubleSpacePeriod(); } return true; } Loading @@ -685,7 +686,7 @@ public final class RichInputConnection { final String text = " " + textBeforeCursor.subSequence(0, 1); commitText(text, 1); if (ProductionFlag.IS_EXPERIMENTAL) { ResearchLogger.richInputConnection_revertSwapPunctuation(text); ResearchLogger.richInputConnection_revertSwapPunctuation(); } return true; } Loading
java/src/com/android/inputmethod/research/FixedLogBuffer.java +9 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,15 @@ public class FixedLogBuffer extends LogBuffer { mNumActualWords++; // Must be a word, or we wouldn't be here. } @Override public LogUnit unshiftIn() { final LogUnit logUnit = super.unshiftIn(); if (logUnit != null && logUnit.hasWord()) { mNumActualWords--; } return logUnit; } private void shiftOutThroughFirstWord() { final LinkedList<LogUnit> logUnits = getLogUnits(); while (!logUnits.isEmpty()) { Loading
java/src/com/android/inputmethod/research/LogBuffer.java +14 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,20 @@ public class LogBuffer { mLogUnits.add(logUnit); } public LogUnit unshiftIn() { if (mLogUnits.isEmpty()) { return null; } return mLogUnits.removeLast(); } public LogUnit peekLastLogUnit() { if (mLogUnits.isEmpty()) { return null; } return mLogUnits.peekLast(); } public boolean isEmpty() { return mLogUnits.isEmpty(); } Loading
java/src/com/android/inputmethod/research/LogUnit.java +10 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,7 @@ import java.util.Map; public LogUnit splitByTime(final long maxTime) { // Assume that mTimeList is in sorted order. final int length = mTimeList.size(); // TODO: find time by binary search, e.g. using Collections#binarySearch() for (int index = 0; index < length; index++) { if (mTimeList.get(index) > maxTime) { final List<LogStatement> laterLogStatements = Loading Loading @@ -267,4 +268,13 @@ import java.util.Map; } return new LogUnit(); } public void append(final LogUnit logUnit) { mLogStatementList.addAll(logUnit.mLogStatementList); mValuesList.addAll(logUnit.mValuesList); mTimeList.addAll(logUnit.mTimeList); mWord = null; mMayContainDigit = mMayContainDigit || logUnit.mMayContainDigit; mIsPartOfMegaword = false; } }