summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/TextToSpeechSettings.java
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2010-02-10 13:58:23 -0800
committerCharles Chen <clchen@google.com>2010-02-10 14:54:26 -0800
commitc8298717bc3b015ce1dece31d201d7ae7bf37677 (patch)
tree2acfedc9221dbd0c1f3bf8c3a47455489e94067e /src/com/android/settings/TextToSpeechSettings.java
parent07c61c6dbb805ab9aa60ceffd3bd1fb528a3dc65 (diff)
downloadpackages_apps_Settings-c8298717bc3b015ce1dece31d201d7ae7bf37677.zip
packages_apps_Settings-c8298717bc3b015ce1dece31d201d7ae7bf37677.tar.gz
packages_apps_Settings-c8298717bc3b015ce1dece31d201d7ae7bf37677.tar.bz2
Settings for TextToSpeech now uses the results returned by the
engine's CheckVoiceData activity to determine which languages are available and whether or not to make "Install Data" clickable.
Diffstat (limited to 'src/com/android/settings/TextToSpeechSettings.java')
-rw-r--r--src/com/android/settings/TextToSpeechSettings.java46
1 files changed, 41 insertions, 5 deletions
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index 1a97fbf..4a2f8c8 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -38,6 +38,7 @@ import android.provider.Settings.SettingNotFoundException;
import android.speech.tts.TextToSpeech;
import android.util.Log;
+import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
@@ -84,6 +85,7 @@ public class TextToSpeechSettings extends PreferenceActivity implements
private int mDemoStringIndex = 0;
private boolean mEnableDemo = false;
+ private boolean mVoicesMissing = false;
private TextToSpeech mTts = null;
@@ -278,16 +280,50 @@ public class TextToSpeechSettings extends PreferenceActivity implements
*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VOICE_DATA_INTEGRITY_CHECK) {
- if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
- Log.v(TAG, "Voice data check passed");
+ // TODO (clchen): Add these extras to TextToSpeech.Engine
+ ArrayList<String> available =
+ data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_AVAILABLE_VOICES");
+ ArrayList<String> unavailable =
+ data.getStringArrayListExtra("TextToSpeech.Engine.EXTRA_UNAVAILABLE_VOICES");
+
+ if (available.size() > 0){
if (mTts == null) {
mTts = new TextToSpeech(this, this);
}
+ ListPreference ttsLanguagePref =
+ (ListPreference) findPreference("tts_default_lang");
+ CharSequence[] entries = new CharSequence[available.size()];
+ CharSequence[] entryValues = new CharSequence[available.size()];
+ for (int i=0; i<available.size(); i++){
+ String[] langCountryVariant = available.get(i).split("-");
+ Locale loc = null;
+ if (langCountryVariant.length == 1){
+ loc = new Locale(langCountryVariant[0]);
+ } else if (langCountryVariant.length == 2){
+ loc = new Locale(langCountryVariant[0], langCountryVariant[1]);
+ } else if (langCountryVariant.length == 3){
+ loc = new Locale(langCountryVariant[0], langCountryVariant[1],
+ langCountryVariant[2]);
+ }
+ if (loc != null){
+ entries[i] = loc.getDisplayName();
+ entryValues[i] = available.get(i);
+ }
+ }
+ ttsLanguagePref.setEntries(entries);
+ ttsLanguagePref.setEntryValues(entryValues);
+ mEnableDemo = true;
} else {
- Log.v(TAG, "Voice data check failed");
mEnableDemo = false;
- updateWidgetState();
}
+
+ if (unavailable.size() > 0){
+ mVoicesMissing = true;
+ } else {
+ mVoicesMissing = false;
+ }
+
+ updateWidgetState();
} else if (requestCode == GET_SAMPLE_TEXT) {
if (resultCode == TextToSpeech.LANG_AVAILABLE) {
if (mTts != null) {
@@ -377,7 +413,7 @@ public class TextToSpeechSettings extends PreferenceActivity implements
mDefaultRatePref.setEnabled(mEnableDemo);
mDefaultLocPref.setEnabled(mEnableDemo);
- mInstallData.setEnabled(!mEnableDemo);
+ mInstallData.setEnabled(mVoicesMissing);
}