Fix bug 2553592 API REVIEW: android.speech

Change 3 of 4
Notes from API Council review:
Rename RecognitionManager to SpeechRecognizer

Change-Id: Ieea0ade975b7c01f1fccb83a78a5b8f75e0c62de
main
Jean-Michel Trivi 2010-03-30 10:05:53 -07:00
parent 7f4f7b877a
commit 06933183c8
3 changed files with 19 additions and 19 deletions

View File

@ -39,7 +39,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.speech.RecognitionManager; import android.speech.SpeechRecognizer;
import android.text.AutoText; import android.text.AutoText;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.TextUtils; import android.text.TextUtils;
@ -1725,7 +1725,7 @@ public class LatinIME extends InputMethodService
return ENABLE_VOICE_BUTTON && fieldCanDoVoice(fieldContext) return ENABLE_VOICE_BUTTON && fieldCanDoVoice(fieldContext)
&& !(attribute != null && attribute.privateImeOptions != null && !(attribute != null && attribute.privateImeOptions != null
&& attribute.privateImeOptions.equals(IME_OPTION_NO_MICROPHONE)) && attribute.privateImeOptions.equals(IME_OPTION_NO_MICROPHONE))
&& RecognitionManager.isRecognitionAvailable(this); && SpeechRecognizer.isRecognitionAvailable(this);
} }
// receive ringer mode changes to detect silent mode // receive ringer mode changes to detect silent mode

View File

@ -31,7 +31,7 @@ import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.speech.RecognitionManager; import android.speech.SpeechRecognizer;
import android.text.AutoText; import android.text.AutoText;
import android.util.Log; import android.util.Log;
@ -88,7 +88,7 @@ public class LatinIMESettings extends PreferenceActivity
.removePreference(mQuickFixes); .removePreference(mQuickFixes);
} }
if (!LatinIME.VOICE_INSTALLED if (!LatinIME.VOICE_INSTALLED
|| !RecognitionManager.isRecognitionAvailable(this)) { || !SpeechRecognizer.isRecognitionAvailable(this)) {
getPreferenceScreen().removePreference(mVoicePreference); getPreferenceScreen().removePreference(mVoicePreference);
} else { } else {
updateVoiceModeSummary(); updateVoiceModeSummary();

View File

@ -26,7 +26,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.speech.RecognitionListener; import android.speech.RecognitionListener;
import android.speech.RecognitionManager; import android.speech.SpeechRecognizer;
import android.speech.RecognizerIntent; import android.speech.RecognizerIntent;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
@ -134,7 +134,7 @@ public class VoiceInput implements OnClickListener {
public void onCancelVoice(); public void onCancelVoice();
} }
private RecognitionManager mRecognitionManager; private SpeechRecognizer mSpeechRecognizer;
private RecognitionListener mRecognitionListener; private RecognitionListener mRecognitionListener;
private RecognitionView mRecognitionView; private RecognitionView mRecognitionView;
private UiListener mUiListener; private UiListener mUiListener;
@ -147,8 +147,8 @@ public class VoiceInput implements OnClickListener {
public VoiceInput(Context context, UiListener uiHandler) { public VoiceInput(Context context, UiListener uiHandler) {
mLogger = VoiceInputLogger.getLogger(context); mLogger = VoiceInputLogger.getLogger(context);
mRecognitionListener = new ImeRecognitionListener(); mRecognitionListener = new ImeRecognitionListener();
mRecognitionManager = RecognitionManager.createRecognitionManager(context); mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(context);
mRecognitionManager.setRecognitionListener(mRecognitionListener); mSpeechRecognizer.setRecognitionListener(mRecognitionListener);
mUiListener = uiHandler; mUiListener = uiHandler;
mContext = context; mContext = context;
newView(); newView();
@ -334,7 +334,7 @@ public class VoiceInput implements OnClickListener {
EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS, EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS,
null /* rely on endpointer default */); null /* rely on endpointer default */);
mRecognitionManager.startListening(intent); mSpeechRecognizer.startListening(intent);
} }
/** /**
@ -357,7 +357,7 @@ public class VoiceInput implements OnClickListener {
} }
public void destroy() { public void destroy() {
mRecognitionManager.destroy(); mSpeechRecognizer.destroy();
} }
/** /**
@ -484,7 +484,7 @@ public class VoiceInput implements OnClickListener {
// Remove all pending tasks (e.g., timers to cancel voice input) // Remove all pending tasks (e.g., timers to cancel voice input)
mHandler.removeMessages(MSG_CLOSE_ERROR_DIALOG); mHandler.removeMessages(MSG_CLOSE_ERROR_DIALOG);
mRecognitionManager.cancel(); mSpeechRecognizer.cancel();
mUiListener.onCancelVoice(); mUiListener.onCancelVoice();
mRecognitionView.finish(); mRecognitionView.finish();
} }
@ -492,20 +492,20 @@ public class VoiceInput implements OnClickListener {
private int getErrorStringId(int errorType, boolean endpointed) { private int getErrorStringId(int errorType, boolean endpointed) {
switch (errorType) { switch (errorType) {
// We use CLIENT_ERROR to signify that voice search is not available on the device. // We use CLIENT_ERROR to signify that voice search is not available on the device.
case RecognitionManager.ERROR_CLIENT: case SpeechRecognizer.ERROR_CLIENT:
return R.string.voice_not_installed; return R.string.voice_not_installed;
case RecognitionManager.ERROR_NETWORK: case SpeechRecognizer.ERROR_NETWORK:
return R.string.voice_network_error; return R.string.voice_network_error;
case RecognitionManager.ERROR_NETWORK_TIMEOUT: case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
return endpointed ? return endpointed ?
R.string.voice_network_error : R.string.voice_too_much_speech; R.string.voice_network_error : R.string.voice_too_much_speech;
case RecognitionManager.ERROR_AUDIO: case SpeechRecognizer.ERROR_AUDIO:
return R.string.voice_audio_error; return R.string.voice_audio_error;
case RecognitionManager.ERROR_SERVER: case SpeechRecognizer.ERROR_SERVER:
return R.string.voice_server_error; return R.string.voice_server_error;
case RecognitionManager.ERROR_SPEECH_TIMEOUT: case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
return R.string.voice_speech_timeout; return R.string.voice_speech_timeout;
case RecognitionManager.ERROR_NO_MATCH: case SpeechRecognizer.ERROR_NO_MATCH:
return R.string.voice_no_match; return R.string.voice_no_match;
default: return R.string.voice_error; default: return R.string.voice_error;
} }
@ -562,7 +562,7 @@ public class VoiceInput implements OnClickListener {
public void onResults(Bundle resultsBundle) { public void onResults(Bundle resultsBundle) {
List<String> results = resultsBundle List<String> results = resultsBundle
.getStringArrayList(RecognitionManager.RESULTS_RECOGNITION); .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
mState = DEFAULT; mState = DEFAULT;
final Map<String, List<CharSequence>> alternatives = final Map<String, List<CharSequence>> alternatives =