Search in sources :

Example 16 with TtsEngines

use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by SudaMod.

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;
}
Also used : VirtualKeyboardPreferenceController(com.android.settings.inputmethod.VirtualKeyboardPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) SpellCheckerPreferenceController(com.android.settings.inputmethod.SpellCheckerPreferenceController) ArrayList(java.util.ArrayList) PhysicalKeyboardPreferenceController(com.android.settings.inputmethod.PhysicalKeyboardPreferenceController) TtsEngines(android.speech.tts.TtsEngines) DefaultAutofillPreferenceController(com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController) GameControllerPreferenceController(com.android.settings.inputmethod.GameControllerPreferenceController)

Example 17 with TtsEngines

use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by SudaMod.

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);
}
Also used : TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Example 18 with TtsEngines

use of android.speech.tts.TtsEngines in project android_packages_apps_Settings by SudaMod.

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();
}
Also used : TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Example 19 with TtsEngines

use of android.speech.tts.TtsEngines in project platform_packages_apps_Settings by BlissRoms.

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;
}
Also used : VirtualKeyboardPreferenceController(com.android.settings.inputmethod.VirtualKeyboardPreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) SpellCheckerPreferenceController(com.android.settings.inputmethod.SpellCheckerPreferenceController) ArrayList(java.util.ArrayList) PhysicalKeyboardPreferenceController(com.android.settings.inputmethod.PhysicalKeyboardPreferenceController) TtsEngines(android.speech.tts.TtsEngines) DefaultAutofillPreferenceController(com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController) GameControllerPreferenceController(com.android.settings.inputmethod.GameControllerPreferenceController)

Example 20 with TtsEngines

use of android.speech.tts.TtsEngines in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 = ((ActionButtonsPreference) findPreference(KEY_ACTION_BUTTONS)).setButton1Text(R.string.tts_play).setButton1OnClickListener(v -> speakSampleText()).setButton1Enabled(false).setButton2Text(R.string.tts_reset).setButton2OnClickListener(v -> resetTts()).setButton1Enabled(true);
    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);
}
Also used : SettingsPreferenceFragment(com.android.settings.SettingsPreferenceFragment) Context(android.content.Context) Arrays(java.util.Arrays) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) SeekBarPreference(com.android.settings.widget.SeekBarPreference) Pair(android.util.Pair) UtteranceProgressListener(android.speech.tts.UtteranceProgressListener) Intent(android.content.Intent) HashMap(java.util.HashMap) SearchIndexable(com.android.settingslib.search.SearchIndexable) ArrayList(java.util.ArrayList) Indexable(com.android.settings.search.Indexable) SearchIndexableResource(android.provider.SearchIndexableResource) TtsEngines(android.speech.tts.TtsEngines) ContentResolver(android.content.ContentResolver) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo) Locale(java.util.Locale) TTS_DEFAULT_RATE(android.provider.Settings.Secure.TTS_DEFAULT_RATE) Log(android.util.Log) R(com.android.settings.R) BaseSearchIndexProvider(com.android.settings.search.BaseSearchIndexProvider) TTS_DEFAULT_PITCH(android.provider.Settings.Secure.TTS_DEFAULT_PITCH) TTS_DEFAULT_SYNTH(android.provider.Settings.Secure.TTS_DEFAULT_SYNTH) MissingResourceException(java.util.MissingResourceException) Set(java.util.Set) SettingsEnums(android.app.settings.SettingsEnums) TextUtils(android.text.TextUtils) GearPreference(com.android.settings.widget.GearPreference) ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference) Preference(androidx.preference.Preference) Objects(java.util.Objects) TextToSpeech(android.speech.tts.TextToSpeech) List(java.util.List) SettingsActivity(com.android.settings.SettingsActivity) ActivityNotFoundException(android.content.ActivityNotFoundException) ListPreference(androidx.preference.ListPreference) Collections(java.util.Collections) ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference) TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Aggregations

TtsEngines (android.speech.tts.TtsEngines)21 TextToSpeech (android.speech.tts.TextToSpeech)15 ArrayList (java.util.ArrayList)7 DefaultAutofillPreferenceController (com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController)6 GameControllerPreferenceController (com.android.settings.inputmethod.GameControllerPreferenceController)6 PhysicalKeyboardPreferenceController (com.android.settings.inputmethod.PhysicalKeyboardPreferenceController)6 SpellCheckerPreferenceController (com.android.settings.inputmethod.SpellCheckerPreferenceController)6 VirtualKeyboardPreferenceController (com.android.settings.inputmethod.VirtualKeyboardPreferenceController)6 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)6 SettingsEnums (android.app.settings.SettingsEnums)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ContentResolver (android.content.ContentResolver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Bundle (android.os.Bundle)1 SearchIndexableResource (android.provider.SearchIndexableResource)1 TTS_DEFAULT_PITCH (android.provider.Settings.Secure.TTS_DEFAULT_PITCH)1 TTS_DEFAULT_RATE (android.provider.Settings.Secure.TTS_DEFAULT_RATE)1 TTS_DEFAULT_SYNTH (android.provider.Settings.Secure.TTS_DEFAULT_SYNTH)1