summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/tts
diff options
context:
space:
mode:
authorPrzemyslaw Szczepaniak <pszczepaniak@google.com>2014-05-12 13:48:33 +0100
committerPrzemyslaw Szczepaniak <pszczepaniak@google.com>2014-05-12 13:48:33 +0100
commit1cb159a7394b5b2ae613994f1f2c36d0fb472468 (patch)
tree8d01648132b8f1d211108f03144b99f29b22f2d2 /src/com/android/settings/tts
parent55638cb6c6730104ec04287e7566eae7f3e57385 (diff)
downloadpackages_apps_Settings-1cb159a7394b5b2ae613994f1f2c36d0fb472468.tar.gz
packages_apps_Settings-1cb159a7394b5b2ae613994f1f2c36d0fb472468.tar.bz2
packages_apps_Settings-1cb159a7394b5b2ae613994f1f2c36d0fb472468.zip
Preserve list of available TTS locales on rotation.
Bug: 13637881 Change-Id: I966005ec34b3f9f1a1354104cae119678c9b3fc4
Diffstat (limited to 'src/com/android/settings/tts')
-rw-r--r--src/com/android/settings/tts/TtsEngineSettingsFragment.java39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/com/android/settings/tts/TtsEngineSettingsFragment.java b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
index 25ec1fdca..f6314dd35 100644
--- a/src/com/android/settings/tts/TtsEngineSettingsFragment.java
+++ b/src/com/android/settings/tts/TtsEngineSettingsFragment.java
@@ -52,6 +52,10 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
private static final String KEY_ENGINE_SETTINGS = "tts_engine_settings";
private static final String KEY_INSTALL_DATA = "tts_install_data";
+ private static final String STATE_KEY_LOCALE_ENTRIES = "locale_entries";
+ private static final String STATE_KEY_LOCALE_ENTRY_VALUES= "locale_entry_values";
+ private static final String STATE_KEY_LOCALE_VALUE = "locale_value";
+
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
private TtsEngines mEnginesHelper;
@@ -120,10 +124,26 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
mEngineSettingsPreference.setEnabled(false);
}
mInstallVoicesPreference.setEnabled(false);
- mLocalePreference.setEnabled(false);
- mLocalePreference.setEntries(new CharSequence[0]);
- mLocalePreference.setEntryValues(new CharSequence[0]);
+ if (savedInstanceState == null) {
+ mLocalePreference.setEnabled(false);
+ mLocalePreference.setEntries(new CharSequence[0]);
+ mLocalePreference.setEntryValues(new CharSequence[0]);
+ } else {
+ // Repopulate mLocalePreference with saved state. Will be updated later with
+ // up-to-date values when checkTtsData() calls back with results.
+ final CharSequence[] entries =
+ savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
+ final CharSequence[] entryValues =
+ savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
+ final CharSequence value =
+ savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
+
+ mLocalePreference.setEntries(entries);
+ mLocalePreference.setEntryValues(entryValues);
+ mLocalePreference.setValue(value.toString());
+ mLocalePreference.setEnabled(entries.length > 0);
+ }
mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
@@ -144,6 +164,19 @@ public class TtsEngineSettingsFragment extends SettingsPreferenceFragment implem
super.onDestroy();
}
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ // Save the mLocalePreference values, so we can repopulate it with entries.
+ outState.putCharSequenceArray(STATE_KEY_LOCALE_ENTRIES,
+ mLocalePreference.getEntries());
+ outState.putCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES,
+ mLocalePreference.getEntryValues());
+ outState.putCharSequence(STATE_KEY_LOCALE_VALUE,
+ mLocalePreference.getValue());
+ }
+
private final void checkTtsData() {
Intent intent = new Intent(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
intent.setPackage(getEngineName());