diff options
author | 2010-03-04 09:34:21 -0500 | |
---|---|---|
committer | 2010-03-15 12:18:08 -0400 | |
commit | 4f1f2201bdd0e63a19e686caa3d17b16eb134f5e (patch) | |
tree | e6fdf45c6430741859b6ead515854a6ed95ec740 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | 6c2f9f5ba7afedc183086d4ee3a7aa50b3866edc (diff) | |
download | latinime-4f1f2201bdd0e63a19e686caa3d17b16eb134f5e.tar.gz latinime-4f1f2201bdd0e63a19e686caa3d17b16eb134f5e.tar.xz latinime-4f1f2201bdd0e63a19e686caa3d17b16eb134f5e.zip |
Fixes the over-logging of TextModified
We were overlogging the TextMoified action because the old
implementation would log a cursor change as a text
modification. This CL logs 4 specific actions (choose
suggestion, delete text, insert text, insert punctuation)
as a text modification rather than any action in the textbox
I also add in logging of the length of the recognition result
so that we can get some more context around the scope of the
editing of the ime result.
Change-Id: I172df24ddc0a7b62bcc5ed806fd70ef7e1c42310
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index ffa7b0a4b..70d49f564 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -234,6 +234,7 @@ public class LatinIME extends InputMethodService List<String> candidates; Map<String, List<CharSequence>> alternatives; } + private boolean mRefreshKeyboardRequired; Handler mHandler = new Handler() { @@ -552,6 +553,7 @@ public class LatinIME extends InputMethodService if (VOICE_INSTALLED && !mConfigurationChanging) { if (mAfterVoiceInput) { + mVoiceInput.flushAllTextModificationCounters(); mVoiceInput.logInputEnded(); } mVoiceInput.flushLogs(); @@ -567,8 +569,6 @@ public class LatinIME extends InputMethodService super.onUpdateExtractedText(token, text); InputConnection ic = getCurrentInputConnection(); if (!mImmediatelyAfterVoiceInput && mAfterVoiceInput && ic != null) { - mVoiceInput.logTextModified(); - if (mHints.showPunctuationHintIfNecessary(ic)) { mVoiceInput.logPunctuationHintDisplayed(); } @@ -592,6 +592,11 @@ public class LatinIME extends InputMethodService + ", ce=" + candidatesEnd); } + if (mAfterVoiceInput) { + mVoiceInput.setCursorPos(newSelEnd); + mVoiceInput.setSelectionSpan(newSelEnd - newSelStart); + } + mSuggestionShouldReplaceCurrentWord = false; // If the current selection in the text view changes, we should // clear whatever candidate text we have. @@ -997,12 +1002,27 @@ public class LatinIME extends InputMethodService private void handleBackspace() { if (VOICE_INSTALLED && mVoiceInputHighlighted) { + mVoiceInput.incrementTextModificationDeleteCount( + mVoiceResults.candidates.get(0).toString().length()); revertVoiceInput(); return; } boolean deleteChar = false; InputConnection ic = getCurrentInputConnection(); if (ic == null) return; + + if (mAfterVoiceInput) { + // Don't log delete if the user is pressing delete at + // the beginning of the text box (hence not deleting anything) + if (mVoiceInput.getCursorPos() > 0) { + // If anything was selected before the delete was pressed, increment the + // delete count by the length of the selection + int deleteLen = mVoiceInput.getSelectionSpan() > 0 ? + mVoiceInput.getSelectionSpan() : 1; + mVoiceInput.incrementTextModificationDeleteCount(deleteLen); + } + } + if (mPredicting) { final int length = mComposing.length(); if (length > 0) { @@ -1048,6 +1068,12 @@ public class LatinIME extends InputMethodService if (VOICE_INSTALLED && mVoiceInputHighlighted) { commitVoiceInput(); } + + if (mAfterVoiceInput) { + // Assume input length is 1. This assumption fails for smiley face insertions. + mVoiceInput.incrementTextModificationInsertCount(1); + } + if (isAlphabet(primaryCode) && isPredictionOn() && !isCursorTouchingWord()) { if (!mPredicting) { mPredicting = true; @@ -1091,6 +1117,12 @@ public class LatinIME extends InputMethodService if (VOICE_INSTALLED && mVoiceInputHighlighted) { commitVoiceInput(); } + + if (mAfterVoiceInput){ + // Assume input length is 1. This assumption fails for smiley face insertions. + mVoiceInput.incrementTextModificationInsertPunctuationCount(1); + } + boolean pickedDefault = false; // Handle separator InputConnection ic = getCurrentInputConnection(); @@ -1344,7 +1376,7 @@ public class LatinIME extends InputMethodService String bestResult = nBest.get(0).toString(); - mVoiceInput.logVoiceInputDelivered(); + mVoiceInput.logVoiceInputDelivered(bestResult.length()); mHints.registerVoiceResult(bestResult); @@ -1448,6 +1480,12 @@ public class LatinIME extends InputMethodService public void pickSuggestionManually(int index, CharSequence suggestion) { if (mAfterVoiceInput && mShowingVoiceSuggestions) mVoiceInput.logNBestChoose(index); + if (mAfterVoiceInput && !mShowingVoiceSuggestions) { + mVoiceInput.flushAllTextModificationCounters(); + // send this intent AFTER logging any prior aggregated edits. + mVoiceInput.logTextModifiedByChooseSuggestion(suggestion.length()); + } + InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.beginBatchEdit(); |