diff options
author | Narayan Kamath <narayan@google.com> | 2011-08-24 20:12:26 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2011-08-24 20:33:01 +0100 |
commit | 8c3663bbd7fef33734001ef8ec8e7b0f01538616 (patch) | |
tree | 7f0f806299dc1a44ed41466b1be0380923aa8076 /src/com/android/settings/tts/TextToSpeechSettings.java | |
parent | fdc53383a9f98a8dcd5aba09152383d822aa459a (diff) | |
download | packages_apps_Settings-8c3663bbd7fef33734001ef8ec8e7b0f01538616.zip packages_apps_Settings-8c3663bbd7fef33734001ef8ec8e7b0f01538616.tar.gz packages_apps_Settings-8c3663bbd7fef33734001ef8ec8e7b0f01538616.tar.bz2 |
Call setLanguage( ) on the TTS engine before the sample.
This makes the sample play faster, and results in a reliable
return value from getLanguage().
bug:5207139
Change-Id: Ic6ca4a2f4aed299d35c320ecc3f327579c66471b
Diffstat (limited to 'src/com/android/settings/tts/TextToSpeechSettings.java')
-rw-r--r-- | src/com/android/settings/tts/TextToSpeechSettings.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java index 210cb9c..e8255bf 100644 --- a/src/com/android/settings/tts/TextToSpeechSettings.java +++ b/src/com/android/settings/tts/TextToSpeechSettings.java @@ -192,16 +192,31 @@ 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); + + if (DBG) Log.d(TAG, "Loading language ahead of sample check : " + locale); + mTts.setLanguage(new Locale(locale[0], locale[1], locale[2])); + } + } + } + /** * Ask the current default engine to return a string of sample text to be * spoken to the user. */ private void getSampleText() { String currentEngine = mTts.getCurrentEngine(); - Locale currentLocale = mTts.getLanguage(); if (TextUtils.isEmpty(currentEngine)) currentEngine = mTts.getDefaultEngine(); + maybeUpdateTtsLanguage(currentEngine); + Locale currentLocale = mTts.getLanguage(); + // TODO: This is currently a hidden private API. The intent extras // and the intent action should be made public if we intend to make this // a public API. We fall back to using a canned set of strings if this @@ -220,7 +235,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements startActivityForResult(intent, GET_SAMPLE_TEXT); } catch (ActivityNotFoundException ex) { Log.e(TAG, "Failed to get sample text, no activity found for " + intent + ")"); - onSampleTextReceived(TextToSpeech.ERROR, null); } } |