Merge "Renamed Proxy classes"

This commit is contained in:
satok 2011-03-24 21:01:34 -07:00 committed by Android (Google) Code Review
commit 5cbc984ce1
5 changed files with 66 additions and 66 deletions

View file

@ -68,8 +68,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class VoiceConnector implements VoiceInput.UiListener { public class VoiceProxy implements VoiceInput.UiListener {
private static final VoiceConnector sInstance = new VoiceConnector(); private static final VoiceProxy sInstance = new VoiceProxy();
public static final boolean VOICE_INSTALLED = true; public static final boolean VOICE_INSTALLED = true;
private static final boolean ENABLE_VOICE_BUTTON = true; private static final boolean ENABLE_VOICE_BUTTON = true;
@ -83,7 +83,7 @@ public class VoiceConnector implements VoiceInput.UiListener {
"has_used_voice_input_unsupported_locale"; "has_used_voice_input_unsupported_locale";
private static final int RECOGNITIONVIEW_HEIGHT_THRESHOLD_RATIO = 6; private static final int RECOGNITIONVIEW_HEIGHT_THRESHOLD_RATIO = 6;
private static final String TAG = VoiceConnector.class.getSimpleName(); private static final String TAG = VoiceProxy.class.getSimpleName();
private static final boolean DEBUG = LatinImeLogger.sDBG; private static final boolean DEBUG = LatinImeLogger.sDBG;
private boolean mAfterVoiceInput; private boolean mAfterVoiceInput;
@ -111,12 +111,12 @@ public class VoiceConnector implements VoiceInput.UiListener {
private final Map<String, List<CharSequence>> mWordToSuggestions = private final Map<String, List<CharSequence>> mWordToSuggestions =
new HashMap<String, List<CharSequence>>(); new HashMap<String, List<CharSequence>>();
public static VoiceConnector init(LatinIME context, SharedPreferences prefs, UIHandler h) { public static VoiceProxy init(LatinIME context, SharedPreferences prefs, UIHandler h) {
sInstance.initInternal(context, prefs, h); sInstance.initInternal(context, prefs, h);
return sInstance; return sInstance;
} }
public static VoiceConnector getInstance() { public static VoiceProxy getInstance() {
return sInstance; return sInstance;
} }
@ -139,7 +139,7 @@ public class VoiceConnector implements VoiceInput.UiListener {
} }
} }
private VoiceConnector() { private VoiceProxy() {
// Intentional empty constructor for singleton. // Intentional empty constructor for singleton.
} }
@ -691,7 +691,7 @@ public class VoiceConnector implements VoiceInput.UiListener {
public void onAttachedToWindow() { public void onAttachedToWindow() {
// After onAttachedToWindow, we can show the voice warning dialog. See startListening() // After onAttachedToWindow, we can show the voice warning dialog. See startListening()
// above. // above.
VoiceInputConnector.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher); VoiceInputWrapper.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher);
} }
public void onConfigurationChanged(Configuration configuration) { public void onConfigurationChanged(Configuration configuration) {
@ -743,11 +743,11 @@ public class VoiceConnector implements VoiceInput.UiListener {
Map<String, List<CharSequence>> alternatives; Map<String, List<CharSequence>> alternatives;
} }
public static class VoiceLoggerConnector { public static class VoiceLoggerWrapper {
private static final VoiceLoggerConnector sInstance = new VoiceLoggerConnector(); private static final VoiceLoggerWrapper sInstance = new VoiceLoggerWrapper();
private VoiceInputLogger mLogger; private VoiceInputLogger mLogger;
public static VoiceLoggerConnector getInstance(Context context) { public static VoiceLoggerWrapper getInstance(Context context) {
if (sInstance.mLogger == null) { if (sInstance.mLogger == null) {
// Not thread safe, but it's ok. // Not thread safe, but it's ok.
sInstance.mLogger = VoiceInputLogger.getLogger(context); sInstance.mLogger = VoiceInputLogger.getLogger(context);
@ -756,7 +756,7 @@ public class VoiceConnector implements VoiceInput.UiListener {
} }
// private for the singleton // private for the singleton
private VoiceLoggerConnector() { private VoiceLoggerWrapper() {
} }
public void settingsWarningDialogCancel() { public void settingsWarningDialogCancel() {
@ -784,20 +784,20 @@ public class VoiceConnector implements VoiceInput.UiListener {
} }
} }
public static class VoiceInputConnector { public static class VoiceInputWrapper {
private static final VoiceInputConnector sInstance = new VoiceInputConnector(); private static final VoiceInputWrapper sInstance = new VoiceInputWrapper();
private VoiceInput mVoiceInput; private VoiceInput mVoiceInput;
public static VoiceInputConnector getInstance() { public static VoiceInputWrapper getInstance() {
return sInstance; return sInstance;
} }
public void setVoiceInput(VoiceInput voiceInput, SubtypeSwitcher switcher) { public void setVoiceInput(VoiceInput voiceInput, SubtypeSwitcher switcher) {
if (mVoiceInput == null && voiceInput != null) { if (mVoiceInput == null && voiceInput != null) {
mVoiceInput = voiceInput; mVoiceInput = voiceInput;
} }
switcher.setVoiceInputConnector(this); switcher.setVoiceInputWrapper(this);
} }
private VoiceInputConnector() { private VoiceInputWrapper() {
} }
public void cancel() { public void cancel() {

View file

@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.Utils;
@ -264,6 +264,6 @@ public class LatinKeyboardView extends KeyboardView {
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
// Token is available from here. // Token is available from here.
VoiceConnector.getInstance().onAttachedToWindow(); VoiceProxy.getInstance().onAttachedToWindow();
} }
} }

View file

@ -19,7 +19,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodServiceCompatWrapper; import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardActionListener;
import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardSwitcher;
@ -154,7 +154,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private String mInputMethodId; private String mInputMethodId;
private KeyboardSwitcher mKeyboardSwitcher; private KeyboardSwitcher mKeyboardSwitcher;
private SubtypeSwitcher mSubtypeSwitcher; private SubtypeSwitcher mSubtypeSwitcher;
private VoiceConnector mVoiceConnector; private VoiceProxy mVoiceProxy;
private UserDictionary mUserDictionary; private UserDictionary mUserDictionary;
private UserBigramDictionary mUserBigramDictionary; private UserBigramDictionary mUserBigramDictionary;
@ -212,7 +212,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
/* package */ String mWordSeparators; /* package */ String mWordSeparators;
private String mSentenceSeparators; private String mSentenceSeparators;
private String mSuggestPuncs; private String mSuggestPuncs;
// TODO: Move this flag to VoiceIMEConnector // TODO: Move this flag to VoiceProxy
private boolean mConfigurationChanging; private boolean mConfigurationChanging;
// Object for reacting to adding/removing a dictionary pack. // Object for reacting to adding/removing a dictionary pack.
@ -282,7 +282,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
switcher.updateShiftState(); switcher.updateShiftState();
break; break;
case MSG_VOICE_RESULTS: case MSG_VOICE_RESULTS:
mVoiceConnector.handleVoiceResults(preferCapitalization() mVoiceProxy.handleVoiceResults(preferCapitalization()
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked())); || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
break; break;
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
@ -432,7 +432,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(mReceiver, filter); registerReceiver(mReceiver, filter);
mVoiceConnector = VoiceConnector.init(this, prefs, mHandler); mVoiceProxy = VoiceProxy.init(this, prefs, mHandler);
final IntentFilter packageFilter = new IntentFilter(); final IntentFilter packageFilter = new IntentFilter();
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
@ -492,7 +492,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
unregisterReceiver(mReceiver); unregisterReceiver(mReceiver);
unregisterReceiver(mDictionaryPackInstallReceiver); unregisterReceiver(mDictionaryPackInstallReceiver);
mVoiceConnector.destroy(); mVoiceProxy.destroy();
LatinImeLogger.commit(); LatinImeLogger.commit();
LatinImeLogger.onDestroy(); LatinImeLogger.onDestroy();
super.onDestroy(); super.onDestroy();
@ -513,7 +513,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mConfigurationChanging = true; mConfigurationChanging = true;
super.onConfigurationChanged(conf); super.onConfigurationChanged(conf);
mVoiceConnector.onConfigurationChanged(conf); mVoiceProxy.onConfigurationChanged(conf);
mConfigurationChanging = false; mConfigurationChanging = false;
} }
@ -559,7 +559,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Most such things we decide below in initializeInputAttributesAndGetMode, but we need to // Most such things we decide below in initializeInputAttributesAndGetMode, but we need to
// know now whether this is a password text field, because we need to know now whether we // know now whether this is a password text field, because we need to know now whether we
// want to enable the voice button. // want to enable the voice button.
final VoiceConnector voiceIme = mVoiceConnector; final VoiceProxy voiceIme = mVoiceProxy;
voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType) voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType)
|| Utils.isVisiblePasswordInputType(attribute.inputType)); || Utils.isVisiblePasswordInputType(attribute.inputType));
@ -691,7 +691,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
LatinImeLogger.commit(); LatinImeLogger.commit();
mKeyboardSwitcher.onAutoCorrectionStateChanged(false); mKeyboardSwitcher.onAutoCorrectionStateChanged(false);
mVoiceConnector.flushVoiceInputLogs(mConfigurationChanging); mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging);
KeyboardView inputView = mKeyboardSwitcher.getInputView(); KeyboardView inputView = mKeyboardSwitcher.getInputView();
if (inputView != null) inputView.closing(); if (inputView != null) inputView.closing();
@ -712,7 +712,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public void onUpdateExtractedText(int token, ExtractedText text) { public void onUpdateExtractedText(int token, ExtractedText text) {
super.onUpdateExtractedText(token, text); super.onUpdateExtractedText(token, text);
mVoiceConnector.showPunctuationHintIfNecessary(); mVoiceProxy.showPunctuationHintIfNecessary();
} }
@Override @Override
@ -733,7 +733,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
+ ", ce=" + candidatesEnd); + ", ce=" + candidatesEnd);
} }
mVoiceConnector.setCursorAndSelection(newSelEnd, newSelStart); mVoiceProxy.setCursorAndSelection(newSelEnd, newSelStart);
// If the current selection in the text view changes, we should // If the current selection in the text view changes, we should
// clear whatever candidate text we have. // clear whatever candidate text we have.
@ -741,7 +741,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|| newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart;
final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1;
if (((mComposing.length() > 0 && mHasValidSuggestions) if (((mComposing.length() > 0 && mHasValidSuggestions)
|| mVoiceConnector.isVoiceInputHighlighted()) || mVoiceProxy.isVoiceInputHighlighted())
&& (selectionChanged || candidatesCleared)) { && (selectionChanged || candidatesCleared)) {
if (candidatesCleared) { if (candidatesCleared) {
// If the composing span has been cleared, save the typed word in the history for // If the composing span has been cleared, save the typed word in the history for
@ -757,7 +757,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (ic != null) { if (ic != null) {
ic.finishComposingText(); ic.finishComposingText();
} }
mVoiceConnector.setVoiceInputHighlighted(false); mVoiceProxy.setVoiceInputHighlighted(false);
} else if (!mHasValidSuggestions && !mJustAccepted) { } else if (!mHasValidSuggestions && !mJustAccepted) {
if (TextEntryState.isAcceptedDefault() || TextEntryState.isSpaceAfterPicked()) { if (TextEntryState.isAcceptedDefault() || TextEntryState.isSpaceAfterPicked()) {
if (TextEntryState.isAcceptedDefault()) if (TextEntryState.isAcceptedDefault())
@ -837,7 +837,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mOptionsDialog.dismiss(); mOptionsDialog.dismiss();
mOptionsDialog = null; mOptionsDialog = null;
} }
mVoiceConnector.hideVoiceWindow(mConfigurationChanging); mVoiceProxy.hideVoiceWindow(mConfigurationChanging);
mWordHistory.clear(); mWordHistory.clear();
super.hideWindow(); super.hideWindow();
} }
@ -1188,7 +1188,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override @Override
public void onTextInput(CharSequence text) { public void onTextInput(CharSequence text) {
mVoiceConnector.commitVoiceInput(); mVoiceProxy.commitVoiceInput();
InputConnection ic = getCurrentInputConnection(); InputConnection ic = getCurrentInputConnection();
if (ic == null) return; if (ic == null) return;
abortRecorrection(false); abortRecorrection(false);
@ -1210,13 +1210,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
private void handleBackspace() { private void handleBackspace() {
if (mVoiceConnector.logAndRevertVoiceInput()) return; if (mVoiceProxy.logAndRevertVoiceInput()) return;
final InputConnection ic = getCurrentInputConnection(); final InputConnection ic = getCurrentInputConnection();
if (ic == null) return; if (ic == null) return;
ic.beginBatchEdit(); ic.beginBatchEdit();
mVoiceConnector.handleBackspace(); mVoiceProxy.handleBackspace();
boolean deleteChar = false; boolean deleteChar = false;
if (mHasValidSuggestions) { if (mHasValidSuggestions) {
@ -1300,7 +1300,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) { private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) {
mVoiceConnector.handleCharacter(); mVoiceProxy.handleCharacter();
if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isRecorrecting()) { if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isRecorrecting()) {
abortRecorrection(false); abortRecorrection(false);
@ -1360,7 +1360,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
private void handleSeparator(int primaryCode) { private void handleSeparator(int primaryCode) {
mVoiceConnector.handleSeparator(); mVoiceProxy.handleSeparator();
// Should dismiss the "Touch again to save" message when handling separator // Should dismiss the "Touch again to save" message when handling separator
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) { if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
@ -1430,7 +1430,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void handleClose() { private void handleClose() {
commitTyped(getCurrentInputConnection()); commitTyped(getCurrentInputConnection());
mVoiceConnector.handleClose(); mVoiceProxy.handleClose();
requestHideSelf(0); requestHideSelf(0);
LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
if (inputView != null) if (inputView != null)
@ -1503,7 +1503,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
public void setSuggestions(SuggestedWords words) { public void setSuggestions(SuggestedWords words) {
if (mVoiceConnector.getAndResetIsShowingHint()) { if (mVoiceProxy.getAndResetIsShowingHint()) {
setCandidatesView(mCandidateViewContainer); setCandidatesView(mCandidateViewContainer);
} }
@ -1519,7 +1519,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void updateSuggestions() { public void updateSuggestions() {
// Check if we have a suggestion engine attached. // Check if we have a suggestion engine attached.
if ((mSuggest == null || !isSuggestionsRequested()) if ((mSuggest == null || !isSuggestionsRequested())
&& !mVoiceConnector.isVoiceInputHighlighted()) { && !mVoiceProxy.isVoiceInputHighlighted()) {
return; return;
} }
@ -1614,7 +1614,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void pickSuggestionManually(int index, CharSequence suggestion) { public void pickSuggestionManually(int index, CharSequence suggestion) {
SuggestedWords suggestions = mCandidateView.getSuggestions(); SuggestedWords suggestions = mCandidateView.getSuggestions();
mVoiceConnector.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators); mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators);
final boolean recorrecting = TextEntryState.isRecorrecting(); final boolean recorrecting = TextEntryState.isRecorrecting();
InputConnection ic = getCurrentInputConnection(); InputConnection ic = getCurrentInputConnection();
@ -1718,7 +1718,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return; return;
InputConnection ic = getCurrentInputConnection(); InputConnection ic = getCurrentInputConnection();
if (ic != null) { if (ic != null) {
mVoiceConnector.rememberReplacedWord(suggestion, mWordSeparators); mVoiceProxy.rememberReplacedWord(suggestion, mWordSeparators);
ic.commitText(suggestion, 1); ic.commitText(suggestion, 1);
} }
saveWordInHistory(suggestion); saveWordInHistory(suggestion);
@ -1773,7 +1773,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
private void setOldSuggestions() { private void setOldSuggestions() {
mVoiceConnector.setShowingVoiceSuggestions(false); mVoiceProxy.setShowingVoiceSuggestions(false);
if (mCandidateView != null && mCandidateView.isShowingAddToDictionaryHint()) { if (mCandidateView != null && mCandidateView.isShowingAddToDictionaryHint()) {
return; return;
} }
@ -1787,7 +1787,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (touching != null && touching.mWord.length() > 1) { if (touching != null && touching.mWord.length() > 1) {
ic.beginBatchEdit(); ic.beginBatchEdit();
if (!mVoiceConnector.applyVoiceAlternatives(touching) if (!mVoiceProxy.applyVoiceAlternatives(touching)
&& !applyTypedAlternatives(touching)) { && !applyTypedAlternatives(touching)) {
abortRecorrection(true); abortRecorrection(true);
} else { } else {
@ -1945,8 +1945,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
// Reload keyboard because the current language has been changed. // Reload keyboard because the current language has been changed.
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(),
mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceConnector.isVoiceButtonEnabled(), mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceProxy.isVoiceButtonEnabled(),
mVoiceConnector.isVoiceButtonOnPrimary()); mVoiceProxy.isVoiceButtonOnPrimary());
initSuggest(); initSuggest();
mKeyboardSwitcher.updateShiftState(); mKeyboardSwitcher.updateShiftState();
} }
@ -2132,7 +2132,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs); mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs);
loadAndSetAutoCorrectionThreshold(prefs); loadAndSetAutoCorrectionThreshold(prefs);
mVoiceConnector.loadSettings(attribute, prefs); mVoiceProxy.loadSettings(attribute, prefs);
updateCorrectionMode(); updateCorrectionMode();
updateAutoTextEnabled(); updateAutoTextEnabled();

View file

@ -18,7 +18,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.CompatUtils;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.deprecated.VoiceProxy;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
@ -82,7 +82,7 @@ public class Settings extends PreferenceActivity
private AlertDialog mDialog; private AlertDialog mDialog;
private VoiceConnector.VoiceLoggerConnector mVoiceLogger; private VoiceProxy.VoiceLoggerWrapper mVoiceLogger;
private boolean mOkClicked = false; private boolean mOkClicked = false;
private String mVoiceModeOff; private String mVoiceModeOff;
@ -111,7 +111,7 @@ public class Settings extends PreferenceActivity
mVoiceModeOff = getString(R.string.voice_mode_off); mVoiceModeOff = getString(R.string.voice_mode_off);
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
.equals(mVoiceModeOff)); .equals(mVoiceModeOff));
mVoiceLogger = VoiceConnector.VoiceLoggerConnector.getInstance(this); mVoiceLogger = VoiceProxy.VoiceLoggerWrapper.getInstance(this);
mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD); mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS); mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS);
@ -184,7 +184,7 @@ public class Settings extends PreferenceActivity
((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY)) ((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY))
.removePreference(mQuickFixes); .removePreference(mQuickFixes);
} }
if (!VoiceConnector.VOICE_INSTALLED if (!VoiceProxy.VOICE_INSTALLED
|| !SpeechRecognizer.isRecognitionAvailable(this)) { || !SpeechRecognizer.isRecognitionAvailable(this)) {
getPreferenceScreen().removePreference(mVoicePreference); getPreferenceScreen().removePreference(mVoicePreference);
} else { } else {

View file

@ -18,7 +18,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper; import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.deprecated.VoiceConnector; import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.LatinKeyboard; import com.android.inputmethod.keyboard.LatinKeyboard;
@ -78,7 +78,7 @@ public class SubtypeSwitcher {
private Locale mSystemLocale; private Locale mSystemLocale;
private Locale mInputLocale; private Locale mInputLocale;
private String mInputLocaleStr; private String mInputLocaleStr;
private VoiceConnector.VoiceInputConnector mVoiceInputConnector; private VoiceProxy.VoiceInputWrapper mVoiceInputWrapper;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
private boolean mIsNetworkConnected; private boolean mIsNetworkConnected;
@ -113,7 +113,7 @@ public class SubtypeSwitcher {
mCurrentSubtype = null; mCurrentSubtype = null;
mAllEnabledSubtypesOfCurrentInputMethod = null; mAllEnabledSubtypesOfCurrentInputMethod = null;
// TODO: Voice input should be created here // TODO: Voice input should be created here
mVoiceInputConnector = null; mVoiceInputWrapper = null;
mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean( mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean(
R.bool.config_use_spacebar_language_switcher); R.bool.config_use_spacebar_language_switcher);
if (mConfigUseSpacebarLanguageSwitcher) if (mConfigUseSpacebarLanguageSwitcher)
@ -243,30 +243,30 @@ public class SubtypeSwitcher {
// We cancel its status when we change mode, while we reset otherwise. // We cancel its status when we change mode, while we reset otherwise.
if (isKeyboardMode()) { if (isKeyboardMode()) {
if (modeChanged) { if (modeChanged) {
if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != null) { if (VOICE_MODE.equals(oldMode) && mVoiceInputWrapper != null) {
mVoiceInputConnector.cancel(); mVoiceInputWrapper.cancel();
} }
} }
if (modeChanged || languageChanged) { if (modeChanged || languageChanged) {
updateShortcutIME(); updateShortcutIME();
mService.onRefreshKeyboard(); mService.onRefreshKeyboard();
} }
} else if (isVoiceMode() && mVoiceInputConnector != null) { } else if (isVoiceMode() && mVoiceInputWrapper != null) {
if (VOICE_MODE.equals(oldMode)) { if (VOICE_MODE.equals(oldMode)) {
mVoiceInputConnector.reset(); mVoiceInputWrapper.reset();
} }
// If needsToShowWarningDialog is true, voice input need to show warning before // If needsToShowWarningDialog is true, voice input need to show warning before
// show recognition view. // show recognition view.
if (languageChanged || modeChanged if (languageChanged || modeChanged
|| VoiceConnector.getInstance().needsToShowWarningDialog()) { || VoiceProxy.getInstance().needsToShowWarningDialog()) {
triggerVoiceIME(); triggerVoiceIME();
} }
} else { } else {
Log.w(TAG, "Unknown subtype mode: " + newMode); Log.w(TAG, "Unknown subtype mode: " + newMode);
if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != null) { if (VOICE_MODE.equals(oldMode) && mVoiceInputWrapper != null) {
// We need to reset the voice input to release the resources and to reset its status // We need to reset the voice input to release the resources and to reset its status
// as it is not the current input mode. // as it is not the current input mode.
mVoiceInputConnector.reset(); mVoiceInputWrapper.reset();
} }
} }
} }
@ -520,9 +520,9 @@ public class SubtypeSwitcher {
// Voice Input functions // // Voice Input functions //
/////////////////////////// ///////////////////////////
public boolean setVoiceInputConnector(VoiceConnector.VoiceInputConnector vi) { public boolean setVoiceInputWrapper(VoiceProxy.VoiceInputWrapper vi) {
if (mVoiceInputConnector == null && vi != null) { if (mVoiceInputWrapper == null && vi != null) {
mVoiceInputConnector = vi; mVoiceInputWrapper = vi;
if (isVoiceMode()) { if (isVoiceMode()) {
if (DBG) { if (DBG) {
Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr()); Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr());
@ -540,7 +540,7 @@ public class SubtypeSwitcher {
private void triggerVoiceIME() { private void triggerVoiceIME() {
if (!mService.isInputViewShown()) return; if (!mService.isInputViewShown()) return;
VoiceConnector.getInstance().startListening(false, VoiceProxy.getInstance().startListening(false,
KeyboardSwitcher.getInstance().getInputView().getWindowToken()); KeyboardSwitcher.getInstance().getInputView().getWindowToken());
} }
@ -631,7 +631,7 @@ public class SubtypeSwitcher {
// input. Because this method is called by onStartInputView, this should mean that as // input. Because this method is called by onStartInputView, this should mean that as
// long as the locale doesn't change while the user is keeping the IME open, the // long as the locale doesn't change while the user is keeping the IME open, the
// value should never be stale. // value should never be stale.
String supportedLocalesString = VoiceConnector.getSupportedLocalesString( String supportedLocalesString = VoiceProxy.getSupportedLocalesString(
mService.getContentResolver()); mService.getContentResolver());
List<String> voiceInputSupportedLocales = Arrays.asList( List<String> voiceInputSupportedLocales = Arrays.asList(
supportedLocalesString.split("\\s+")); supportedLocalesString.split("\\s+"));