use of android.speech.tts.TtsEngines in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TtsEngineSettingsFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_engine_settings);
mEnginesHelper = new TtsEngines(getActivity());
final PreferenceScreen root = getPreferenceScreen();
mLocalePreference = (ListPreference) root.findPreference(KEY_ENGINE_LOCALE);
mLocalePreference.setOnPreferenceChangeListener(this);
mEngineSettingsPreference = root.findPreference(KEY_ENGINE_SETTINGS);
mEngineSettingsPreference.setOnPreferenceClickListener(this);
mInstallVoicesPreference = root.findPreference(KEY_INSTALL_DATA);
mInstallVoicesPreference.setOnPreferenceClickListener(this);
root.setTitle(getEngineLabel());
root.setKey(getEngineName());
mEngineSettingsPreference.setTitle(getResources().getString(R.string.tts_engine_settings_title, getEngineLabel()));
mEngineSettingsIntent = mEnginesHelper.getSettingsIntent(getEngineName());
if (mEngineSettingsIntent == null) {
mEngineSettingsPreference.setEnabled(false);
}
mInstallVoicesPreference.setEnabled(false);
if (savedInstanceState == null) {
mLocalePreference.setEnabled(false);
mLocalePreference.setEntries(new CharSequence[0]);
mLocalePreference.setEntryValues(new CharSequence[0]);
} else {
// Repopulate mLocalePreference with saved state. Will be updated later with
// up-to-date values when checkTtsData() calls back with results.
final CharSequence[] entries = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
final CharSequence[] entryValues = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
final CharSequence value = savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
mLocalePreference.setEntries(entries);
mLocalePreference.setEntryValues(entryValues);
mLocalePreference.setValue(value != null ? value.toString() : null);
mLocalePreference.setEnabled(entries.length > 0);
}
mVoiceDataDetails = getArguments().getParcelable(TtsEnginePreference.FRAGMENT_ARGS_VOICES);
mTts = new TextToSpeech(getActivity().getApplicationContext(), mTtsInitListener, getEngineName());
// Check if data packs changed
checkTtsData();
getActivity().registerReceiver(mLanguagesChangedReceiver, new IntentFilter(TextToSpeech.Engine.ACTION_TTS_DATA_INSTALLED));
}
use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by LineageOS.
the class TtsEnginePreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_engine_picker);
mEnginePreferenceCategory = (PreferenceCategory) findPreference("tts_engine_preference_category");
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
mTts = new TextToSpeech(getActivity().getApplicationContext(), null);
initSettings();
}
use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by omnirom.
the class LanguageAndInputSettings method buildPreferenceControllers.
private static List<AbstractPreferenceController> buildPreferenceControllers(@NonNull Context context, @Nullable Lifecycle lifecycle) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
// Language
controllers.add(new PhoneLanguagePreferenceController(context));
controllers.add(new SpellCheckerPreferenceController(context));
controllers.add(new UserDictionaryPreferenceController(context));
controllers.add(new TtsPreferenceController(context, new TtsEngines(context)));
// Input
controllers.add(new VirtualKeyboardPreferenceController(context));
controllers.add(new PhysicalKeyboardPreferenceController(context, lifecycle));
final GameControllerPreferenceController gameControllerPreferenceController = new GameControllerPreferenceController(context);
if (lifecycle != null) {
lifecycle.addObserver(gameControllerPreferenceController);
}
controllers.add(gameControllerPreferenceController);
controllers.add(new DefaultAutofillPreferenceController(context));
return controllers;
}
use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by omnirom.
the class TtsEnginePreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_engine_picker);
mEnginePreferenceCategory = (PreferenceCategory) findPreference("tts_engine_preference_category");
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
mTts = new TextToSpeech(getActivity().getApplicationContext(), null);
initSettings();
}
use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by crdroidandroid.
the class TextToSpeechSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.tts_settings);
getActivity().setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
mEnginesHelper = new TtsEngines(getActivity().getApplicationContext());
mLocalePreference = (ListPreference) findPreference(KEY_ENGINE_LOCALE);
mLocalePreference.setOnPreferenceChangeListener(this);
mDefaultPitchPref = (SeekBarPreference) findPreference(KEY_DEFAULT_PITCH);
mDefaultRatePref = (SeekBarPreference) findPreference(KEY_DEFAULT_RATE);
mActionButtons = (LayoutPreference) findPreference(KEY_ACTION_BUTTONS);
mPlayButton = (Button) mActionButtons.findViewById(R.id.tts_play_button);
mPlayButton.setOnClickListener(this);
mPlayButton.setEnabled(false);
mResetButton = (Button) mActionButtons.findViewById(R.id.tts_reset_button);
mResetButton.setOnClickListener(this);
if (savedInstanceState == null) {
mLocalePreference.setEnabled(false);
mLocalePreference.setEntries(new CharSequence[0]);
mLocalePreference.setEntryValues(new CharSequence[0]);
} else {
// Repopulate mLocalePreference with saved state. Will be updated later with
// up-to-date values when checkTtsData() calls back with results.
final CharSequence[] entries = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRIES);
final CharSequence[] entryValues = savedInstanceState.getCharSequenceArray(STATE_KEY_LOCALE_ENTRY_VALUES);
final CharSequence value = savedInstanceState.getCharSequence(STATE_KEY_LOCALE_VALUE);
mLocalePreference.setEntries(entries);
mLocalePreference.setEntryValues(entryValues);
mLocalePreference.setValue(value != null ? value.toString() : null);
mLocalePreference.setEnabled(entries.length > 0);
}
mTts = new TextToSpeech(getActivity().getApplicationContext(), mInitListener);
setTtsUtteranceProgressListener();
initSettings();
// Prevent restarting the TTS connection on rotation
setRetainInstance(true);
}
Aggregations