Text to speech settings UI change.
No more separate checkboxes for each of the engines. This brings it more in line with the voice recognition settings. The user is shown a data warning every time he chooses a non system engine as the default. Change-Id: I00fcb9c9f634a9fc13ff14da8bfade79ae6727c4
This commit is contained in:
@@ -2878,6 +2878,14 @@ found in the list of installed applications.</string>
|
|||||||
<string name="tts_engine_name_is_enabled_summary"><xliff:g id="tts_plugin_engine_name">%s</xliff:g> is enabled</string>
|
<string name="tts_engine_name_is_enabled_summary"><xliff:g id="tts_plugin_engine_name">%s</xliff:g> is enabled</string>
|
||||||
<!-- On main TTS Settings screen, text preceded by the TTS engine name to indicate the engine cannot be used by the user -->
|
<!-- On main TTS Settings screen, text preceded by the TTS engine name to indicate the engine cannot be used by the user -->
|
||||||
<string name="tts_engine_name_is_disabled_summary"><xliff:g id="tts_plugin_engine_name">%s</xliff:g> is disabled</string>
|
<string name="tts_engine_name_is_disabled_summary"><xliff:g id="tts_plugin_engine_name">%s</xliff:g> is disabled</string>
|
||||||
|
<!-- On the main TTS settings screen, text for a divider under which
|
||||||
|
the engine specific settings and the "engine install data" option
|
||||||
|
are listed [CHAR LIMIT=30]-->
|
||||||
|
<string name="tts_engine_settings_section">Engine settings</string>
|
||||||
|
<!-- Title for a preference in the main TTS settings screen, which
|
||||||
|
launches the settings screen for a given TTS engine when clicked
|
||||||
|
[CHAR LIMIT=30]-->
|
||||||
|
<string name="tts_engine_settings_title">Settings for <xliff:g id="tts_engine_name">%s</xliff:g></string>
|
||||||
<!-- On Pico TTS Settings screen, text to mark the section for the various languages and voices that are available -->
|
<!-- On Pico TTS Settings screen, text to mark the section for the various languages and voices that are available -->
|
||||||
<string name="pico_languages_and_voices">Languages and voices</string>
|
<string name="pico_languages_and_voices">Languages and voices</string>
|
||||||
<!-- On Pico TTS Settings screen, text to mark a voice as installed -->
|
<!-- On Pico TTS Settings screen, text to mark a voice as installed -->
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -18,17 +18,11 @@
|
|||||||
android:title="@string/tts_settings_title">
|
android:title="@string/tts_settings_title">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="tts_play_example"
|
android:key="tts_play_example"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/tts_play_example_title"
|
android:title="@string/tts_play_example_title"
|
||||||
android:summary="@string/tts_play_example_summary" />
|
android:summary="@string/tts_play_example_summary" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="toggle_use_default_tts_settings"
|
|
||||||
android:title="@string/use_default_tts_settings_title"
|
|
||||||
android:summary="@string/use_default_tts_settings_summary"
|
|
||||||
android:persistent="false" />
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/tts_default_settings_section">
|
android:title="@string/tts_default_settings_section">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
@@ -39,12 +33,6 @@
|
|||||||
android:entries="@array/tts_engine_entries"
|
android:entries="@array/tts_engine_entries"
|
||||||
android:entryValues="@array/tts_engine_values" />
|
android:entryValues="@array/tts_engine_values" />
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:key="tts_install_data"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/tts_install_data_title"
|
|
||||||
android:summary="@string/tts_install_data_summary" />
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="tts_default_rate"
|
android:key="tts_default_rate"
|
||||||
android:title="@string/tts_default_rate_title"
|
android:title="@string/tts_default_rate_title"
|
||||||
@@ -63,8 +51,19 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:key="tts_engines_section"
|
<PreferenceCategory android:key="tts_engine_settings_section"
|
||||||
android:title="@string/tts_engines_section" />
|
android:title="@string/tts_engine_settings_section">
|
||||||
|
<Preference
|
||||||
|
android:key="tts_engine_settings"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/tts_engine_settings_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="tts_install_data"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/tts_install_data_title"
|
||||||
|
android:summary="@string/tts_install_data_summary" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import static android.provider.Settings.Secure.TTS_DEFAULT_LANG;
|
|||||||
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_SYNTH;
|
import static android.provider.Settings.Secure.TTS_DEFAULT_SYNTH;
|
||||||
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_ENABLED_PLUGINS;
|
|
||||||
import static android.provider.Settings.Secure.TTS_USE_DEFAULTS;
|
import static android.provider.Settings.Secure.TTS_USE_DEFAULTS;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -32,7 +31,6 @@ import android.content.DialogInterface;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
@@ -64,7 +62,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
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";
|
||||||
private static final String KEY_TTS_DEFAULT_SYNTH = "tts_default_synth";
|
private static final String KEY_TTS_DEFAULT_SYNTH = "tts_default_synth";
|
||||||
private static final String KEY_TTS_ENGINES = "tts_engines_section";
|
private static final String KEY_TTS_ENGINE_SETTINGS = "tts_engine_settings";
|
||||||
|
|
||||||
private static final String KEY_PLUGIN_ENABLED_PREFIX = "ENABLED_";
|
private static final String KEY_PLUGIN_ENABLED_PREFIX = "ENABLED_";
|
||||||
private static final String KEY_PLUGIN_SETTINGS_PREFIX = "SETTINGS_";
|
private static final String KEY_PLUGIN_SETTINGS_PREFIX = "SETTINGS_";
|
||||||
@@ -76,13 +74,14 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
private static final String LOCALE_DELIMITER = "-";
|
private static final String LOCALE_DELIMITER = "-";
|
||||||
|
|
||||||
private Preference mPlayExample = null;
|
private Preference mPlayExample = null;
|
||||||
private Preference mInstallData = null;
|
|
||||||
private CheckBoxPreference mUseDefaultPref = null;
|
private ListPreference mDefaultRatePref = null;
|
||||||
private ListPreference mDefaultRatePref = null;
|
private ListPreference mDefaultLocPref = null;
|
||||||
private ListPreference mDefaultLocPref = null;
|
private ListPreference mDefaultSynthPref = null;
|
||||||
private ListPreference mDefaultSynthPref = null;
|
|
||||||
private PreferenceGroup mEnginesGroup;
|
private Preference mInstallData = null;
|
||||||
|
private Preference mEngineSettings = null;
|
||||||
|
|
||||||
private String mDefaultLanguage = null;
|
private String mDefaultLanguage = null;
|
||||||
private String mDefaultCountry = null;
|
private String mDefaultCountry = null;
|
||||||
@@ -127,18 +126,18 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
mInstallData = findPreference(KEY_TTS_INSTALL_DATA);
|
mInstallData = findPreference(KEY_TTS_INSTALL_DATA);
|
||||||
mInstallData.setOnPreferenceClickListener(this);
|
mInstallData.setOnPreferenceClickListener(this);
|
||||||
|
|
||||||
mUseDefaultPref = (CheckBoxPreference) findPreference(KEY_TTS_USE_DEFAULT);
|
|
||||||
mDefaultSynthPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_SYNTH);
|
mDefaultSynthPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_SYNTH);
|
||||||
mDefaultRatePref = (ListPreference) findPreference(KEY_TTS_DEFAULT_RATE);
|
mDefaultRatePref = (ListPreference) findPreference(KEY_TTS_DEFAULT_RATE);
|
||||||
mDefaultLocPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_LANG);
|
mDefaultLocPref = (ListPreference) findPreference(KEY_TTS_DEFAULT_LANG);
|
||||||
|
|
||||||
mEnginesGroup = (PreferenceGroup) findPreference(KEY_TTS_ENGINES);
|
mEngineSettings = (Preference) findPreference(KEY_TTS_ENGINE_SETTINGS);
|
||||||
|
mEngineSettings.setEnabled(false);
|
||||||
|
|
||||||
mTts = new TextToSpeech(getActivity().getApplicationContext(), this);
|
mTts = new TextToSpeech(getActivity().getApplicationContext(), this);
|
||||||
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
|
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
|
||||||
|
|
||||||
initDefaultSettings();
|
initDefaultSettings();
|
||||||
addEngineSpecificSettings();
|
initEngineSpecificSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,39 +174,27 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEngineSpecificSettings() {
|
private void initEngineSpecificSettings() {
|
||||||
Context context = getActivity();
|
final String engineName = mEnginesHelper.getDefaultEngine();
|
||||||
List<EngineInfo> engines = mTts.getEngines();
|
final EngineInfo engine = mEnginesHelper.getEngineInfo(engineName);
|
||||||
for (EngineInfo engine : engines) {
|
|
||||||
final String engineName = engine.name;
|
|
||||||
if (!engine.system) {
|
|
||||||
CheckBoxPreference enablePref = new CheckBoxPreference(context);
|
|
||||||
enablePref.setKey(KEY_PLUGIN_ENABLED_PREFIX + engineName);
|
|
||||||
enablePref.setTitle(engine.label);
|
|
||||||
enablePref.setOnPreferenceClickListener(this);
|
|
||||||
mEnginesGroup.addPreference(enablePref);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (engineHasSettings(engineName)) {
|
mEngineSettings.setTitle(getResources().getString(R.string.tts_engine_settings_title,
|
||||||
Preference pref = new Preference(context);
|
engine.label));
|
||||||
pref.setKey(KEY_PLUGIN_SETTINGS_PREFIX + engineName);
|
|
||||||
pref.setTitle(engine.label);
|
if (engineHasSettings(engineName)) {
|
||||||
CharSequence settingsLabel = getResources().getString(
|
mEngineSettings.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
R.string.tts_engine_name_settings, engine.label);
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
pref.setSummary(settingsLabel);
|
Intent i = new Intent();
|
||||||
// TODO: Add a new API for this.
|
i.setClassName(engineName, engineName + ".EngineSettings");
|
||||||
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
startActivity(i);
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
return true;
|
||||||
Intent i = new Intent();
|
}
|
||||||
i.setClassName(engineName,
|
});
|
||||||
engineName + ".EngineSettings");
|
mEngineSettings.setEnabled(true);
|
||||||
startActivity(i);
|
} else {
|
||||||
return true;
|
mEngineSettings.setEnabled(false);
|
||||||
}
|
|
||||||
});
|
|
||||||
mEnginesGroup.addPreference(pref);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean engineHasSettings(String enginePackageName) {
|
private boolean engineHasSettings(String enginePackageName) {
|
||||||
@@ -226,12 +213,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
// Find the default TTS values in the settings, initialize and store the
|
// Find the default TTS values in the settings, initialize and store the
|
||||||
// settings if they are not found.
|
// settings if they are not found.
|
||||||
|
|
||||||
// "Use Defaults"
|
|
||||||
int useDefault = Settings.Secure.getInt(resolver, TTS_USE_DEFAULTS,
|
|
||||||
TextToSpeech.Engine.USE_DEFAULTS);
|
|
||||||
mUseDefaultPref.setChecked(useDefault == 1);
|
|
||||||
mUseDefaultPref.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
// Default synthesis engine
|
// Default synthesis engine
|
||||||
loadEngines();
|
loadEngines();
|
||||||
mDefaultSynthPref.setOnPreferenceChangeListener(this);
|
mDefaultSynthPref.setOnPreferenceChangeListener(this);
|
||||||
@@ -301,6 +282,7 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
intent.putExtra("country", mDefaultCountry);
|
intent.putExtra("country", mDefaultCountry);
|
||||||
intent.putExtra("variant", mDefaultLocVariant);
|
intent.putExtra("variant", mDefaultLocVariant);
|
||||||
intent.setPackage(defaultEngine);
|
intent.setPackage(defaultEngine);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Log.v(TAG, "Getting sample text: " + intent.toUri(0));
|
Log.v(TAG, "Getting sample text: " + intent.toUri(0));
|
||||||
startActivityForResult(intent, GET_SAMPLE_TEXT);
|
startActivityForResult(intent, GET_SAMPLE_TEXT);
|
||||||
@@ -504,16 +486,21 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
Log.v(TAG, " selected is " + newIndex);
|
Log.v(TAG, " selected is " + newIndex);
|
||||||
mDemoStringIndex = newIndex > -1 ? newIndex : 0;
|
mDemoStringIndex = newIndex > -1 ? newIndex : 0;
|
||||||
} else if (KEY_TTS_DEFAULT_SYNTH.equals(preference.getKey())) {
|
} else if (KEY_TTS_DEFAULT_SYNTH.equals(preference.getKey())) {
|
||||||
String defaultEng = objValue.toString();
|
final String name = objValue.toString();
|
||||||
Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, defaultEng);
|
final EngineInfo info = mEnginesHelper.getEngineInfo(name);
|
||||||
if (mTts != null) {
|
|
||||||
mTts.setEngineByPackageName(defaultEng);
|
if (info.system) {
|
||||||
mEnableDemo = false;
|
// For system engines, do away with the alert dialog.
|
||||||
mVoicesMissing = false;
|
updateDefaultEngine(name);
|
||||||
updateWidgetState();
|
initEngineSpecificSettings();
|
||||||
checkVoiceData();
|
} else {
|
||||||
|
// For all other engines, display a warning message before
|
||||||
|
// turning them on.
|
||||||
|
displayDataAlert(preference, name);
|
||||||
}
|
}
|
||||||
Log.v(TAG, "The default synth is: " + objValue.toString());
|
|
||||||
|
// We'll deal with updating the UI ourselves.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -534,42 +521,13 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
// quit this activity so it needs to be restarted after installation of the voice data
|
// quit this activity so it needs to be restarted after installation of the voice data
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
} else if (preference.getKey().startsWith(KEY_PLUGIN_ENABLED_PREFIX)) {
|
|
||||||
final CheckBoxPreference chkPref = (CheckBoxPreference) preference;
|
|
||||||
if (chkPref.isChecked()) {
|
|
||||||
chkPref.setChecked(false);
|
|
||||||
AlertDialog d = (new AlertDialog.Builder(getActivity()))
|
|
||||||
.setTitle(android.R.string.dialog_alert_title)
|
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
||||||
.setMessage(
|
|
||||||
getActivity().getString(R.string.tts_engine_security_warning,
|
|
||||||
chkPref.getTitle()))
|
|
||||||
.setCancelable(true)
|
|
||||||
.setPositiveButton(android.R.string.ok,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
chkPref.setChecked(true);
|
|
||||||
loadEngines();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
d.show();
|
|
||||||
} else {
|
|
||||||
loadEngines();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateWidgetState() {
|
private void updateWidgetState() {
|
||||||
mPlayExample.setEnabled(mEnableDemo);
|
mPlayExample.setEnabled(mEnableDemo);
|
||||||
mUseDefaultPref.setEnabled(mEnableDemo);
|
|
||||||
mDefaultRatePref.setEnabled(mEnableDemo);
|
mDefaultRatePref.setEnabled(mEnableDemo);
|
||||||
mDefaultLocPref.setEnabled(mEnableDemo);
|
mDefaultLocPref.setEnabled(mEnableDemo);
|
||||||
|
|
||||||
@@ -582,14 +540,18 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
mDefaultLanguage = "";
|
mDefaultLanguage = "";
|
||||||
mDefaultCountry = "";
|
mDefaultCountry = "";
|
||||||
mDefaultLocVariant = "";
|
mDefaultLocVariant = "";
|
||||||
if (tokenizer.hasMoreTokens()) {
|
|
||||||
mDefaultLanguage = tokenizer.nextToken().trim();
|
if (locale != null) {
|
||||||
}
|
String[] components = locale.split(LOCALE_DELIMITER);
|
||||||
if (tokenizer.hasMoreTokens()) {
|
if (components.length > 0) {
|
||||||
mDefaultCountry = tokenizer.nextToken().trim();
|
mDefaultLanguage = components[0];
|
||||||
}
|
}
|
||||||
if (tokenizer.hasMoreTokens()) {
|
if (components.length > 1) {
|
||||||
mDefaultLocVariant = tokenizer.nextToken().trim();
|
mDefaultCountry = components[1];
|
||||||
|
}
|
||||||
|
if (components.length > 2) {
|
||||||
|
mDefaultLocVariant = components[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,26 +645,18 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
private void loadEngines() {
|
private void loadEngines() {
|
||||||
List<EngineInfo> engines = mEnginesHelper.getEngines();
|
List<EngineInfo> engines = mEnginesHelper.getEngines();
|
||||||
updateUserEnabledEngines(engines);
|
CharSequence entries[] = new CharSequence[engines.size()];
|
||||||
|
CharSequence values[] = new CharSequence[engines.size()];
|
||||||
|
|
||||||
ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
|
final int count = engines.size();
|
||||||
ArrayList<CharSequence> values = new ArrayList<CharSequence>();
|
for (int i = 0; i < count; ++i) {
|
||||||
StringBuilder enabledEngines = new StringBuilder();
|
final EngineInfo engine = engines.get(i);
|
||||||
|
entries[i] = engine.label;
|
||||||
for (EngineInfo engine : engines) {
|
values[i] = engine.name;
|
||||||
Log.v(TAG, "Engine: " + engine);
|
|
||||||
if (mEnginesHelper.isEngineEnabled(engine.name)) {
|
|
||||||
entries.add(engine.label);
|
|
||||||
values.add(engine.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaultSynthPref.setEntries(entries);
|
||||||
CharSequence entriesArray[] = new CharSequence[entries.size()];
|
mDefaultSynthPref.setEntryValues(values);
|
||||||
CharSequence valuesArray[] = new CharSequence[values.size()];
|
|
||||||
|
|
||||||
mDefaultSynthPref.setEntries(entries.toArray(entriesArray));
|
|
||||||
mDefaultSynthPref.setEntryValues(values.toArray(valuesArray));
|
|
||||||
|
|
||||||
// Set the selected engine based on the saved preference
|
// Set the selected engine based on the saved preference
|
||||||
String selectedEngine = Settings.Secure.getString(getContentResolver(), TTS_DEFAULT_SYNTH);
|
String selectedEngine = Settings.Secure.getString(getContentResolver(), TTS_DEFAULT_SYNTH);
|
||||||
@@ -716,26 +670,51 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
private void displayDataAlert(Preference pref, final String key) {
|
||||||
* Write out the list of engines enabled by the user to a
|
Log.v(TAG, "Displaying data alert for :" + key);
|
||||||
* shared preference.
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
*/
|
builder.setTitle(android.R.string.dialog_alert_title);
|
||||||
private void updateUserEnabledEngines(List<EngineInfo> engines) {
|
builder.setIcon(android.R.drawable.ic_dialog_alert);
|
||||||
StringBuilder enginesList = new StringBuilder();
|
builder.setMessage(getActivity().getString(
|
||||||
for (EngineInfo engine : engines) {
|
R.string.tts_engine_security_warning, pref.getTitle()));
|
||||||
if (isEngineUserEnabled(engine.name)) {
|
builder.setCancelable(true);
|
||||||
if (enginesList.length() > 0) enginesList.append(' ');
|
builder.setPositiveButton(android.R.string.ok,
|
||||||
enginesList.append(engine.name);
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
updateDefaultEngine(key);
|
||||||
|
loadEngines();
|
||||||
|
initEngineSpecificSettings();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(android.R.string.cancel, null);
|
||||||
|
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDefaultEngine(String engine) {
|
||||||
|
Log.v(TAG, "Updating default synth to : " + engine);
|
||||||
|
if (mTts != null) {
|
||||||
|
try {
|
||||||
|
mTts.shutdown();
|
||||||
|
mTts = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error shutting down TTS engine" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentResolver resolver = getContentResolver();
|
mTts = new TextToSpeech(getActivity().getApplicationContext(), this, engine);
|
||||||
Settings.Secure.putString(resolver, TTS_ENABLED_PLUGINS, enginesList.toString());
|
mEnableDemo = false;
|
||||||
}
|
mVoicesMissing = false;
|
||||||
|
updateWidgetState();
|
||||||
|
checkVoiceData();
|
||||||
|
|
||||||
private boolean isEngineUserEnabled(String engineName) {
|
// Finally, persist this value to settings.
|
||||||
String enginePref = KEY_PLUGIN_ENABLED_PREFIX + engineName;
|
Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, engine);
|
||||||
return getPreferenceManager().getSharedPreferences().getBoolean(enginePref, false);
|
// .. and update the UI.
|
||||||
|
mDefaultSynthPref.setValue(engine);
|
||||||
|
|
||||||
|
Log.v(TAG, "The default synth is now: " + engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user