Fix NPE in settings

Bug: 5246032
Change-Id: I452dab9bf863fb8cba142467f338088ee8b30283
This commit is contained in:
satok 2011-09-07 12:36:07 +09:00
parent ade62577d4
commit 6d468c513f
3 changed files with 6 additions and 6 deletions

View file

@ -717,8 +717,8 @@ public class VoiceProxy implements VoiceInput.UiListener {
mHasUsedVoiceInputUnsupportedLocale = mHasUsedVoiceInputUnsupportedLocale =
sp.getBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE, false); sp.getBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE, false);
mLocaleSupportedForVoiceInput = SubtypeSwitcher.getInstance().isVoiceSupported( mLocaleSupportedForVoiceInput = SubtypeSwitcher.isVoiceSupported(
SubtypeSwitcher.getInstance().getInputLocaleStr()); mService, SubtypeSwitcher.getInstance().getInputLocaleStr());
final String voiceMode = sp.getString(PREF_VOICE_MODE, final String voiceMode = sp.getString(PREF_VOICE_MODE,
mService.getString(R.string.voice_mode_main)); mService.getString(R.string.voice_mode_main));

View file

@ -580,8 +580,8 @@ public class Settings extends InputMethodSettingsActivity
// Get the current list of supported locales and check the current locale against // Get the current list of supported locales and check the current locale against
// that list, to decide whether to put a warning that voice input will not work in // that list, to decide whether to put a warning that voice input will not work in
// the current language as part of the pop-up confirmation dialog. // the current language as part of the pop-up confirmation dialog.
boolean localeSupported = SubtypeSwitcher.getInstance().isVoiceSupported( boolean localeSupported = SubtypeSwitcher.isVoiceSupported(
Locale.getDefault().toString()); this, Locale.getDefault().toString());
final CharSequence message; final CharSequence message;
if (localeSupported) { if (localeSupported) {

View file

@ -539,14 +539,14 @@ public class SubtypeSwitcher {
} }
public boolean isVoiceSupported(String locale) { public static boolean isVoiceSupported(Context context, String locale) {
// Get the current list of supported locales and check the current locale against that // 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 // 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 // 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 = VoiceProxy.getSupportedLocalesString( String supportedLocalesString = VoiceProxy.getSupportedLocalesString(
mService.getContentResolver()); context.getContentResolver());
List<String> voiceInputSupportedLocales = Arrays.asList( List<String> voiceInputSupportedLocales = Arrays.asList(
supportedLocalesString.split("\\s+")); supportedLocalesString.split("\\s+"));
return voiceInputSupportedLocales.contains(locale); return voiceInputSupportedLocales.contains(locale);