Merge "Refactor settings hierarchy and clump all volumes in one dialog."
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index 2edb328..611af04 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -45,7 +45,7 @@
private static final String PREFS_USE_LOCATION = "use_location";
// Vendor specific
- private static final String GSETTINGS_PROVIDER = "com.google.android.providers.settings";
+ private static final String GSETTINGS_PROVIDER = "com.google.settings";
private static final String LOCATION_CATEGORY = "location_category";
private static final String SETTINGS_CATEGORY = "settings_category";
private static final String USE_LOCATION = "use_location";
@@ -69,11 +69,7 @@
mBackup = (CheckBoxPreference) getPreferenceScreen().findPreference(BACKUP_SETTINGS);
// Vendor specific
- try {
- if (mUseLocation != null) {
- getPackageManager().getPackageInfo(GSETTINGS_PROVIDER, 0);
- }
- } catch (NameNotFoundException nnfe) {
+ if (getPackageManager().resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
getPreferenceScreen().removePreference(findPreference(LOCATION_CATEGORY));
getPreferenceScreen().removePreference(findPreference(SETTINGS_CATEGORY));
}
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 @@
* 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 @@
}
}
+ /**
+ * 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 @@
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 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) {