Merge change 5391 into donut
* changes:
Fix an NPE.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 63b343d..5df6cf5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1457,7 +1457,7 @@
<string name="quick_launch_no_shortcut">No shortcut</string>
<!-- On the Quick launch settings screen, summary text under the item for each assigned letter. -->
<string name="quick_launch_shortcut">Search + <xliff:g id="shortcut_letter">%1$s</xliff:g></string>
- <!-- On the Quick launch settings screen, title of "Clear shortcut" confirmation dialog. This is reached by longpressing an item for a shortcut letter. This allows the user to clear the assigned applicatino for that shortcut letter. -->
+ <!-- On the Quick launch settings screen, title of "Clear shortcut" confirmation dialog. This is reached by longpressing an item for a shortcut letter. This allows the user to clear the assigned application for that shortcut letter. -->
<string name="quick_launch_clear_dialog_title">Clear</string>
<!-- On the Quick launch settings screen, message in the "Clear shortcut" confirmation dialog. See the title for this dialog for more info. -->
<string name="quick_launch_clear_dialog_message">Your shortcut for <xliff:g id="shortcut_letter">%1$s</xliff:g> (<xliff:g id="application_name">%2$s</xliff:g>) will be cleared.</string>
@@ -1498,6 +1498,10 @@
<string name="allow_mock_location">Allow mock locations</string>
<!-- setting Checkbox summary whether to allow mock locations -->
<string name="allow_mock_location_summary">Allow mock locations</string>
+ <!-- Title of warning dialog about the implications of enabling USB debugging -->
+ <string name="adb_warning_title">Enable USB debugging?</string>
+ <!-- Warning text to user about the implications of enabling USB debugging -->
+ <string name="adb_warning_message">USB debugging is intended for development purposes only. It can be used to copy data between your computer and your device, install applications on your device without notification, and read log data.</string>
<!-- Title for the screen that lets the user choose a gadget to add to the home screen
(or other screens that can host gadgets). Note to translators: we're still determining
diff --git a/res/xml/tts_settings.xml b/res/xml/tts_settings.xml
index 4ec2a4d..d94d575 100644
--- a/res/xml/tts_settings.xml
+++ b/res/xml/tts_settings.xml
@@ -45,14 +45,6 @@
android:persistent="false"
android:entries="@array/tts_rate_entries"
android:entryValues="@array/tts_rate_values" />
-
- <ListPreference
- android:key="tts_default_pitch"
- android:title="@string/tts_default_pitch_title"
- android:summary="@string/tts_default_pitch_summary"
- android:persistent="false"
- android:entries="@array/tts_pitch_entries"
- android:entryValues="@array/tts_pitch_values" />
<ListPreference
android:key="tts_default_lang"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 155f085..c1da18a 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -16,6 +16,8 @@
package com.android.settings;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.SystemProperties;
@@ -29,7 +31,8 @@
/*
* Displays preferences for application developers.
*/
-public class DevelopmentSettings extends PreferenceActivity {
+public class DevelopmentSettings extends PreferenceActivity
+ implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
private static final String ENABLE_ADB = "enable_adb";
private static final String KEEP_SCREEN_ON = "keep_screen_on";
@@ -39,6 +42,9 @@
private CheckBoxPreference mKeepScreenOn;
private CheckBoxPreference mAllowMockLocation;
+ // To track whether Yes was clicked in the adb warning dialog
+ private boolean mOkClicked;
+
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -72,8 +78,19 @@
}
if (preference == mEnableAdb) {
- Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED,
- mEnableAdb.isChecked() ? 1 : 0);
+ if (mEnableAdb.isChecked()) {
+ mOkClicked = false;
+ new AlertDialog.Builder(this).setMessage(
+ getResources().getString(R.string.adb_warning_message))
+ .setTitle(R.string.adb_warning_title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setPositiveButton(android.R.string.yes, this)
+ .setNegativeButton(android.R.string.no, this)
+ .show()
+ .setOnDismissListener(this);
+ } else {
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
+ }
} else if (preference == mKeepScreenOn) {
Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN,
mKeepScreenOn.isChecked() ?
@@ -85,4 +102,21 @@
return false;
}
+
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ mOkClicked = true;
+ Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 1);
+ } else {
+ // Reset the toggle
+ mEnableAdb.setChecked(false);
+ }
+ }
+
+ public void onDismiss(DialogInterface dialog) {
+ // Assuming that onClick gets called first
+ if (!mOkClicked) {
+ mEnableAdb.setChecked(false);
+ }
+ }
}
diff --git a/src/com/android/settings/TextToSpeechSettings.java b/src/com/android/settings/TextToSpeechSettings.java
index f77913f..94b256f 100644
--- a/src/com/android/settings/TextToSpeechSettings.java
+++ b/src/com/android/settings/TextToSpeechSettings.java
@@ -18,10 +18,10 @@
import static android.provider.Settings.Secure.TTS_USE_DEFAULTS;
import static android.provider.Settings.Secure.TTS_DEFAULT_RATE;
-import static android.provider.Settings.Secure.TTS_DEFAULT_PITCH;
import static android.provider.Settings.Secure.TTS_DEFAULT_LANG;
import static android.provider.Settings.Secure.TTS_DEFAULT_COUNTRY;
import static android.provider.Settings.Secure.TTS_DEFAULT_VARIANT;
+import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
import android.content.ContentResolver;
import android.content.Intent;
@@ -51,7 +51,6 @@
private static final String KEY_TTS_INSTALL_DATA = "tts_install_data";
private static final String KEY_TTS_USE_DEFAULT = "toggle_use_default_tts_settings";
private static final String KEY_TTS_DEFAULT_RATE = "tts_default_rate";
- private static final String KEY_TTS_DEFAULT_PITCH = "tts_default_pitch";
private static final String KEY_TTS_DEFAULT_LANG = "tts_default_lang";
private static final String KEY_TTS_DEFAULT_COUNTRY = "tts_default_country";
private static final String KEY_TTS_DEFAULT_VARIANT = "tts_default_variant";
@@ -65,7 +64,6 @@
private Preference mInstallData = null;
private CheckBoxPreference mUseDefaultPref = null;
private ListPreference mDefaultRatePref = null;
- private ListPreference mDefaultPitchPref = null;
private ListPreference mDefaultLocPref = null;
private String mDefaultLanguage = null;
private String mDefaultCountry = null;
@@ -81,6 +79,11 @@
* startActivityForResult.
*/
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
+ /**
+ * Request code (arbitrary value) for voice data installation through
+ * startActivityForResult.
+ */
+ private static final int VOICE_DATA_INSTALLATION = 1980;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -88,6 +91,7 @@
addPreferencesFromResource(R.xml.tts_settings);
+ mEnableDemo = false;
initClickers();
initDefaultSettings();
}
@@ -99,7 +103,6 @@
// whenever we return to this screen, we don't know the state of the
// system, so we have to recheck that we can play the demo, or it must be disabled.
// TODO make the TTS service listen to "changes in the system", i.e. sd card un/mount
- mEnableDemo = false;
initClickers();
updateWidgetState();
checkVoiceData();
@@ -144,7 +147,13 @@
mUseDefaultPref.setOnPreferenceChangeListener(this);
// Default engine
- mDefaultEng = FALLBACK_TTS_DEFAULT_SYNTH;
+ String engine = Settings.Secure.getString(resolver, TTS_DEFAULT_SYNTH);
+ if (engine == null) {
+ // TODO move FALLBACK_TTS_DEFAULT_SYNTH to TextToSpeech
+ engine = FALLBACK_TTS_DEFAULT_SYNTH;
+ Settings.Secure.putString(resolver, TTS_DEFAULT_SYNTH, engine);
+ }
+ mDefaultEng = engine;
// Default rate
mDefaultRatePref = (ListPreference) findPreference(KEY_TTS_DEFAULT_RATE);
@@ -158,26 +167,13 @@
mDefaultRatePref.setValue(String.valueOf(intVal));
mDefaultRatePref.setOnPreferenceChangeListener(this);
- // Default pitch
- mDefaultPitchPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_PITCH);
- try {
- intVal = Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH);
- } catch (SettingNotFoundException e) {
- // default pitch setting not found, initialize it
- intVal = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_PITCH;
- Settings.Secure.putInt(resolver, TTS_DEFAULT_PITCH, intVal);
- }
- mDefaultPitchPref.setValue(String.valueOf(intVal));
- mDefaultPitchPref.setOnPreferenceChangeListener(this);
-
-
// Default language / country / variant : these three values map to a single ListPref
// representing the matching Locale
String language = null;
String country = null;
String variant = null;
mDefaultLocPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_LANG);
- language = Settings.Secure.getString(resolver, KEY_TTS_DEFAULT_LANG);
+ language = Settings.Secure.getString(resolver, TTS_DEFAULT_LANG);
if (language != null) {
mDefaultLanguage = language;
} else {
@@ -185,9 +181,9 @@
language = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_LANG;
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_LANG, language);
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_COUNTRY, country);
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_VARIANT, variant);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_LANG, language);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_COUNTRY, country);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_VARIANT, variant);
}
if (country == null) {
// country wasn't initialized yet because a default language was found
@@ -198,8 +194,8 @@
// default country setting not found, initialize it, as well as the variant;
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_COUNTRY, country);
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_VARIANT, variant);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_COUNTRY, country);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_VARIANT, variant);
}
}
if (variant == null) {
@@ -210,7 +206,7 @@
} else {
// default variant setting not found, initialize it
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
- Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_VARIANT, variant);
+ Settings.Secure.putString(resolver, TTS_DEFAULT_VARIANT, variant);
}
}
// we now have the default lang/country/variant trio, build a string value from it
@@ -230,6 +226,10 @@
}
+ /**
+ * Ask the current default engine to launch the matching CHECK_TTS_DATA activity
+ * to check the required TTS files are properly installed.
+ */
private void checkVoiceData() {
PackageManager pm = getPackageManager();
Intent intent = new Intent();
@@ -247,6 +247,26 @@
/**
+ * Ask the current default engine to launch the matching INSTALL_TTS_DATA activity
+ * so the required TTS files are properly installed.
+ */
+ private void installVoiceData() {
+ PackageManager pm = getPackageManager();
+ Intent intent = new Intent();
+ intent.setAction("android.intent.action.INSTALL_TTS_DATA");
+ 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, VOICE_DATA_INSTALLATION);
+ }
+ }
+ }
+
+
+ /**
* Called when the TTS engine is initialized.
*/
public void onInit(int status) {
@@ -273,7 +293,8 @@
}
} else {
Log.v(TAG, "Voice data check failed");
-
+ mEnableDemo = false;
+ updateWidgetState();
}
}
}
@@ -299,16 +320,6 @@
} catch (NumberFormatException e) {
Log.e(TAG, "could not persist default TTS rate setting", e);
}
- } else if (KEY_TTS_DEFAULT_PITCH.equals(preference.getKey())) {
- // Default pitch
- int value = Integer.parseInt((String) objValue);
- try {
- Settings.Secure.putInt(getContentResolver(),
- TTS_DEFAULT_PITCH, value);
- Log.i(TAG, "TTS default pitch is "+value);
- } catch (NumberFormatException e) {
- Log.e(TAG, "could not persist default TTS pitch setting", e);
- }
} else if (KEY_TTS_DEFAULT_LANG.equals(preference.getKey())) {
// Default locale
ContentResolver resolver = getContentResolver();
@@ -337,9 +348,9 @@
return true;
}
if (preference == mInstallData) {
- // Install data
- // TODO launch request for installer
-
+ installVoiceData();
+ // quit this activity so it needs to be restarted after installation of the voice data
+ finish();
return true;
}
return false;
@@ -350,7 +361,6 @@
mPlayExample.setEnabled(mEnableDemo);
mUseDefaultPref.setEnabled(mEnableDemo);
mDefaultRatePref.setEnabled(mEnableDemo);
- mDefaultPitchPref.setEnabled(mEnableDemo);
mDefaultLocPref.setEnabled(mEnableDemo);
mInstallData.setEnabled(!mEnableDemo);