summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/tts/TextToSpeechSettings.java
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2014-06-28 14:25:28 -0700
committerCraig Mautner <cmautner@google.com>2014-06-28 14:32:08 -0700
commit5a98d4368188816739243243c0a6d257b61acac1 (patch)
treec0c10d64bf5f5a099ec3380fdf2e2c27e12d38fa /src/com/android/settings/tts/TextToSpeechSettings.java
parentebdd13fa7a4f8251e190937db9da7491104e0970 (diff)
downloadpackages_apps_Settings-5a98d4368188816739243243c0a6d257b61acac1.zip
packages_apps_Settings-5a98d4368188816739243243c0a6d257b61acac1.tar.gz
packages_apps_Settings-5a98d4368188816739243243c0a6d257b61acac1.tar.bz2
Take TextToSpeechSettings out of endless loop
Launching an Activity using startActivityForResult() every time you are in onResume() is a recipe for endless looping. I.e. every time the launched Activity finishes it will be relaunched because the launching Activity reenters onResume(). This change keeps the GetSampleText activity from being launched from onResume if we already have the sample text and the Locale hasn't changed since the last onResume. Fixes bug 15951054. Change-Id: I65d9070df93396d8d3a45a6673ae56826f418122
Diffstat (limited to 'src/com/android/settings/tts/TextToSpeechSettings.java')
-rw-r--r--src/com/android/settings/tts/TextToSpeechSettings.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index 8417cfd..b16ab56 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -47,6 +47,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.Set;
public class TextToSpeechSettings extends SettingsPreferenceFragment implements
@@ -104,7 +105,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
private TextToSpeech mTts = null;
private TtsEngines mEnginesHelper = null;
- private String mSampleText = "";
+ private String mSampleText = null;
/**
* Default locale used by selected TTS engine, null if not connected to any engine.
@@ -270,10 +271,14 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
// ISO-3166 alpha 3 country codes are out of spec. If we won't normalize,
// we may end up with English (USA)and German (DEU).
+ final Locale oldDefaultLocale = mCurrentDefaultLocale;
mCurrentDefaultLocale = mEnginesHelper.parseLocaleString(defaultLocale.toString());
+ if (!Objects.equals(oldDefaultLocale, mCurrentDefaultLocale)) {
+ mSampleText = null;
+ }
int defaultAvailable = mTts.setLanguage(defaultLocale);
- if (evaluateDefaultLocale()) {
+ if (evaluateDefaultLocale() && mSampleText == null) {
getSampleText();
}
}