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/voice | |
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/voice')
-rw-r--r-- | java/src/com/android/inputmethod/voice/VoiceInput.java | 107 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/voice/VoiceInputLogger.java | 39 |
2 files changed, 138 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/voice/VoiceInput.java b/java/src/com/android/inputmethod/voice/VoiceInput.java index e881856dd..72cb2f902 100644 --- a/java/src/com/android/inputmethod/voice/VoiceInput.java +++ b/java/src/com/android/inputmethod/voice/VoiceInput.java @@ -94,6 +94,12 @@ public class VoiceInput implements OnClickListener { public static final int WORKING = 2; public static final int ERROR = 3; + private int mAfterVoiceInputDeleteCount = 0; + private int mAfterVoiceInputInsertCount = 0; + private int mAfterVoiceInputInsertPunctuationCount = 0; + private int mAfterVoiceInputCursorPos = 0; + private int mAfterVoiceInputSelectionSpan = 0; + private int mState = DEFAULT; private final static int MSG_CLOSE_ERROR_DIALOG = 1; @@ -161,6 +167,87 @@ public class VoiceInput implements OnClickListener { mBlacklist.addApp("com.android.setupwizard"); } + public void setCursorPos(int pos) { + mAfterVoiceInputCursorPos = pos; + } + + public int getCursorPos() { + return mAfterVoiceInputCursorPos; + } + + public void setSelectionSpan(int span) { + mAfterVoiceInputSelectionSpan = span; + } + + public int getSelectionSpan() { + return mAfterVoiceInputSelectionSpan; + } + + public void incrementTextModificationDeleteCount(int count){ + mAfterVoiceInputDeleteCount += count; + // Send up intents for other text modification types + if (mAfterVoiceInputInsertCount > 0) { + logTextModifiedByTypingInsertion(mAfterVoiceInputInsertCount); + mAfterVoiceInputInsertCount = 0; + } + if (mAfterVoiceInputInsertPunctuationCount > 0) { + logTextModifiedByTypingInsertionPunctuation(mAfterVoiceInputInsertPunctuationCount); + mAfterVoiceInputInsertPunctuationCount = 0; + } + + } + + public void incrementTextModificationInsertCount(int count){ + mAfterVoiceInputInsertCount += count; + if (mAfterVoiceInputSelectionSpan > 0) { + // If text was highlighted before inserting the char, count this as + // a delete. + mAfterVoiceInputDeleteCount += mAfterVoiceInputSelectionSpan; + } + // Send up intents for other text modification types + if (mAfterVoiceInputDeleteCount > 0) { + logTextModifiedByTypingDeletion(mAfterVoiceInputDeleteCount); + mAfterVoiceInputDeleteCount = 0; + } + if (mAfterVoiceInputInsertPunctuationCount > 0) { + logTextModifiedByTypingInsertionPunctuation(mAfterVoiceInputInsertPunctuationCount); + mAfterVoiceInputInsertPunctuationCount = 0; + } + } + + public void incrementTextModificationInsertPunctuationCount(int count){ + mAfterVoiceInputInsertPunctuationCount += 1; + if (mAfterVoiceInputSelectionSpan > 0) { + // If text was highlighted before inserting the char, count this as + // a delete. + mAfterVoiceInputDeleteCount += mAfterVoiceInputSelectionSpan; + } + // Send up intents for aggregated non-punctuation insertions + if (mAfterVoiceInputDeleteCount > 0) { + logTextModifiedByTypingDeletion(mAfterVoiceInputDeleteCount); + mAfterVoiceInputDeleteCount = 0; + } + if (mAfterVoiceInputInsertCount > 0) { + logTextModifiedByTypingInsertion(mAfterVoiceInputInsertCount); + mAfterVoiceInputInsertCount = 0; + } + } + + public void flushAllTextModificationCounters() { + if (mAfterVoiceInputInsertCount > 0) { + logTextModifiedByTypingInsertion(mAfterVoiceInputInsertCount); + mAfterVoiceInputInsertCount = 0; + } + if (mAfterVoiceInputDeleteCount > 0) { + logTextModifiedByTypingDeletion(mAfterVoiceInputDeleteCount); + mAfterVoiceInputDeleteCount = 0; + } + if (mAfterVoiceInputInsertPunctuationCount > 0) { + logTextModifiedByTypingInsertionPunctuation(mAfterVoiceInputInsertPunctuationCount); + mAfterVoiceInputInsertPunctuationCount = 0; + } + } + /** * The configuration of the IME changed and may have caused the views to be layed out * again. Restore the state of the recognition view. @@ -302,8 +389,20 @@ public class VoiceInput implements OnClickListener { } } - public void logTextModified() { - mLogger.textModified(); + public void logTextModifiedByTypingInsertion(int length) { + mLogger.textModifiedByTypingInsertion(length); + } + + public void logTextModifiedByTypingInsertionPunctuation(int length) { + mLogger.textModifiedByTypingInsertionPunctuation(length); + } + + public void logTextModifiedByTypingDeletion(int length) { + mLogger.textModifiedByTypingDeletion(length); + } + + public void logTextModifiedByChooseSuggestion(int length) { + mLogger.textModifiedByChooseSuggestion(length); } public void logKeyboardWarningDialogShown() { @@ -330,8 +429,8 @@ public class VoiceInput implements OnClickListener { mLogger.punctuationHintDisplayed(); } - public void logVoiceInputDelivered() { - mLogger.voiceInputDelivered(); + public void logVoiceInputDelivered(int length) { + mLogger.voiceInputDelivered(length); } public void logNBestChoose(int index) { diff --git a/java/src/com/android/inputmethod/voice/VoiceInputLogger.java b/java/src/com/android/inputmethod/voice/VoiceInputLogger.java index 659033340..9d3a92037 100644 --- a/java/src/com/android/inputmethod/voice/VoiceInputLogger.java +++ b/java/src/com/android/inputmethod/voice/VoiceInputLogger.java @@ -147,12 +147,43 @@ public class VoiceInputLogger { mContext.sendBroadcast(i); } - public void voiceInputDelivered() { - mContext.sendBroadcast(newLoggingBroadcast(LoggingEvents.VoiceIme.VOICE_INPUT_DELIVERED)); + public void voiceInputDelivered(int length) { + Intent i = newLoggingBroadcast(LoggingEvents.VoiceIme.VOICE_INPUT_DELIVERED); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_LENGTH, length); + mContext.sendBroadcast(i); + } + + public void textModifiedByTypingInsertion(int length) { + Intent i = newLoggingBroadcast(LoggingEvents.VoiceIme.TEXT_MODIFIED); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_LENGTH, length); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_TYPE, + LoggingEvents.VoiceIme.TEXT_MODIFIED_TYPE_TYPING_INSERTION); + mContext.sendBroadcast(i); + } + + public void textModifiedByTypingInsertionPunctuation(int length) { + Intent i = newLoggingBroadcast(LoggingEvents.VoiceIme.TEXT_MODIFIED); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_LENGTH, length); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_TYPE, + LoggingEvents.VoiceIme.TEXT_MODIFIED_TYPE_TYPING_INSERTION_PUNCTUATION); + mContext.sendBroadcast(i); + } + + public void textModifiedByTypingDeletion(int length) { + Intent i = newLoggingBroadcast(LoggingEvents.VoiceIme.TEXT_MODIFIED); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_LENGTH, length); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_TYPE, + LoggingEvents.VoiceIme.TEXT_MODIFIED_TYPE_TYPING_DELETION); + + mContext.sendBroadcast(i); } - public void textModified() { - mContext.sendBroadcast(newLoggingBroadcast(LoggingEvents.VoiceIme.TEXT_MODIFIED)); + public void textModifiedByChooseSuggestion(int length) { + Intent i = newLoggingBroadcast(LoggingEvents.VoiceIme.TEXT_MODIFIED); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_LENGTH, length); + i.putExtra(LoggingEvents.VoiceIme.EXTRA_TEXT_MODIFIED_TYPE, + LoggingEvents.VoiceIme.TEXT_MODIFIED_TYPE_CHOOSE_SUGGESTION); + mContext.sendBroadcast(i); } public void nBestChoose(int index) { |