Fixing bugs 2577511 and 2581920.
Making sure that the language, country, and variant defaults are always
set to something to ensure that there won't be an NPE.
Dismissing the ListPreference dialogs before a rotation to avoid list
data corruption caused by the list being displayed while its data is
being re-initialized.
Change-Id: Iecdb3b4d415542dc8a4db162c930e6a6570a55f2
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index ed80892..0ae8eb4 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -161,6 +161,15 @@
<item>Questo è un esempio di sintesi vocale in italiano.</item>
<item>Este es un ejemplo de síntesis de voz en español.</item>
</string-array>
+ <!-- Do not translate. -->
+ <string-array name="tts_engine_entries">
+ <item>Pico TTS</item>
+ </string-array>
+ <!-- Do not translate. -->
+ <string-array name="tts_engine_values">
+ <item>com.svox.pico</item>
+ </string-array>
+
<!-- Wi-Fi settings -->
diff --git a/res/xml/tts_settings.xml b/res/xml/tts_settings.xml
index 8974cfe..c378f64 100644
--- a/res/xml/tts_settings.xml
+++ b/res/xml/tts_settings.xml
@@ -35,7 +35,9 @@
android:key="tts_default_synth"
android:title="@string/tts_default_synth_title"
android:summary="@string/tts_default_synth_summary"
- android:persistent="false" />
+ android:persistent="false"
+ android:entries="@array/tts_engine_entries"
+ android:entryValues="@array/tts_engine_values" />
<Preference
android:key="tts_install_data"
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index d6e11d7..8b30a5a 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -123,6 +123,11 @@
mEnableDemo = false;
mTtsStarted = false;
+ Locale currentLocale = Locale.getDefault();
+ mDefaultLanguage = currentLocale.getISO3Language();
+ mDefaultCountry = currentLocale.getISO3Country();
+ mDefaultLocVariant = currentLocale.getVariant();
+
mTts = new TextToSpeech(this, this);
}
@@ -149,6 +154,21 @@
}
}
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if ((mDefaultRatePref != null) && (mDefaultRatePref.getDialog() != null)) {
+ mDefaultRatePref.getDialog().dismiss();
+ }
+ if ((mDefaultLocPref != null) && (mDefaultLocPref.getDialog() != null)) {
+ mDefaultLocPref.getDialog().dismiss();
+ }
+ if ((mDefaultSynthPref != null) && (mDefaultSynthPref.getDialog() != null)) {
+ mDefaultSynthPref.getDialog().dismiss();
+ }
+ }
+
+
private void addEngineSpecificSettings() {
PreferenceGroup enginesCategory = (PreferenceGroup) findPreference("tts_engines_section");
@@ -673,7 +693,7 @@
private void loadEngines() {
- ListPreference enginesPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_SYNTH);
+ mDefaultSynthPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_SYNTH);
// TODO (clchen): Try to see if it is possible to be more efficient here
// and not search for plugins again.
@@ -705,16 +725,16 @@
CharSequence entriesArray[] = new CharSequence[entries.size()];
CharSequence valuesArray[] = new CharSequence[values.size()];
- enginesPref.setEntries(entries.toArray(entriesArray));
- enginesPref.setEntryValues(values.toArray(valuesArray));
+ mDefaultSynthPref.setEntries(entries.toArray(entriesArray));
+ mDefaultSynthPref.setEntryValues(values.toArray(valuesArray));
// Set the selected engine based on the saved preference
String selectedEngine = Settings.Secure.getString(getContentResolver(), TTS_DEFAULT_SYNTH);
- int selectedEngineIndex = enginesPref.findIndexOfValue(selectedEngine);
+ int selectedEngineIndex = mDefaultSynthPref.findIndexOfValue(selectedEngine);
if (selectedEngineIndex == -1){
- selectedEngineIndex = enginesPref.findIndexOfValue(SYSTEM_TTS);
+ selectedEngineIndex = mDefaultSynthPref.findIndexOfValue(SYSTEM_TTS);
}
- enginesPref.setValueIndex(selectedEngineIndex);
+ mDefaultSynthPref.setValueIndex(selectedEngineIndex);
}
}