aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/voice/VoiceInput.java
diff options
context:
space:
mode:
authorMaryam Garrett <mkamvar@google.com>2010-03-04 09:34:21 -0500
committerMaryam Garrett <mkamvar@google.com>2010-03-15 12:18:08 -0400
commit4f1f2201bdd0e63a19e686caa3d17b16eb134f5e (patch)
treee6fdf45c6430741859b6ead515854a6ed95ec740 /java/src/com/android/inputmethod/voice/VoiceInput.java
parent6c2f9f5ba7afedc183086d4ee3a7aa50b3866edc (diff)
downloadlatinime-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/VoiceInput.java')
-rw-r--r--java/src/com/android/inputmethod/voice/VoiceInput.java107
1 files changed, 103 insertions, 4 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) {