am 517ce789
: Merge change 5374 into donut
Merge commit '517ce789b4c624c6e15b9f6ca2f5757396315247' * commit '517ce789b4c624c6e15b9f6ca2f5757396315247': Remove pitch selection from TTS settings.
This commit is contained in:
committed by
The Android Open Source Project
commit
49d2e2d695
@@ -46,14 +46,6 @@
|
|||||||
android:entries="@array/tts_rate_entries"
|
android:entries="@array/tts_rate_entries"
|
||||||
android:entryValues="@array/tts_rate_values" />
|
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
|
<ListPreference
|
||||||
android:key="tts_default_lang"
|
android:key="tts_default_lang"
|
||||||
android:title="@string/tts_default_lang_title"
|
android:title="@string/tts_default_lang_title"
|
||||||
|
@@ -18,10 +18,10 @@ package com.android.settings;
|
|||||||
|
|
||||||
import static android.provider.Settings.Secure.TTS_USE_DEFAULTS;
|
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_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_LANG;
|
||||||
import static android.provider.Settings.Secure.TTS_DEFAULT_COUNTRY;
|
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_VARIANT;
|
||||||
|
import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -51,7 +51,6 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
private static final String KEY_TTS_INSTALL_DATA = "tts_install_data";
|
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_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_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_LANG = "tts_default_lang";
|
||||||
private static final String KEY_TTS_DEFAULT_COUNTRY = "tts_default_country";
|
private static final String KEY_TTS_DEFAULT_COUNTRY = "tts_default_country";
|
||||||
private static final String KEY_TTS_DEFAULT_VARIANT = "tts_default_variant";
|
private static final String KEY_TTS_DEFAULT_VARIANT = "tts_default_variant";
|
||||||
@@ -65,7 +64,6 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
private Preference mInstallData = null;
|
private Preference mInstallData = null;
|
||||||
private CheckBoxPreference mUseDefaultPref = null;
|
private CheckBoxPreference mUseDefaultPref = null;
|
||||||
private ListPreference mDefaultRatePref = null;
|
private ListPreference mDefaultRatePref = null;
|
||||||
private ListPreference mDefaultPitchPref = null;
|
|
||||||
private ListPreference mDefaultLocPref = null;
|
private ListPreference mDefaultLocPref = null;
|
||||||
private String mDefaultLanguage = null;
|
private String mDefaultLanguage = null;
|
||||||
private String mDefaultCountry = null;
|
private String mDefaultCountry = null;
|
||||||
@@ -81,6 +79,11 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
* startActivityForResult.
|
* startActivityForResult.
|
||||||
*/
|
*/
|
||||||
private static final int VOICE_DATA_INTEGRITY_CHECK = 1977;
|
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
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -88,6 +91,7 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
|
|
||||||
addPreferencesFromResource(R.xml.tts_settings);
|
addPreferencesFromResource(R.xml.tts_settings);
|
||||||
|
|
||||||
|
mEnableDemo = false;
|
||||||
initClickers();
|
initClickers();
|
||||||
initDefaultSettings();
|
initDefaultSettings();
|
||||||
}
|
}
|
||||||
@@ -99,7 +103,6 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
// whenever we return to this screen, we don't know the state of the
|
// 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.
|
// 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
|
// TODO make the TTS service listen to "changes in the system", i.e. sd card un/mount
|
||||||
mEnableDemo = false;
|
|
||||||
initClickers();
|
initClickers();
|
||||||
updateWidgetState();
|
updateWidgetState();
|
||||||
checkVoiceData();
|
checkVoiceData();
|
||||||
@@ -144,7 +147,13 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
mUseDefaultPref.setOnPreferenceChangeListener(this);
|
mUseDefaultPref.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
// Default engine
|
// 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
|
// Default rate
|
||||||
mDefaultRatePref = (ListPreference) findPreference(KEY_TTS_DEFAULT_RATE);
|
mDefaultRatePref = (ListPreference) findPreference(KEY_TTS_DEFAULT_RATE);
|
||||||
@@ -158,26 +167,13 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
mDefaultRatePref.setValue(String.valueOf(intVal));
|
mDefaultRatePref.setValue(String.valueOf(intVal));
|
||||||
mDefaultRatePref.setOnPreferenceChangeListener(this);
|
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
|
// Default language / country / variant : these three values map to a single ListPref
|
||||||
// representing the matching Locale
|
// representing the matching Locale
|
||||||
String language = null;
|
String language = null;
|
||||||
String country = null;
|
String country = null;
|
||||||
String variant = null;
|
String variant = null;
|
||||||
mDefaultLocPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_LANG);
|
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) {
|
if (language != null) {
|
||||||
mDefaultLanguage = language;
|
mDefaultLanguage = language;
|
||||||
} else {
|
} else {
|
||||||
@@ -185,9 +181,9 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
language = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_LANG;
|
language = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_LANG;
|
||||||
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
|
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
|
||||||
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
|
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
|
||||||
Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_LANG, language);
|
Settings.Secure.putString(resolver, TTS_DEFAULT_LANG, language);
|
||||||
Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_COUNTRY, country);
|
Settings.Secure.putString(resolver, TTS_DEFAULT_COUNTRY, country);
|
||||||
Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_VARIANT, variant);
|
Settings.Secure.putString(resolver, TTS_DEFAULT_VARIANT, variant);
|
||||||
}
|
}
|
||||||
if (country == null) {
|
if (country == null) {
|
||||||
// country wasn't initialized yet because a default language was found
|
// country wasn't initialized yet because a default language was found
|
||||||
@@ -198,8 +194,8 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
// default country setting not found, initialize it, as well as the variant;
|
// default country setting not found, initialize it, as well as the variant;
|
||||||
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
|
country = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_COUNTRY;
|
||||||
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
|
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
|
||||||
Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_COUNTRY, country);
|
Settings.Secure.putString(resolver, TTS_DEFAULT_COUNTRY, country);
|
||||||
Settings.Secure.putString(resolver, KEY_TTS_DEFAULT_VARIANT, variant);
|
Settings.Secure.putString(resolver, TTS_DEFAULT_VARIANT, variant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (variant == null) {
|
if (variant == null) {
|
||||||
@@ -210,7 +206,7 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
} else {
|
} else {
|
||||||
// default variant setting not found, initialize it
|
// default variant setting not found, initialize it
|
||||||
variant = TextToSpeech.Engine.FALLBACK_TTS_DEFAULT_VARIANT;
|
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
|
// we now have the default lang/country/variant trio, build a string value from it
|
||||||
@@ -230,6 +226,10 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
private void checkVoiceData() {
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@@ -246,6 +246,26 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Called when the TTS engine is initialized.
|
||||||
*/
|
*/
|
||||||
@@ -273,7 +293,8 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "Voice data check failed");
|
Log.v(TAG, "Voice data check failed");
|
||||||
|
mEnableDemo = false;
|
||||||
|
updateWidgetState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,16 +320,6 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.e(TAG, "could not persist default TTS rate setting", 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())) {
|
} else if (KEY_TTS_DEFAULT_LANG.equals(preference.getKey())) {
|
||||||
// Default locale
|
// Default locale
|
||||||
ContentResolver resolver = getContentResolver();
|
ContentResolver resolver = getContentResolver();
|
||||||
@@ -337,9 +348,9 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (preference == mInstallData) {
|
if (preference == mInstallData) {
|
||||||
// Install data
|
installVoiceData();
|
||||||
// TODO launch request for installer
|
// quit this activity so it needs to be restarted after installation of the voice data
|
||||||
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -350,7 +361,6 @@ public class TextToSpeechSettings extends PreferenceActivity implements
|
|||||||
mPlayExample.setEnabled(mEnableDemo);
|
mPlayExample.setEnabled(mEnableDemo);
|
||||||
mUseDefaultPref.setEnabled(mEnableDemo);
|
mUseDefaultPref.setEnabled(mEnableDemo);
|
||||||
mDefaultRatePref.setEnabled(mEnableDemo);
|
mDefaultRatePref.setEnabled(mEnableDemo);
|
||||||
mDefaultPitchPref.setEnabled(mEnableDemo);
|
|
||||||
mDefaultLocPref.setEnabled(mEnableDemo);
|
mDefaultLocPref.setEnabled(mEnableDemo);
|
||||||
|
|
||||||
mInstallData.setEnabled(!mEnableDemo);
|
mInstallData.setEnabled(!mEnableDemo);
|
||||||
|
Reference in New Issue
Block a user