use of android.speech.tts.TextToSpeech.EngineInfo in project android_frameworks_base by DirtyUnicorns.
the class TtsEngines method getEngineInfo.
private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
ServiceInfo service = resolve.serviceInfo;
if (service != null) {
EngineInfo engine = new EngineInfo();
// Using just the package name isn't great, since it disallows having
// multiple engines in the same package, but that's what the existing API does.
engine.name = service.packageName;
CharSequence label = service.loadLabel(pm);
engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
engine.icon = service.getIconResource();
engine.priority = resolve.priority;
engine.system = isSystemEngine(service);
return engine;
}
return null;
}
use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by LineageOS.
the class TextToSpeechSettings method onGearClick.
@Override
public void onGearClick(GearPreference p) {
if (KEY_TTS_ENGINE_PREFERENCE.equals(p.getKey())) {
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
final Intent settingsIntent = mEnginesHelper.getSettingsIntent(info.name);
startActivity(settingsIntent);
}
}
use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by LineageOS.
the class TtsEnginePreferenceFragment method initSettings.
private void initSettings() {
if (mTts != null) {
mCurrentEngine = mTts.getCurrentEngine();
}
mEnginePreferenceCategory.removeAll();
SettingsActivity activity = (SettingsActivity) getActivity();
List<EngineInfo> engines = mEnginesHelper.getEngines();
for (EngineInfo engine : engines) {
TtsEnginePreference enginePref = new TtsEnginePreference(getPrefContext(), engine, this, activity);
mEnginePreferenceCategory.addPreference(enginePref);
}
}
use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by omnirom.
the class TtsEnginePreferenceFragment method initSettings.
private void initSettings() {
if (mTts != null) {
mCurrentEngine = mTts.getCurrentEngine();
}
mEnginePreferenceCategory.removeAll();
SettingsActivity activity = (SettingsActivity) getActivity();
List<EngineInfo> engines = mEnginesHelper.getEngines();
for (EngineInfo engine : engines) {
TtsEnginePreference enginePref = new TtsEnginePreference(getPrefContext(), engine, this, activity);
mEnginePreferenceCategory.addPreference(enginePref);
}
}
use of android.speech.tts.TextToSpeech.EngineInfo in project android_packages_apps_Settings by DirtyUnicorns.
the class TextToSpeechSettings method initSettings.
private void initSettings() {
final ContentResolver resolver = getContentResolver();
// Set up the default rate and pitch.
mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE, TextToSpeech.Engine.DEFAULT_RATE);
mDefaultPitch = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH);
mDefaultRatePref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, mDefaultRate));
mDefaultRatePref.setOnPreferenceChangeListener(this);
mDefaultRatePref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, MAX_SPEECH_RATE));
mDefaultPitchPref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, mDefaultPitch));
mDefaultPitchPref.setOnPreferenceChangeListener(this);
mDefaultPitchPref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, MAX_SPEECH_PITCH));
if (mTts != null) {
mCurrentEngine = mTts.getCurrentEngine();
mTts.setSpeechRate(mDefaultRate / 100.0f);
mTts.setPitch(mDefaultPitch / 100.0f);
}
SettingsActivity activity = null;
if (getActivity() instanceof SettingsActivity) {
activity = (SettingsActivity) getActivity();
} else {
throw new IllegalStateException("TextToSpeechSettings used outside a " + "Settings");
}
if (mCurrentEngine != null) {
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
((GearPreference) mEnginePreference).setOnGearClickListener(this);
mEnginePreference.setSummary(info.label);
}
checkVoiceData(mCurrentEngine);
}
Aggregations