Merge "Add backspace event methods to StatsUtils"

main
Mohammadinamul Sheik 2014-09-10 04:56:23 +00:00 committed by Android (Google) Code Review
commit 97243cea28
2 changed files with 34 additions and 0 deletions

View File

@ -28,6 +28,26 @@ public final class StatsUtils {
public static void onPickSuggestionManually(final SuggestedWords suggestedWords, public static void onPickSuggestionManually(final SuggestedWords suggestedWords,
final SuggestedWords.SuggestedWordInfo suggestionInfo) { final SuggestedWords.SuggestedWordInfo suggestionInfo) {
}
public static void onBackspaceWordDelete(int wordLength) {
}
public static void onBackspacePressed(int lengthToDelete) {
}
public static void onBackspaceSelectedText(int selectedTextLength) {
}
public static void onDeleteMultiCharInput(int multiCharLength) {
}
public static void onRevertAutoCorrect() {
}
public static void onRevertDoubleSpacePeriod() {
}
public static void onRevertSwapPunctuation() {
} }
} }

View File

@ -1088,8 +1088,10 @@ public final class InputLogic {
if (!TextUtils.isEmpty(rejectedSuggestion)) { if (!TextUtils.isEmpty(rejectedSuggestion)) {
mDictionaryFacilitator.removeWordFromPersonalizedDicts(rejectedSuggestion); mDictionaryFacilitator.removeWordFromPersonalizedDicts(rejectedSuggestion);
} }
StatsUtils.onBackspaceWordDelete(rejectedSuggestion.length());
} else { } else {
mWordComposer.applyProcessedEvent(event); mWordComposer.applyProcessedEvent(event);
StatsUtils.onBackspacePressed(1);
} }
if (mWordComposer.isComposingWord()) { if (mWordComposer.isComposingWord()) {
setComposingTextInternal(getTextWithUnderline(mWordComposer.getTypedWord()), 1); setComposingTextInternal(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
@ -1100,6 +1102,7 @@ public final class InputLogic {
} else { } else {
if (mLastComposedWord.canRevertCommit()) { if (mLastComposedWord.canRevertCommit()) {
revertCommit(inputTransaction); revertCommit(inputTransaction);
StatsUtils.onRevertAutoCorrect();
return; return;
} }
if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) { if (mEnteredText != null && mConnection.sameAsTextBeforeCursor(mEnteredText)) {
@ -1107,6 +1110,7 @@ public final class InputLogic {
// This is triggered on backspace after a key that inputs multiple characters, // This is triggered on backspace after a key that inputs multiple characters,
// like the smiley key or the .com key. // like the smiley key or the .com key.
mConnection.deleteSurroundingText(mEnteredText.length(), 0); mConnection.deleteSurroundingText(mEnteredText.length(), 0);
StatsUtils.onDeleteMultiCharInput(mEnteredText.length());
mEnteredText = null; mEnteredText = null;
// If we have mEnteredText, then we know that mHasUncommittedTypedChars == false. // If we have mEnteredText, then we know that mHasUncommittedTypedChars == false.
// In addition we know that spaceState is false, and that we should not be // In addition we know that spaceState is false, and that we should not be
@ -1122,10 +1126,12 @@ public final class InputLogic {
inputTransaction.setRequiresUpdateSuggestions(); inputTransaction.setRequiresUpdateSuggestions();
mWordComposer.setCapitalizedModeAtStartComposingTime( mWordComposer.setCapitalizedModeAtStartComposingTime(
WordComposer.CAPS_MODE_OFF); WordComposer.CAPS_MODE_OFF);
StatsUtils.onRevertDoubleSpacePeriod();
return; return;
} }
} else if (SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) { } else if (SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) {
if (mConnection.revertSwapPunctuation()) { if (mConnection.revertSwapPunctuation()) {
StatsUtils.onRevertSwapPunctuation();
// Likewise // Likewise
return; return;
} }
@ -1140,6 +1146,7 @@ public final class InputLogic {
mConnection.setSelection(mConnection.getExpectedSelectionEnd(), mConnection.setSelection(mConnection.getExpectedSelectionEnd(),
mConnection.getExpectedSelectionEnd()); mConnection.getExpectedSelectionEnd());
mConnection.deleteSurroundingText(numCharsDeleted, 0); mConnection.deleteSurroundingText(numCharsDeleted, 0);
StatsUtils.onBackspaceSelectedText(numCharsDeleted);
} else { } else {
// There is no selection, just delete one character. // There is no selection, just delete one character.
if (Constants.NOT_A_CURSOR_POSITION == mConnection.getExpectedSelectionEnd()) { if (Constants.NOT_A_CURSOR_POSITION == mConnection.getExpectedSelectionEnd()) {
@ -1156,9 +1163,12 @@ public final class InputLogic {
// applications are relying on this behavior so we continue to support it for // applications are relying on this behavior so we continue to support it for
// older apps, so we retain this behavior if the app has target SDK < JellyBean. // older apps, so we retain this behavior if the app has target SDK < JellyBean.
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL); sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
int totalDeletedLength = 1;
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) { if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL); sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
totalDeletedLength++;
} }
StatsUtils.onBackspacePressed(totalDeletedLength);
} else { } else {
final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor(); final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
if (codePointBeforeCursor == Constants.NOT_A_CODE) { if (codePointBeforeCursor == Constants.NOT_A_CODE) {
@ -1169,11 +1179,13 @@ public final class InputLogic {
// catch it and have their broken interface react. If you need the keyboard // catch it and have their broken interface react. If you need the keyboard
// to do this, you're doing it wrong -- please fix your app. // to do this, you're doing it wrong -- please fix your app.
mConnection.deleteSurroundingText(1, 0); mConnection.deleteSurroundingText(1, 0);
// TODO: Add a new StatsUtils method onBackspaceWhenNoText()
return; return;
} }
final int lengthToDelete = final int lengthToDelete =
Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1; Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
mConnection.deleteSurroundingText(lengthToDelete, 0); mConnection.deleteSurroundingText(lengthToDelete, 0);
int totalDeletedLength = lengthToDelete;
if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) { if (mDeleteCount > Constants.DELETE_ACCELERATE_AT) {
final int codePointBeforeCursorToDeleteAgain = final int codePointBeforeCursorToDeleteAgain =
mConnection.getCodePointBeforeCursor(); mConnection.getCodePointBeforeCursor();
@ -1181,8 +1193,10 @@ public final class InputLogic {
final int lengthToDeleteAgain = Character.isSupplementaryCodePoint( final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
codePointBeforeCursorToDeleteAgain) ? 2 : 1; codePointBeforeCursorToDeleteAgain) ? 2 : 1;
mConnection.deleteSurroundingText(lengthToDeleteAgain, 0); mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
totalDeletedLength += lengthToDeleteAgain;
} }
} }
StatsUtils.onBackspacePressed(totalDeletedLength);
} }
} }
if (inputTransaction.mSettingsValues if (inputTransaction.mSettingsValues