(Refactor 1) Moved voice related codes to deprecated/voice
Change-Id: I008ac7099c815fb74a9ab374419617b336453f97main
parent
071f47140c
commit
9807ab27ea
|
@ -45,7 +45,7 @@
|
|||
android:layout_height="0dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="1.0">
|
||||
<com.android.inputmethod.voice.SoundIndicator
|
||||
<com.android.inputmethod.deprecated.voice.SoundIndicator
|
||||
android:id="@+id/sound_indicator"
|
||||
android:src="@drawable/mic_full"
|
||||
android:background="@drawable/mic_base"
|
||||
|
|
|
@ -14,8 +14,13 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated;
|
||||
|
||||
import com.android.inputmethod.deprecated.voice.FieldContext;
|
||||
import com.android.inputmethod.deprecated.voice.Hints;
|
||||
import com.android.inputmethod.deprecated.voice.SettingsUtil;
|
||||
import com.android.inputmethod.deprecated.voice.VoiceInput;
|
||||
import com.android.inputmethod.deprecated.voice.VoiceInputLogger;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import com.android.inputmethod.latin.EditingUtils;
|
||||
import com.android.inputmethod.latin.LatinIME;
|
||||
|
@ -28,6 +33,7 @@ import com.android.inputmethod.latin.SuggestedWords;
|
|||
import com.android.inputmethod.latin.Utils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -62,8 +68,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class VoiceIMEConnector implements VoiceInput.UiListener {
|
||||
private static final VoiceIMEConnector sInstance = new VoiceIMEConnector();
|
||||
public class VoiceConnector implements VoiceInput.UiListener {
|
||||
private static final VoiceConnector sInstance = new VoiceConnector();
|
||||
|
||||
public static final boolean VOICE_INSTALLED = true;
|
||||
private static final boolean ENABLE_VOICE_BUTTON = true;
|
||||
|
@ -77,7 +83,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
|
|||
"has_used_voice_input_unsupported_locale";
|
||||
private static final int RECOGNITIONVIEW_HEIGHT_THRESHOLD_RATIO = 6;
|
||||
|
||||
private static final String TAG = VoiceIMEConnector.class.getSimpleName();
|
||||
private static final String TAG = VoiceConnector.class.getSimpleName();
|
||||
private static final boolean DEBUG = LatinImeLogger.sDBG;
|
||||
|
||||
private boolean mAfterVoiceInput;
|
||||
|
@ -105,12 +111,12 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
|
|||
private final Map<String, List<CharSequence>> mWordToSuggestions =
|
||||
new HashMap<String, List<CharSequence>>();
|
||||
|
||||
public static VoiceIMEConnector init(LatinIME context, SharedPreferences prefs, UIHandler h) {
|
||||
public static VoiceConnector init(LatinIME context, SharedPreferences prefs, UIHandler h) {
|
||||
sInstance.initInternal(context, prefs, h);
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static VoiceIMEConnector getInstance() {
|
||||
public static VoiceConnector getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
|
@ -133,7 +139,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
|
|||
}
|
||||
}
|
||||
|
||||
private VoiceIMEConnector() {
|
||||
private VoiceConnector() {
|
||||
// Intentional empty constructor for singleton.
|
||||
}
|
||||
|
||||
|
@ -674,7 +680,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
|
|||
public void onAttachedToWindow() {
|
||||
// After onAttachedToWindow, we can show the voice warning dialog. See startListening()
|
||||
// above.
|
||||
mSubtypeSwitcher.setVoiceInput(mVoiceInput);
|
||||
VoiceInputConnector.getInstance().setVoiceInput(mVoiceInput, mSubtypeSwitcher);
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration configuration) {
|
||||
|
@ -725,4 +731,91 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
|
|||
List<String> candidates;
|
||||
Map<String, List<CharSequence>> alternatives;
|
||||
}
|
||||
|
||||
public static class VoiceLoggerConnector {
|
||||
private static final VoiceLoggerConnector sInstance = new VoiceLoggerConnector();
|
||||
private VoiceInputLogger mLogger;
|
||||
|
||||
public static VoiceLoggerConnector getInstance(Context context) {
|
||||
if (sInstance.mLogger == null) {
|
||||
// Not thread safe, but it's ok.
|
||||
sInstance.mLogger = VoiceInputLogger.getLogger(context);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
// private for the singleton
|
||||
private VoiceLoggerConnector() {
|
||||
}
|
||||
|
||||
public void settingsWarningDialogCancel() {
|
||||
mLogger.settingsWarningDialogCancel();
|
||||
}
|
||||
|
||||
public void settingsWarningDialogOk() {
|
||||
mLogger.settingsWarningDialogOk();
|
||||
}
|
||||
|
||||
public void settingsWarningDialogShown() {
|
||||
mLogger.settingsWarningDialogShown();
|
||||
}
|
||||
|
||||
public void settingsWarningDialogDismissed() {
|
||||
mLogger.settingsWarningDialogDismissed();
|
||||
}
|
||||
|
||||
public void voiceInputSettingEnabled(boolean enabled) {
|
||||
if (enabled) {
|
||||
mLogger.voiceInputSettingEnabled();
|
||||
} else {
|
||||
mLogger.voiceInputSettingDisabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class VoiceInputConnector {
|
||||
private static final VoiceInputConnector sInstance = new VoiceInputConnector();
|
||||
private VoiceInput mVoiceInput;
|
||||
public static VoiceInputConnector getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
public void setVoiceInput(VoiceInput voiceInput, SubtypeSwitcher switcher) {
|
||||
if (mVoiceInput == null && voiceInput != null) {
|
||||
mVoiceInput = voiceInput;
|
||||
switcher.setVoiceInputConnector(this);
|
||||
}
|
||||
}
|
||||
|
||||
private VoiceInputConnector() {
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (mVoiceInput != null) mVoiceInput.cancel();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
if (mVoiceInput != null) mVoiceInput.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// A list of locales which are supported by default for voice input, unless we get a
|
||||
// different list from Gservices.
|
||||
private static final String DEFAULT_VOICE_INPUT_SUPPORTED_LOCALES =
|
||||
"en " +
|
||||
"en_US " +
|
||||
"en_GB " +
|
||||
"en_AU " +
|
||||
"en_CA " +
|
||||
"en_IE " +
|
||||
"en_IN " +
|
||||
"en_NZ " +
|
||||
"en_SG " +
|
||||
"en_ZA ";
|
||||
|
||||
public static String getSupportedLocalesString (ContentResolver resolver) {
|
||||
return SettingsUtil.getSettingsString(
|
||||
resolver,
|
||||
SettingsUtil.LATIN_IME_VOICE_INPUT_SUPPORTED_LOCALES,
|
||||
DEFAULT_VOICE_INPUT_SUPPORTED_LOCALES);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.SharedPreferencesCompat;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.provider.Settings;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import com.android.inputmethod.latin.EditingUtils;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import com.android.common.speech.LoggingEvents;
|
||||
import com.android.common.userhappiness.UserHappinessSignals;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
|
@ -14,7 +14,7 @@
|
|||
* the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.voice;
|
||||
package com.android.inputmethod.deprecated.voice;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
package com.android.inputmethod.keyboard;
|
||||
|
||||
import com.android.inputmethod.deprecated.VoiceConnector;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.Utils;
|
||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -264,6 +264,6 @@ public class LatinKeyboardView extends KeyboardView {
|
|||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
// Token is available from here.
|
||||
VoiceIMEConnector.getInstance().onAttachedToWindow();
|
||||
VoiceConnector.getInstance().onAttachedToWindow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import com.android.inputmethod.deprecated.VoiceConnector;
|
||||
import com.android.inputmethod.keyboard.Keyboard;
|
||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
|
@ -23,7 +24,6 @@ import com.android.inputmethod.keyboard.KeyboardView;
|
|||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
||||
import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||
import com.android.inputmethod.latin.Utils.RingCharBuffer;
|
||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
|
@ -146,7 +146,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private String mInputMethodId;
|
||||
private KeyboardSwitcher mKeyboardSwitcher;
|
||||
private SubtypeSwitcher mSubtypeSwitcher;
|
||||
private VoiceIMEConnector mVoiceConnector;
|
||||
private VoiceConnector mVoiceConnector;
|
||||
|
||||
private UserDictionary mUserDictionary;
|
||||
private UserBigramDictionary mUserBigramDictionary;
|
||||
|
@ -419,7 +419,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
registerReceiver(mReceiver, filter);
|
||||
mVoiceConnector = VoiceIMEConnector.init(this, prefs, mHandler);
|
||||
mVoiceConnector = VoiceConnector.init(this, prefs, mHandler);
|
||||
}
|
||||
|
||||
private void initSuggest() {
|
||||
|
@ -531,7 +531,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// 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 VoiceIMEConnector voiceIme = mVoiceConnector;
|
||||
final VoiceConnector voiceIme = mVoiceConnector;
|
||||
voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType)
|
||||
|| Utils.isVisiblePasswordInputType(attribute.inputType));
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||
import com.android.inputmethod.voice.VoiceInputLogger;
|
||||
import com.android.inputmethod.deprecated.VoiceConnector;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
@ -82,7 +81,7 @@ public class Settings extends PreferenceActivity
|
|||
|
||||
private AlertDialog mDialog;
|
||||
|
||||
private VoiceInputLogger mLogger;
|
||||
private VoiceConnector.VoiceLoggerConnector mVoiceLogger;
|
||||
|
||||
private boolean mOkClicked = false;
|
||||
private String mVoiceModeOff;
|
||||
|
@ -111,7 +110,7 @@ public class Settings extends PreferenceActivity
|
|||
mVoiceModeOff = getString(R.string.voice_mode_off);
|
||||
mVoiceOn = !(prefs.getString(PREF_VOICE_SETTINGS_KEY, mVoiceModeOff)
|
||||
.equals(mVoiceModeOff));
|
||||
mLogger = VoiceInputLogger.getLogger(this);
|
||||
mVoiceLogger = VoiceConnector.VoiceLoggerConnector.getInstance(this);
|
||||
|
||||
mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
|
||||
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS);
|
||||
|
@ -184,7 +183,7 @@ public class Settings extends PreferenceActivity
|
|||
((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY))
|
||||
.removePreference(mQuickFixes);
|
||||
}
|
||||
if (!VoiceIMEConnector.VOICE_INSTALLED
|
||||
if (!VoiceConnector.VOICE_INSTALLED
|
||||
|| !SpeechRecognizer.isRecognitionAvailable(this)) {
|
||||
getPreferenceScreen().removePreference(mVoicePreference);
|
||||
} else {
|
||||
|
@ -277,10 +276,10 @@ public class Settings extends PreferenceActivity
|
|||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
if (whichButton == DialogInterface.BUTTON_NEGATIVE) {
|
||||
mVoicePreference.setValue(mVoiceModeOff);
|
||||
mLogger.settingsWarningDialogCancel();
|
||||
mVoiceLogger.settingsWarningDialogCancel();
|
||||
} else if (whichButton == DialogInterface.BUTTON_POSITIVE) {
|
||||
mOkClicked = true;
|
||||
mLogger.settingsWarningDialogOk();
|
||||
mVoiceLogger.settingsWarningDialogOk();
|
||||
}
|
||||
updateVoicePreference();
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ public class Settings extends PreferenceActivity
|
|||
AlertDialog dialog = builder.create();
|
||||
mDialog = dialog;
|
||||
dialog.setOnDismissListener(this);
|
||||
mLogger.settingsWarningDialogShown();
|
||||
mVoiceLogger.settingsWarningDialogShown();
|
||||
return dialog;
|
||||
default:
|
||||
Log.e(TAG, "unknown dialog " + id);
|
||||
|
@ -321,7 +320,7 @@ public class Settings extends PreferenceActivity
|
|||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mLogger.settingsWarningDialogDismissed();
|
||||
mVoiceLogger.settingsWarningDialogDismissed();
|
||||
if (!mOkClicked) {
|
||||
// This assumes that onPreferenceClick gets called first, and this if the user
|
||||
// agreed after the warning, we set the mOkClicked value to true.
|
||||
|
@ -331,10 +330,6 @@ public class Settings extends PreferenceActivity
|
|||
|
||||
private void updateVoicePreference() {
|
||||
boolean isChecked = !mVoicePreference.getValue().equals(mVoiceModeOff);
|
||||
if (isChecked) {
|
||||
mLogger.voiceInputSettingEnabled();
|
||||
} else {
|
||||
mLogger.voiceInputSettingDisabled();
|
||||
}
|
||||
mVoiceLogger.voiceInputSettingEnabled(isChecked);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
|
||||
package com.android.inputmethod.latin;
|
||||
|
||||
import com.android.inputmethod.deprecated.VoiceConnector;
|
||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
||||
import com.android.inputmethod.voice.SettingsUtil;
|
||||
import com.android.inputmethod.voice.VoiceIMEConnector;
|
||||
import com.android.inputmethod.voice.VoiceInput;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -78,7 +76,7 @@ public class SubtypeSwitcher {
|
|||
private Locale mSystemLocale;
|
||||
private Locale mInputLocale;
|
||||
private String mInputLocaleStr;
|
||||
private VoiceInput mVoiceInput;
|
||||
private VoiceConnector.VoiceInputConnector mVoiceInputConnector;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
private boolean mIsNetworkConnected;
|
||||
|
@ -113,7 +111,7 @@ public class SubtypeSwitcher {
|
|||
mCurrentSubtype = null;
|
||||
mAllEnabledSubtypesOfCurrentInputMethod = null;
|
||||
// TODO: Voice input should be created here
|
||||
mVoiceInput = null;
|
||||
mVoiceInputConnector = null;
|
||||
mConfigUseSpacebarLanguageSwitcher = mResources.getBoolean(
|
||||
R.bool.config_use_spacebar_language_switcher);
|
||||
if (mConfigUseSpacebarLanguageSwitcher)
|
||||
|
@ -243,30 +241,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) && mVoiceInput != null) {
|
||||
mVoiceInput.cancel();
|
||||
if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != null) {
|
||||
mVoiceInputConnector.cancel();
|
||||
}
|
||||
}
|
||||
if (modeChanged || languageChanged) {
|
||||
updateShortcutIME();
|
||||
mService.onRefreshKeyboard();
|
||||
}
|
||||
} else if (isVoiceMode() && mVoiceInput != null) {
|
||||
} else if (isVoiceMode() && mVoiceInputConnector != null) {
|
||||
if (VOICE_MODE.equals(oldMode)) {
|
||||
mVoiceInput.reset();
|
||||
mVoiceInputConnector.reset();
|
||||
}
|
||||
// If needsToShowWarningDialog is true, voice input need to show warning before
|
||||
// show recognition view.
|
||||
if (languageChanged || modeChanged
|
||||
|| VoiceIMEConnector.getInstance().needsToShowWarningDialog()) {
|
||||
|| VoiceConnector.getInstance().needsToShowWarningDialog()) {
|
||||
triggerVoiceIME();
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Unknown subtype mode: " + newMode);
|
||||
if (VOICE_MODE.equals(oldMode) && mVoiceInput != null) {
|
||||
if (VOICE_MODE.equals(oldMode) && mVoiceInputConnector != 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.
|
||||
mVoiceInput.reset();
|
||||
mVoiceInputConnector.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -507,9 +505,9 @@ public class SubtypeSwitcher {
|
|||
// Voice Input functions //
|
||||
///////////////////////////
|
||||
|
||||
public boolean setVoiceInput(VoiceInput vi) {
|
||||
if (mVoiceInput == null && vi != null) {
|
||||
mVoiceInput = vi;
|
||||
public boolean setVoiceInputConnector(VoiceConnector.VoiceInputConnector vi) {
|
||||
if (mVoiceInputConnector == null && vi != null) {
|
||||
mVoiceInputConnector = vi;
|
||||
if (isVoiceMode()) {
|
||||
if (DBG) {
|
||||
Log.d(TAG, "Set and call voice input.: " + getInputLocaleStr());
|
||||
|
@ -527,7 +525,7 @@ public class SubtypeSwitcher {
|
|||
|
||||
private void triggerVoiceIME() {
|
||||
if (!mService.isInputViewShown()) return;
|
||||
VoiceIMEConnector.getInstance().startListening(false,
|
||||
VoiceConnector.getInstance().startListening(false,
|
||||
KeyboardSwitcher.getInstance().getInputView().getWindowToken());
|
||||
}
|
||||
|
||||
|
@ -612,30 +610,14 @@ public class SubtypeSwitcher {
|
|||
}
|
||||
|
||||
|
||||
// A list of locales which are supported by default for voice input, unless we get a
|
||||
// different list from Gservices.
|
||||
private static final String DEFAULT_VOICE_INPUT_SUPPORTED_LOCALES =
|
||||
"en " +
|
||||
"en_US " +
|
||||
"en_GB " +
|
||||
"en_AU " +
|
||||
"en_CA " +
|
||||
"en_IE " +
|
||||
"en_IN " +
|
||||
"en_NZ " +
|
||||
"en_SG " +
|
||||
"en_ZA ";
|
||||
|
||||
public boolean isVoiceSupported(String locale) {
|
||||
// Get the current list of supported locales and check the current locale against that
|
||||
// list. We cache this value so as not to check it every time the user starts a voice
|
||||
// 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 = SettingsUtil.getSettingsString(
|
||||
mService.getContentResolver(),
|
||||
SettingsUtil.LATIN_IME_VOICE_INPUT_SUPPORTED_LOCALES,
|
||||
DEFAULT_VOICE_INPUT_SUPPORTED_LOCALES);
|
||||
String supportedLocalesString = VoiceConnector.getSupportedLocalesString(
|
||||
mService.getContentResolver());
|
||||
List<String> voiceInputSupportedLocales = Arrays.asList(
|
||||
supportedLocalesString.split("\\s+"));
|
||||
return voiceInputSupportedLocales.contains(locale);
|
||||
|
|
Loading…
Reference in New Issue