Loading java/src/com/android/inputmethod/deprecated/VoiceConnector.java→java/src/com/android/inputmethod/deprecated/VoiceProxy.java +16 −16 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; public class VoiceConnector implements VoiceInput.UiListener { private static final VoiceConnector sInstance = new VoiceConnector(); public class VoiceProxy implements VoiceInput.UiListener { private static final VoiceProxy sInstance = new VoiceProxy(); public static final boolean VOICE_INSTALLED = true; private static final boolean ENABLE_VOICE_BUTTON = true; Loading @@ -83,7 +83,7 @@ public class VoiceConnector implements VoiceInput.UiListener { "has_used_voice_input_unsupported_locale"; 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 boolean mAfterVoiceInput; Loading Loading @@ -111,12 +111,12 @@ public class VoiceConnector implements VoiceInput.UiListener { private final Map<String, List<CharSequence>> mWordToSuggestions = 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); return sInstance; } public static VoiceConnector getInstance() { public static VoiceProxy getInstance() { return sInstance; } Loading @@ -139,7 +139,7 @@ public class VoiceConnector implements VoiceInput.UiListener { } } private VoiceConnector() { private VoiceProxy() { // Intentional empty constructor for singleton. } Loading Loading @@ -691,7 +691,7 @@ public class VoiceConnector implements VoiceInput.UiListener { public void onAttachedToWindow() { // After onAttachedToWindow, we can show the voice warning dialog. See startListening() // above. VoiceInputConnector.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher); VoiceInputWrapper.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher); } public void onConfigurationChanged(Configuration configuration) { Loading Loading @@ -743,11 +743,11 @@ public class VoiceConnector implements VoiceInput.UiListener { Map<String, List<CharSequence>> alternatives; } public static class VoiceLoggerConnector { private static final VoiceLoggerConnector sInstance = new VoiceLoggerConnector(); public static class VoiceLoggerWrapper { private static final VoiceLoggerWrapper sInstance = new VoiceLoggerWrapper(); private VoiceInputLogger mLogger; public static VoiceLoggerConnector getInstance(Context context) { public static VoiceLoggerWrapper getInstance(Context context) { if (sInstance.mLogger == null) { // Not thread safe, but it's ok. sInstance.mLogger = VoiceInputLogger.getLogger(context); Loading @@ -756,7 +756,7 @@ public class VoiceConnector implements VoiceInput.UiListener { } // private for the singleton private VoiceLoggerConnector() { private VoiceLoggerWrapper() { } public void settingsWarningDialogCancel() { Loading Loading @@ -784,20 +784,20 @@ public class VoiceConnector implements VoiceInput.UiListener { } } public static class VoiceInputConnector { private static final VoiceInputConnector sInstance = new VoiceInputConnector(); public static class VoiceInputWrapper { private static final VoiceInputWrapper sInstance = new VoiceInputWrapper(); private VoiceInput mVoiceInput; public static VoiceInputConnector getInstance() { public static VoiceInputWrapper getInstance() { return sInstance; } public void setVoiceInput(VoiceInput voiceInput, SubtypeSwitcher switcher) { if (mVoiceInput == null && voiceInput != null) { mVoiceInput = voiceInput; } switcher.setVoiceInputConnector(this); switcher.setVoiceInputWrapper(this); } private VoiceInputConnector() { private VoiceInputWrapper() { } public void cancel() { Loading java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +2 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ 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.Utils; Loading Loading @@ -264,6 +264,6 @@ public class LatinKeyboardView extends KeyboardView { @Override protected void onAttachedToWindow() { // Token is available from here. VoiceConnector.getInstance().onAttachedToWindow(); VoiceProxy.getInstance().onAttachedToWindow(); } } java/src/com/android/inputmethod/latin/LatinIME.java +29 −29 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; 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.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardSwitcher; Loading Loading @@ -154,7 +154,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private String mInputMethodId; private KeyboardSwitcher mKeyboardSwitcher; private SubtypeSwitcher mSubtypeSwitcher; private VoiceConnector mVoiceConnector; private VoiceProxy mVoiceProxy; private UserDictionary mUserDictionary; private UserBigramDictionary mUserBigramDictionary; Loading Loading @@ -212,7 +212,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar /* package */ String mWordSeparators; private String mSentenceSeparators; private String mSuggestPuncs; // TODO: Move this flag to VoiceIMEConnector // TODO: Move this flag to VoiceProxy private boolean mConfigurationChanging; // Object for reacting to adding/removing a dictionary pack. Loading Loading @@ -282,7 +282,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar switcher.updateShiftState(); break; case MSG_VOICE_RESULTS: mVoiceConnector.handleVoiceResults(preferCapitalization() mVoiceProxy.handleVoiceResults(preferCapitalization() || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked())); break; case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: Loading Loading @@ -432,7 +432,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mReceiver, filter); mVoiceConnector = VoiceConnector.init(this, prefs, mHandler); mVoiceProxy = VoiceProxy.init(this, prefs, mHandler); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); Loading Loading @@ -492,7 +492,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } unregisterReceiver(mReceiver); unregisterReceiver(mDictionaryPackInstallReceiver); mVoiceConnector.destroy(); mVoiceProxy.destroy(); LatinImeLogger.commit(); LatinImeLogger.onDestroy(); super.onDestroy(); Loading @@ -513,7 +513,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mConfigurationChanging = true; super.onConfigurationChanged(conf); mVoiceConnector.onConfigurationChanged(conf); mVoiceProxy.onConfigurationChanged(conf); mConfigurationChanging = false; } Loading Loading @@ -559,7 +559,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // 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 // want to enable the voice button. final VoiceConnector voiceIme = mVoiceConnector; final VoiceProxy voiceIme = mVoiceProxy; voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType) || Utils.isVisiblePasswordInputType(attribute.inputType)); Loading Loading @@ -691,7 +691,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar LatinImeLogger.commit(); mKeyboardSwitcher.onAutoCorrectionStateChanged(false); mVoiceConnector.flushVoiceInputLogs(mConfigurationChanging); mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging); KeyboardView inputView = mKeyboardSwitcher.getInputView(); if (inputView != null) inputView.closing(); Loading @@ -712,7 +712,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void onUpdateExtractedText(int token, ExtractedText text) { super.onUpdateExtractedText(token, text); mVoiceConnector.showPunctuationHintIfNecessary(); mVoiceProxy.showPunctuationHintIfNecessary(); } @Override Loading @@ -733,7 +733,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar + ", ce=" + candidatesEnd); } mVoiceConnector.setCursorAndSelection(newSelEnd, newSelStart); mVoiceProxy.setCursorAndSelection(newSelEnd, newSelStart); // If the current selection in the text view changes, we should // clear whatever candidate text we have. Loading @@ -741,7 +741,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; if (((mComposing.length() > 0 && mHasValidSuggestions) || mVoiceConnector.isVoiceInputHighlighted()) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || candidatesCleared)) { if (candidatesCleared) { // If the composing span has been cleared, save the typed word in the history for Loading @@ -757,7 +757,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (ic != null) { ic.finishComposingText(); } mVoiceConnector.setVoiceInputHighlighted(false); mVoiceProxy.setVoiceInputHighlighted(false); } else if (!mHasValidSuggestions && !mJustAccepted) { if (TextEntryState.isAcceptedDefault() || TextEntryState.isSpaceAfterPicked()) { if (TextEntryState.isAcceptedDefault()) Loading Loading @@ -837,7 +837,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mOptionsDialog.dismiss(); mOptionsDialog = null; } mVoiceConnector.hideVoiceWindow(mConfigurationChanging); mVoiceProxy.hideVoiceWindow(mConfigurationChanging); mWordHistory.clear(); super.hideWindow(); } Loading Loading @@ -1188,7 +1188,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void onTextInput(CharSequence text) { mVoiceConnector.commitVoiceInput(); mVoiceProxy.commitVoiceInput(); InputConnection ic = getCurrentInputConnection(); if (ic == null) return; abortRecorrection(false); Loading @@ -1210,13 +1210,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleBackspace() { if (mVoiceConnector.logAndRevertVoiceInput()) return; if (mVoiceProxy.logAndRevertVoiceInput()) return; final InputConnection ic = getCurrentInputConnection(); if (ic == null) return; ic.beginBatchEdit(); mVoiceConnector.handleBackspace(); mVoiceProxy.handleBackspace(); boolean deleteChar = false; if (mHasValidSuggestions) { Loading Loading @@ -1300,7 +1300,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) { mVoiceConnector.handleCharacter(); mVoiceProxy.handleCharacter(); if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isRecorrecting()) { abortRecorrection(false); Loading Loading @@ -1360,7 +1360,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleSeparator(int primaryCode) { mVoiceConnector.handleSeparator(); mVoiceProxy.handleSeparator(); // Should dismiss the "Touch again to save" message when handling separator if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) { Loading Loading @@ -1430,7 +1430,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void handleClose() { commitTyped(getCurrentInputConnection()); mVoiceConnector.handleClose(); mVoiceProxy.handleClose(); requestHideSelf(0); LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); if (inputView != null) Loading Loading @@ -1503,7 +1503,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } public void setSuggestions(SuggestedWords words) { if (mVoiceConnector.getAndResetIsShowingHint()) { if (mVoiceProxy.getAndResetIsShowingHint()) { setCandidatesView(mCandidateViewContainer); } Loading @@ -1519,7 +1519,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void updateSuggestions() { // Check if we have a suggestion engine attached. if ((mSuggest == null || !isSuggestionsRequested()) && !mVoiceConnector.isVoiceInputHighlighted()) { && !mVoiceProxy.isVoiceInputHighlighted()) { return; } Loading Loading @@ -1614,7 +1614,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void pickSuggestionManually(int index, CharSequence suggestion) { SuggestedWords suggestions = mCandidateView.getSuggestions(); mVoiceConnector.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators); mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators); final boolean recorrecting = TextEntryState.isRecorrecting(); InputConnection ic = getCurrentInputConnection(); Loading Loading @@ -1718,7 +1718,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; InputConnection ic = getCurrentInputConnection(); if (ic != null) { mVoiceConnector.rememberReplacedWord(suggestion, mWordSeparators); mVoiceProxy.rememberReplacedWord(suggestion, mWordSeparators); ic.commitText(suggestion, 1); } saveWordInHistory(suggestion); Loading Loading @@ -1773,7 +1773,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void setOldSuggestions() { mVoiceConnector.setShowingVoiceSuggestions(false); mVoiceProxy.setShowingVoiceSuggestions(false); if (mCandidateView != null && mCandidateView.isShowingAddToDictionaryHint()) { return; } Loading @@ -1787,7 +1787,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (touching != null && touching.mWord.length() > 1) { ic.beginBatchEdit(); if (!mVoiceConnector.applyVoiceAlternatives(touching) if (!mVoiceProxy.applyVoiceAlternatives(touching) && !applyTypedAlternatives(touching)) { abortRecorrection(true); } else { Loading Loading @@ -1945,8 +1945,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } // Reload keyboard because the current language has been changed. mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceConnector.isVoiceButtonEnabled(), mVoiceConnector.isVoiceButtonOnPrimary()); mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceProxy.isVoiceButtonEnabled(), mVoiceProxy.isVoiceButtonOnPrimary()); initSuggest(); mKeyboardSwitcher.updateShiftState(); } Loading Loading @@ -2132,7 +2132,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs); loadAndSetAutoCorrectionThreshold(prefs); mVoiceConnector.loadSettings(attribute, prefs); mVoiceProxy.loadSettings(attribute, prefs); updateCorrectionMode(); updateAutoTextEnabled(); Loading java/src/com/android/inputmethod/latin/Settings.java +4 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; 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.Dialog; Loading Loading @@ -82,7 +82,7 @@ public class Settings extends PreferenceActivity private AlertDialog mDialog; private VoiceConnector.VoiceLoggerConnector mVoiceLogger; private VoiceProxy.VoiceLoggerWrapper mVoiceLogger; private boolean mOkClicked = false; private String mVoiceModeOff; Loading Loading @@ -111,7 +111,7 @@ public class Settings extends PreferenceActivity mVoiceModeOff = getString(R.string.voice_mode_off); mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) .equals(mVoiceModeOff)); mVoiceLogger = VoiceConnector.VoiceLoggerConnector.getInstance(this); mVoiceLogger = VoiceProxy.VoiceLoggerWrapper.getInstance(this); mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD); mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS); Loading Loading @@ -184,7 +184,7 @@ public class Settings extends PreferenceActivity ((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY)) .removePreference(mQuickFixes); } if (!VoiceConnector.VOICE_INSTALLED if (!VoiceProxy.VOICE_INSTALLED || !SpeechRecognizer.isRecognitionAvailable(this)) { getPreferenceScreen().removePreference(mVoicePreference); } else { Loading java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +15 −15 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; 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.LatinKeyboard; Loading Loading @@ -78,7 +78,7 @@ public class SubtypeSwitcher { private Locale mSystemLocale; private Locale mInputLocale; private String mInputLocaleStr; private VoiceConnector.VoiceInputConnector mVoiceInputConnector; private VoiceProxy.VoiceInputWrapper mVoiceInputWrapper; /*-----------------------------------------------------------*/ private boolean mIsNetworkConnected; Loading Loading @@ -113,7 +113,7 @@ public class SubtypeSwitcher { mCurrentSubtype = null; mAllEnabledSubtypesOfCurrentInputMethod = null; // TODO: Voice input should be created here mVoiceInputConnector = null; mVoiceInputWrapper = null; mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean( R.bool.config_use_spacebar_language_switcher); if (mConfigUseSpacebarLanguageSwitcher) Loading Loading @@ -243,30 +243,30 @@ public class SubtypeSwitcher { // We cancel its status when we change mode, while we reset otherwise. if (isKeyboardMode()) { if (modeChanged) { if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != null) { mVoiceInputConnector.cancel(); if (VOICE_MODE.equals(oldMode) && mVoiceInputWrapper != null) { mVoiceInputWrapper.cancel(); } } if (modeChanged || languageChanged) { updateShortcutIME(); mService.onRefreshKeyboard(); } } else if (isVoiceMode() && mVoiceInputConnector != null) { } else if (isVoiceMode() && mVoiceInputWrapper != null) { if (VOICE_MODE.equals(oldMode)) { mVoiceInputConnector.reset(); mVoiceInputWrapper.reset(); } // If needsToShowWarningDialog is true, voice input need to show warning before // show recognition view. if (languageChanged || modeChanged || VoiceConnector.getInstance().needsToShowWarningDialog()) { || VoiceProxy.getInstance().needsToShowWarningDialog()) { triggerVoiceIME(); } } else { 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 // as it is not the current input mode. mVoiceInputConnector.reset(); mVoiceInputWrapper.reset(); } } } Loading Loading @@ -520,9 +520,9 @@ public class SubtypeSwitcher { // Voice Input functions // /////////////////////////// public boolean setVoiceInputConnector(VoiceConnector.VoiceInputConnector vi) { if (mVoiceInputConnector == null && vi != null) { mVoiceInputConnector = vi; public boolean setVoiceInputWrapper(VoiceProxy.VoiceInputWrapper vi) { if (mVoiceInputWrapper == null && vi != null) { mVoiceInputWrapper = vi; if (isVoiceMode()) { if (DBG) { Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr()); Loading @@ -540,7 +540,7 @@ public class SubtypeSwitcher { private void triggerVoiceIME() { if (!mService.isInputViewShown()) return; VoiceConnector.getInstance().startListening(false, VoiceProxy.getInstance().startListening(false, KeyboardSwitcher.getInstance().getInputView().getWindowToken()); } Loading Loading @@ -631,7 +631,7 @@ public class SubtypeSwitcher { // 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 // value should never be stale. String supportedLocalesString = VoiceConnector.getSupportedLocalesString( String supportedLocalesString = VoiceProxy.getSupportedLocalesString( mService.getContentResolver()); List<String> voiceInputSupportedLocales = Arrays.asList( supportedLocalesString.split("\\s+")); Loading Loading
java/src/com/android/inputmethod/deprecated/VoiceConnector.java→java/src/com/android/inputmethod/deprecated/VoiceProxy.java +16 −16 Original line number Diff line number Diff line Loading @@ -68,8 +68,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; public class VoiceConnector implements VoiceInput.UiListener { private static final VoiceConnector sInstance = new VoiceConnector(); public class VoiceProxy implements VoiceInput.UiListener { private static final VoiceProxy sInstance = new VoiceProxy(); public static final boolean VOICE_INSTALLED = true; private static final boolean ENABLE_VOICE_BUTTON = true; Loading @@ -83,7 +83,7 @@ public class VoiceConnector implements VoiceInput.UiListener { "has_used_voice_input_unsupported_locale"; 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 boolean mAfterVoiceInput; Loading Loading @@ -111,12 +111,12 @@ public class VoiceConnector implements VoiceInput.UiListener { private final Map<String, List<CharSequence>> mWordToSuggestions = 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); return sInstance; } public static VoiceConnector getInstance() { public static VoiceProxy getInstance() { return sInstance; } Loading @@ -139,7 +139,7 @@ public class VoiceConnector implements VoiceInput.UiListener { } } private VoiceConnector() { private VoiceProxy() { // Intentional empty constructor for singleton. } Loading Loading @@ -691,7 +691,7 @@ public class VoiceConnector implements VoiceInput.UiListener { public void onAttachedToWindow() { // After onAttachedToWindow, we can show the voice warning dialog. See startListening() // above. VoiceInputConnector.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher); VoiceInputWrapper.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher); } public void onConfigurationChanged(Configuration configuration) { Loading Loading @@ -743,11 +743,11 @@ public class VoiceConnector implements VoiceInput.UiListener { Map<String, List<CharSequence>> alternatives; } public static class VoiceLoggerConnector { private static final VoiceLoggerConnector sInstance = new VoiceLoggerConnector(); public static class VoiceLoggerWrapper { private static final VoiceLoggerWrapper sInstance = new VoiceLoggerWrapper(); private VoiceInputLogger mLogger; public static VoiceLoggerConnector getInstance(Context context) { public static VoiceLoggerWrapper getInstance(Context context) { if (sInstance.mLogger == null) { // Not thread safe, but it's ok. sInstance.mLogger = VoiceInputLogger.getLogger(context); Loading @@ -756,7 +756,7 @@ public class VoiceConnector implements VoiceInput.UiListener { } // private for the singleton private VoiceLoggerConnector() { private VoiceLoggerWrapper() { } public void settingsWarningDialogCancel() { Loading Loading @@ -784,20 +784,20 @@ public class VoiceConnector implements VoiceInput.UiListener { } } public static class VoiceInputConnector { private static final VoiceInputConnector sInstance = new VoiceInputConnector(); public static class VoiceInputWrapper { private static final VoiceInputWrapper sInstance = new VoiceInputWrapper(); private VoiceInput mVoiceInput; public static VoiceInputConnector getInstance() { public static VoiceInputWrapper getInstance() { return sInstance; } public void setVoiceInput(VoiceInput voiceInput, SubtypeSwitcher switcher) { if (mVoiceInput == null && voiceInput != null) { mVoiceInput = voiceInput; } switcher.setVoiceInputConnector(this); switcher.setVoiceInputWrapper(this); } private VoiceInputConnector() { private VoiceInputWrapper() { } public void cancel() { Loading
java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +2 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ 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.Utils; Loading Loading @@ -264,6 +264,6 @@ public class LatinKeyboardView extends KeyboardView { @Override protected void onAttachedToWindow() { // Token is available from here. VoiceConnector.getInstance().onAttachedToWindow(); VoiceProxy.getInstance().onAttachedToWindow(); } }
java/src/com/android/inputmethod/latin/LatinIME.java +29 −29 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; 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.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardSwitcher; Loading Loading @@ -154,7 +154,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private String mInputMethodId; private KeyboardSwitcher mKeyboardSwitcher; private SubtypeSwitcher mSubtypeSwitcher; private VoiceConnector mVoiceConnector; private VoiceProxy mVoiceProxy; private UserDictionary mUserDictionary; private UserBigramDictionary mUserBigramDictionary; Loading Loading @@ -212,7 +212,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar /* package */ String mWordSeparators; private String mSentenceSeparators; private String mSuggestPuncs; // TODO: Move this flag to VoiceIMEConnector // TODO: Move this flag to VoiceProxy private boolean mConfigurationChanging; // Object for reacting to adding/removing a dictionary pack. Loading Loading @@ -282,7 +282,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar switcher.updateShiftState(); break; case MSG_VOICE_RESULTS: mVoiceConnector.handleVoiceResults(preferCapitalization() mVoiceProxy.handleVoiceResults(preferCapitalization() || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked())); break; case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: Loading Loading @@ -432,7 +432,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registerReceiver(mReceiver, filter); mVoiceConnector = VoiceConnector.init(this, prefs, mHandler); mVoiceProxy = VoiceProxy.init(this, prefs, mHandler); final IntentFilter packageFilter = new IntentFilter(); packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED); Loading Loading @@ -492,7 +492,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } unregisterReceiver(mReceiver); unregisterReceiver(mDictionaryPackInstallReceiver); mVoiceConnector.destroy(); mVoiceProxy.destroy(); LatinImeLogger.commit(); LatinImeLogger.onDestroy(); super.onDestroy(); Loading @@ -513,7 +513,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mConfigurationChanging = true; super.onConfigurationChanged(conf); mVoiceConnector.onConfigurationChanged(conf); mVoiceProxy.onConfigurationChanged(conf); mConfigurationChanging = false; } Loading Loading @@ -559,7 +559,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // 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 // want to enable the voice button. final VoiceConnector voiceIme = mVoiceConnector; final VoiceProxy voiceIme = mVoiceProxy; voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType) || Utils.isVisiblePasswordInputType(attribute.inputType)); Loading Loading @@ -691,7 +691,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar LatinImeLogger.commit(); mKeyboardSwitcher.onAutoCorrectionStateChanged(false); mVoiceConnector.flushVoiceInputLogs(mConfigurationChanging); mVoiceProxy.flushVoiceInputLogs(mConfigurationChanging); KeyboardView inputView = mKeyboardSwitcher.getInputView(); if (inputView != null) inputView.closing(); Loading @@ -712,7 +712,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void onUpdateExtractedText(int token, ExtractedText text) { super.onUpdateExtractedText(token, text); mVoiceConnector.showPunctuationHintIfNecessary(); mVoiceProxy.showPunctuationHintIfNecessary(); } @Override Loading @@ -733,7 +733,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar + ", ce=" + candidatesEnd); } mVoiceConnector.setCursorAndSelection(newSelEnd, newSelStart); mVoiceProxy.setCursorAndSelection(newSelEnd, newSelStart); // If the current selection in the text view changes, we should // clear whatever candidate text we have. Loading @@ -741,7 +741,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; if (((mComposing.length() > 0 && mHasValidSuggestions) || mVoiceConnector.isVoiceInputHighlighted()) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || candidatesCleared)) { if (candidatesCleared) { // If the composing span has been cleared, save the typed word in the history for Loading @@ -757,7 +757,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (ic != null) { ic.finishComposingText(); } mVoiceConnector.setVoiceInputHighlighted(false); mVoiceProxy.setVoiceInputHighlighted(false); } else if (!mHasValidSuggestions && !mJustAccepted) { if (TextEntryState.isAcceptedDefault() || TextEntryState.isSpaceAfterPicked()) { if (TextEntryState.isAcceptedDefault()) Loading Loading @@ -837,7 +837,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mOptionsDialog.dismiss(); mOptionsDialog = null; } mVoiceConnector.hideVoiceWindow(mConfigurationChanging); mVoiceProxy.hideVoiceWindow(mConfigurationChanging); mWordHistory.clear(); super.hideWindow(); } Loading Loading @@ -1188,7 +1188,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void onTextInput(CharSequence text) { mVoiceConnector.commitVoiceInput(); mVoiceProxy.commitVoiceInput(); InputConnection ic = getCurrentInputConnection(); if (ic == null) return; abortRecorrection(false); Loading @@ -1210,13 +1210,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleBackspace() { if (mVoiceConnector.logAndRevertVoiceInput()) return; if (mVoiceProxy.logAndRevertVoiceInput()) return; final InputConnection ic = getCurrentInputConnection(); if (ic == null) return; ic.beginBatchEdit(); mVoiceConnector.handleBackspace(); mVoiceProxy.handleBackspace(); boolean deleteChar = false; if (mHasValidSuggestions) { Loading Loading @@ -1300,7 +1300,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleCharacter(int primaryCode, int[] keyCodes, int x, int y) { mVoiceConnector.handleCharacter(); mVoiceProxy.handleCharacter(); if (mLastSelectionStart == mLastSelectionEnd && TextEntryState.isRecorrecting()) { abortRecorrection(false); Loading Loading @@ -1360,7 +1360,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void handleSeparator(int primaryCode) { mVoiceConnector.handleSeparator(); mVoiceProxy.handleSeparator(); // Should dismiss the "Touch again to save" message when handling separator if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) { Loading Loading @@ -1430,7 +1430,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private void handleClose() { commitTyped(getCurrentInputConnection()); mVoiceConnector.handleClose(); mVoiceProxy.handleClose(); requestHideSelf(0); LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); if (inputView != null) Loading Loading @@ -1503,7 +1503,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } public void setSuggestions(SuggestedWords words) { if (mVoiceConnector.getAndResetIsShowingHint()) { if (mVoiceProxy.getAndResetIsShowingHint()) { setCandidatesView(mCandidateViewContainer); } Loading @@ -1519,7 +1519,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void updateSuggestions() { // Check if we have a suggestion engine attached. if ((mSuggest == null || !isSuggestionsRequested()) && !mVoiceConnector.isVoiceInputHighlighted()) { && !mVoiceProxy.isVoiceInputHighlighted()) { return; } Loading Loading @@ -1614,7 +1614,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public void pickSuggestionManually(int index, CharSequence suggestion) { SuggestedWords suggestions = mCandidateView.getSuggestions(); mVoiceConnector.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators); mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mWordSeparators); final boolean recorrecting = TextEntryState.isRecorrecting(); InputConnection ic = getCurrentInputConnection(); Loading Loading @@ -1718,7 +1718,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; InputConnection ic = getCurrentInputConnection(); if (ic != null) { mVoiceConnector.rememberReplacedWord(suggestion, mWordSeparators); mVoiceProxy.rememberReplacedWord(suggestion, mWordSeparators); ic.commitText(suggestion, 1); } saveWordInHistory(suggestion); Loading Loading @@ -1773,7 +1773,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } private void setOldSuggestions() { mVoiceConnector.setShowingVoiceSuggestions(false); mVoiceProxy.setShowingVoiceSuggestions(false); if (mCandidateView != null && mCandidateView.isShowingAddToDictionaryHint()) { return; } Loading @@ -1787,7 +1787,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (touching != null && touching.mWord.length() > 1) { ic.beginBatchEdit(); if (!mVoiceConnector.applyVoiceAlternatives(touching) if (!mVoiceProxy.applyVoiceAlternatives(touching) && !applyTypedAlternatives(touching)) { abortRecorrection(true); } else { Loading Loading @@ -1945,8 +1945,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } // Reload keyboard because the current language has been changed. mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceConnector.isVoiceButtonEnabled(), mVoiceConnector.isVoiceButtonOnPrimary()); mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceProxy.isVoiceButtonEnabled(), mVoiceProxy.isVoiceButtonOnPrimary()); initSuggest(); mKeyboardSwitcher.updateShiftState(); } Loading Loading @@ -2132,7 +2132,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs); loadAndSetAutoCorrectionThreshold(prefs); mVoiceConnector.loadSettings(attribute, prefs); mVoiceProxy.loadSettings(attribute, prefs); updateCorrectionMode(); updateAutoTextEnabled(); Loading
java/src/com/android/inputmethod/latin/Settings.java +4 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.CompatUtils; 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.Dialog; Loading Loading @@ -82,7 +82,7 @@ public class Settings extends PreferenceActivity private AlertDialog mDialog; private VoiceConnector.VoiceLoggerConnector mVoiceLogger; private VoiceProxy.VoiceLoggerWrapper mVoiceLogger; private boolean mOkClicked = false; private String mVoiceModeOff; Loading Loading @@ -111,7 +111,7 @@ public class Settings extends PreferenceActivity mVoiceModeOff = getString(R.string.voice_mode_off); mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff) .equals(mVoiceModeOff)); mVoiceLogger = VoiceConnector.VoiceLoggerConnector.getInstance(this); mVoiceLogger = VoiceProxy.VoiceLoggerWrapper.getInstance(this); mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD); mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS); Loading Loading @@ -184,7 +184,7 @@ public class Settings extends PreferenceActivity ((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY)) .removePreference(mQuickFixes); } if (!VoiceConnector.VOICE_INSTALLED if (!VoiceProxy.VOICE_INSTALLED || !SpeechRecognizer.isRecognitionAvailable(this)) { getPreferenceScreen().removePreference(mVoicePreference); } else { Loading
java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +15 −15 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; 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.LatinKeyboard; Loading Loading @@ -78,7 +78,7 @@ public class SubtypeSwitcher { private Locale mSystemLocale; private Locale mInputLocale; private String mInputLocaleStr; private VoiceConnector.VoiceInputConnector mVoiceInputConnector; private VoiceProxy.VoiceInputWrapper mVoiceInputWrapper; /*-----------------------------------------------------------*/ private boolean mIsNetworkConnected; Loading Loading @@ -113,7 +113,7 @@ public class SubtypeSwitcher { mCurrentSubtype = null; mAllEnabledSubtypesOfCurrentInputMethod = null; // TODO: Voice input should be created here mVoiceInputConnector = null; mVoiceInputWrapper = null; mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean( R.bool.config_use_spacebar_language_switcher); if (mConfigUseSpacebarLanguageSwitcher) Loading Loading @@ -243,30 +243,30 @@ public class SubtypeSwitcher { // We cancel its status when we change mode, while we reset otherwise. if (isKeyboardMode()) { if (modeChanged) { if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != null) { mVoiceInputConnector.cancel(); if (VOICE_MODE.equals(oldMode) && mVoiceInputWrapper != null) { mVoiceInputWrapper.cancel(); } } if (modeChanged || languageChanged) { updateShortcutIME(); mService.onRefreshKeyboard(); } } else if (isVoiceMode() && mVoiceInputConnector != null) { } else if (isVoiceMode() && mVoiceInputWrapper != null) { if (VOICE_MODE.equals(oldMode)) { mVoiceInputConnector.reset(); mVoiceInputWrapper.reset(); } // If needsToShowWarningDialog is true, voice input need to show warning before // show recognition view. if (languageChanged || modeChanged || VoiceConnector.getInstance().needsToShowWarningDialog()) { || VoiceProxy.getInstance().needsToShowWarningDialog()) { triggerVoiceIME(); } } else { 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 // as it is not the current input mode. mVoiceInputConnector.reset(); mVoiceInputWrapper.reset(); } } } Loading Loading @@ -520,9 +520,9 @@ public class SubtypeSwitcher { // Voice Input functions // /////////////////////////// public boolean setVoiceInputConnector(VoiceConnector.VoiceInputConnector vi) { if (mVoiceInputConnector == null && vi != null) { mVoiceInputConnector = vi; public boolean setVoiceInputWrapper(VoiceProxy.VoiceInputWrapper vi) { if (mVoiceInputWrapper == null && vi != null) { mVoiceInputWrapper = vi; if (isVoiceMode()) { if (DBG) { Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr()); Loading @@ -540,7 +540,7 @@ public class SubtypeSwitcher { private void triggerVoiceIME() { if (!mService.isInputViewShown()) return; VoiceConnector.getInstance().startListening(false, VoiceProxy.getInstance().startListening(false, KeyboardSwitcher.getInstance().getInputView().getWindowToken()); } Loading Loading @@ -631,7 +631,7 @@ public class SubtypeSwitcher { // 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 // value should never be stale. String supportedLocalesString = VoiceConnector.getSupportedLocalesString( String supportedLocalesString = VoiceProxy.getSupportedLocalesString( mService.getContentResolver()); List<String> voiceInputSupportedLocales = Arrays.asList( supportedLocalesString.split("\\s+")); Loading