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
This commit is contained in:
@@ -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 -->
|
||||
|
||||
|
@@ -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"
|
||||
|
@@ -123,6 +123,11 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
||||
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 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
@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 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
||||
|
||||
|
||||
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 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user