Call setLanguage() when the TTS locale is changed in settings.
This is required to fix the case where an app has instantiated and is using a TextToSpeech instance, and the user switches to settings and changes the language for that instance. If no app was using TTS, then onCreate() would have be called when TTS is used next, and the correct locale will be loaded. bug:5823836 Change-Id: I62adf3f7f0f14b67450ba08b8743e0d31e615a7e
This commit is contained in:
@@ -192,23 +192,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
checkVoiceData(mCurrentEngine);
|
||||
}
|
||||
|
||||
private void maybeUpdateTtsLanguage(String currentEngine) {
|
||||
if (currentEngine != null && mTts != null) {
|
||||
final String localeString = mEnginesHelper.getLocalePrefForEngine(
|
||||
currentEngine);
|
||||
if (localeString != null) {
|
||||
final String[] locale = TtsEngines.parseLocalePref(localeString);
|
||||
final Locale newLocale = new Locale(locale[0], locale[1], locale[2]);
|
||||
final Locale engineLocale = mTts.getLanguage();
|
||||
|
||||
if (!newLocale.equals(engineLocale)) {
|
||||
if (DBG) Log.d(TAG, "Loading language ahead of sample check : " + locale);
|
||||
mTts.setLanguage(newLocale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the current default engine to return a string of sample text to be
|
||||
* spoken to the user.
|
||||
@@ -218,7 +201,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
if (TextUtils.isEmpty(currentEngine)) currentEngine = mTts.getDefaultEngine();
|
||||
|
||||
maybeUpdateTtsLanguage(currentEngine);
|
||||
Locale currentLocale = mTts.getLanguage();
|
||||
|
||||
// TODO: This is currently a hidden private API. The intent extras
|
||||
|
Reference in New Issue
Block a user