summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2010-01-25 14:04:41 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-01-25 14:04:41 -0800
commit0acb3777066c3bdf33e7e075a7155abb4f019d32 (patch)
tree9cdfe4ed221ed421309b248f1690b74a111b0e85 /src/com
parentedc585b644192377e40e75c41fa5b66646696dd3 (diff)
parent4df6c79f412a89ec69ccd4c5ee802eef699466d4 (diff)
downloadpackages_apps_Settings-0acb3777066c3bdf33e7e075a7155abb4f019d32.zip
packages_apps_Settings-0acb3777066c3bdf33e7e075a7155abb4f019d32.tar.gz
packages_apps_Settings-0acb3777066c3bdf33e7e075a7155abb4f019d32.tar.bz2
Merge "Changing TextToSpeechSettings to query for the sample text strings provided by plugins rather than using hardcoded sample text."
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/TextToSpeechSettings.java42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index edc09e6..838d978 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -92,6 +92,7 @@ public class TextToSpeechSettings extends PreferenceActivity implements
* startActivityForResult.
*/
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
+ private static final int GET_SAMPLE_TEXT = 1983;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -230,6 +231,30 @@ public class TextToSpeechSettings extends PreferenceActivity implements
}
}
+ /**
+ * Ask the current default engine to return a string of sample text to be
+ * spoken to the user.
+ */
+ private void getSampleText() {
+ PackageManager pm = getPackageManager();
+ Intent intent = new Intent();
+ // TODO (clchen): Replace Intent string with the actual
+ // Intent defined in the list of platform Intents.
+ intent.setAction("android.speech.tts.engine.GET_SAMPLE_TEXT");
+ intent.putExtra("language", mDefaultLanguage);
+ intent.putExtra("country", mDefaultCountry);
+ intent.putExtra("variant", mDefaultLocVariant);
+ List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, 0);
+ // query only the package that matches that of the default engine
+ for (int i = 0; i < resolveInfos.size(); i++) {
+ ActivityInfo currentActivityInfo = resolveInfos.get(i).activityInfo;
+ if (mDefaultEng.equals(currentActivityInfo.packageName)) {
+ intent.setClassName(mDefaultEng, currentActivityInfo.name);
+ this.startActivityForResult(intent, GET_SAMPLE_TEXT);
+ }
+ }
+ }
+
/**
* Called when the TTS engine is initialized.
@@ -263,6 +288,16 @@ public class TextToSpeechSettings extends PreferenceActivity implements
mEnableDemo = false;
updateWidgetState();
}
+ } else if (requestCode == GET_SAMPLE_TEXT) {
+ if (resultCode == TextToSpeech.LANG_AVAILABLE) {
+ if (mTts != null) {
+ String sample = data.getExtras().getString("sampleText");
+ mTts.speak(sample, TextToSpeech.QUEUE_FLUSH, null);
+ }
+ } else {
+ // TODO: Display an error here to the user.
+ Log.e(TAG, "Did not have a sample string for the requested language");
+ }
}
}
@@ -321,10 +356,9 @@ public class TextToSpeechSettings extends PreferenceActivity implements
*/
public boolean onPreferenceClick(Preference preference) {
if (preference == mPlayExample) {
- // Play example
- if (mTts != null) {
- mTts.speak(mDemoStrings[mDemoStringIndex], TextToSpeech.QUEUE_FLUSH, null);
- }
+ // Get the sample text from the TTS engine; onActivityResult will do
+ // the actual speaking
+ getSampleText();
return true;
}
if (preference == mInstallData) {