* commit '7a5911a96d158567bac1e892aee813af1b563a46': Fix F/C in TTS settings
This commit is contained in:
committed by
Android Git Automerger
commit
cc91f6ff66
@@ -45,6 +45,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
|
||||
public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
@@ -277,25 +278,32 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
if (mCurrentDefaultLocale == null || mAvailableStrLocals == null) {
|
||||
return false;
|
||||
}
|
||||
int defaultAvailable = mTts.setLanguage(mCurrentDefaultLocale);
|
||||
|
||||
// Check if language is listed in CheckVoices Action result as available voice.
|
||||
String defaultLocaleStr = mCurrentDefaultLocale.getISO3Language();
|
||||
boolean notInAvailableLangauges = true;
|
||||
if (!TextUtils.isEmpty(mCurrentDefaultLocale.getISO3Country())) {
|
||||
defaultLocaleStr += "-" + mCurrentDefaultLocale.getISO3Country();
|
||||
}
|
||||
if (!TextUtils.isEmpty(mCurrentDefaultLocale.getVariant())) {
|
||||
defaultLocaleStr += "-" + mCurrentDefaultLocale.getVariant();
|
||||
}
|
||||
|
||||
for (String loc : mAvailableStrLocals) {
|
||||
if (loc.equalsIgnoreCase(defaultLocaleStr)) {
|
||||
notInAvailableLangauges = false;
|
||||
break;
|
||||
try {
|
||||
// Check if language is listed in CheckVoices Action result as available voice.
|
||||
String defaultLocaleStr = mCurrentDefaultLocale.getISO3Language();
|
||||
if (!TextUtils.isEmpty(mCurrentDefaultLocale.getISO3Country())) {
|
||||
defaultLocaleStr += "-" + mCurrentDefaultLocale.getISO3Country();
|
||||
}
|
||||
if (!TextUtils.isEmpty(mCurrentDefaultLocale.getVariant())) {
|
||||
defaultLocaleStr += "-" + mCurrentDefaultLocale.getVariant();
|
||||
}
|
||||
|
||||
for (String loc : mAvailableStrLocals) {
|
||||
if (loc.equalsIgnoreCase(defaultLocaleStr)) {
|
||||
notInAvailableLangauges = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (MissingResourceException e) {
|
||||
if (DBG) Log.wtf(TAG, "MissingResourceException", e);
|
||||
updateEngineStatus(R.string.tts_status_not_supported);
|
||||
updateWidgetState(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int defaultAvailable = mTts.setLanguage(mCurrentDefaultLocale);
|
||||
if (defaultAvailable == TextToSpeech.LANG_NOT_SUPPORTED ||
|
||||
defaultAvailable == TextToSpeech.LANG_MISSING_DATA ||
|
||||
notInAvailableLangauges) {
|
||||
@@ -314,7 +322,6 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ask the current default engine to return a string of sample text to be
|
||||
* spoken to the user.
|
||||
@@ -357,16 +364,21 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
private String getDefaultSampleString() {
|
||||
if (mTts != null && mTts.getLanguage() != null) {
|
||||
final String currentLang = mTts.getLanguage().getISO3Language();
|
||||
String[] strings = getActivity().getResources().getStringArray(
|
||||
R.array.tts_demo_strings);
|
||||
String[] langs = getActivity().getResources().getStringArray(
|
||||
R.array.tts_demo_string_langs);
|
||||
try {
|
||||
final String currentLang = mTts.getLanguage().getISO3Language();
|
||||
String[] strings = getActivity().getResources().getStringArray(
|
||||
R.array.tts_demo_strings);
|
||||
String[] langs = getActivity().getResources().getStringArray(
|
||||
R.array.tts_demo_string_langs);
|
||||
|
||||
for (int i = 0; i < strings.length; ++i) {
|
||||
if (langs[i].equals(currentLang)) {
|
||||
return strings[i];
|
||||
for (int i = 0; i < strings.length; ++i) {
|
||||
if (langs[i].equals(currentLang)) {
|
||||
return strings[i];
|
||||
}
|
||||
}
|
||||
} catch (MissingResourceException e) {
|
||||
if (DBG) Log.wtf(TAG, "MissingResourceException", e);
|
||||
// Ignore and fall back to default sample string
|
||||
}
|
||||
}
|
||||
return getString(R.string.tts_default_sample_string);
|
||||
|
Reference in New Issue
Block a user