aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/voice/VoiceInput.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/voice/VoiceInput.java')
-rw-r--r--java/src/com/android/inputmethod/voice/VoiceInput.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/voice/VoiceInput.java b/java/src/com/android/inputmethod/voice/VoiceInput.java
index f24c180d0..d51d8694d 100644
--- a/java/src/com/android/inputmethod/voice/VoiceInput.java
+++ b/java/src/com/android/inputmethod/voice/VoiceInput.java
@@ -16,6 +16,7 @@
package com.android.inputmethod.voice;
+import com.android.inputmethod.latin.EditingUtil;
import com.android.inputmethod.latin.R;
import android.content.ContentResolver;
@@ -27,11 +28,12 @@ import android.os.Handler;
import android.os.Message;
import android.os.Parcelable;
import android.speech.RecognitionListener;
-import android.speech.SpeechRecognizer;
import android.speech.RecognizerIntent;
+import android.speech.SpeechRecognizer;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.inputmethod.InputConnection;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -84,6 +86,7 @@ public class VoiceInput implements OnClickListener {
private static final String ALTERNATES_BUNDLE = "alternates_bundle";
// This is copied from the VoiceSearch app.
+ @SuppressWarnings("unused")
private static final class AlternatesBundleKeys {
public static final String ALTERNATES = "alternates";
public static final String CONFIDENCE = "confidence";
@@ -403,6 +406,7 @@ public class VoiceInput implements OnClickListener {
/**
* Handle the cancel button.
*/
+ @Override
public void onClick(View view) {
switch(view.getId()) {
case R.id.button:
@@ -423,8 +427,14 @@ public class VoiceInput implements OnClickListener {
mLogger.textModifiedByTypingDeletion(length);
}
- public void logTextModifiedByChooseSuggestion(int length) {
- mLogger.textModifiedByChooseSuggestion(length);
+ public void logTextModifiedByChooseSuggestion(String suggestion, int index,
+ String wordSeparators, InputConnection ic) {
+ EditingUtil.Range range = new EditingUtil.Range();
+ String wordToBeReplaced = EditingUtil.getWordAtCursor(ic, wordSeparators, range);
+ // If we enable phrase-based alternatives, only send up the first word
+ // in suggestion and wordToBeReplaced.
+ mLogger.textModifiedByChooseSuggestion(suggestion.length(), wordToBeReplaced.length(),
+ index, wordToBeReplaced, suggestion);
}
public void logKeyboardWarningDialogShown() {
@@ -455,10 +465,6 @@ public class VoiceInput implements OnClickListener {
mLogger.voiceInputDelivered(length);
}
- public void logNBestChoose(int index) {
- mLogger.nBestChoose(index);
- }
-
public void logInputEnded() {
mLogger.inputEnded();
}
@@ -552,36 +558,43 @@ public class VoiceInput implements OnClickListener {
int mSpeechStart;
private boolean mEndpointed = false;
+ @Override
public void onReadyForSpeech(Bundle noiseParams) {
mRecognitionView.showListening();
}
+ @Override
public void onBeginningOfSpeech() {
mEndpointed = false;
mSpeechStart = mWaveBuffer.size();
}
+ @Override
public void onRmsChanged(float rmsdB) {
mRecognitionView.updateVoiceMeter(rmsdB);
}
+ @Override
public void onBufferReceived(byte[] buf) {
try {
mWaveBuffer.write(buf);
} catch (IOException e) {}
}
+ @Override
public void onEndOfSpeech() {
mEndpointed = true;
mState = WORKING;
mRecognitionView.showWorking(mWaveBuffer, mSpeechStart, mWaveBuffer.size());
}
+ @Override
public void onError(int errorType) {
mState = ERROR;
VoiceInput.this.onError(errorType, mEndpointed);
}
+ @Override
public void onResults(Bundle resultsBundle) {
List<String> results = resultsBundle
.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
@@ -634,10 +647,12 @@ public class VoiceInput implements OnClickListener {
mRecognitionView.finish();
}
+ @Override
public void onPartialResults(final Bundle partialResults) {
// currently - do nothing
}
+ @Override
public void onEvent(int eventType, Bundle params) {
// do nothing - reserved for events that might be added in the future
}