Search in sources :

Example 6 with ActionButtonsPreference

use of com.android.settingslib.widget.ActionButtonsPreference in project android_packages_apps_Settings by omnirom.

the class BluetoothDetailsButtonsControllerTest method createMock.

private ActionButtonsPreference createMock() {
    final ActionButtonsPreference pref = mock(ActionButtonsPreference.class);
    when(pref.setButton1Text(anyInt())).thenReturn(pref);
    when(pref.setButton1Icon(anyInt())).thenReturn(pref);
    when(pref.setButton1Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton1Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton1OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton2Text(anyInt())).thenReturn(pref);
    when(pref.setButton2Icon(anyInt())).thenReturn(pref);
    when(pref.setButton2Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton2Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton2OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    return pref;
}
Also used : ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference)

Example 7 with ActionButtonsPreference

use of com.android.settingslib.widget.ActionButtonsPreference 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)

Example 8 with ActionButtonsPreference

use of com.android.settingslib.widget.ActionButtonsPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiDetailPreferenceControllerTest method createMock.

private ActionButtonsPreference createMock() {
    final ActionButtonsPreference pref = mock(ActionButtonsPreference.class);
    when(pref.setButton1Text(anyInt())).thenReturn(pref);
    when(pref.setButton1Icon(anyInt())).thenReturn(pref);
    when(pref.setButton1Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton1Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton1OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton2Text(anyInt())).thenReturn(pref);
    when(pref.setButton2Icon(anyInt())).thenReturn(pref);
    when(pref.setButton2Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton2Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton2OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton3Text(anyInt())).thenReturn(pref);
    when(pref.setButton3Icon(anyInt())).thenReturn(pref);
    when(pref.setButton3Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton3Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton3OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton4Text(anyInt())).thenReturn(pref);
    when(pref.setButton4Icon(anyInt())).thenReturn(pref);
    when(pref.setButton4Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton4Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton4OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    return pref;
}
Also used : ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference) OnClickListener(android.view.View.OnClickListener)

Example 9 with ActionButtonsPreference

use of com.android.settingslib.widget.ActionButtonsPreference in project android_packages_apps_Settings by omnirom.

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);
    mUserManager = (UserManager) getActivity().getApplicationContext().getSystemService(Context.USER_SERVICE);
    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);
    }
    final TextToSpeechViewModel ttsViewModel = ViewModelProviders.of(this).get(TextToSpeechViewModel.class);
    Pair<TextToSpeech, Boolean> ttsAndNew = ttsViewModel.getTtsAndWhetherNew(mInitListener);
    mTts = ttsAndNew.first;
    // ensure that we can use the TTS object.
    if (!ttsAndNew.second) {
        successSetup();
    }
    setTtsUtteranceProgressListener();
    initSettings();
}
Also used : SettingsPreferenceFragment(com.android.settings.SettingsPreferenceFragment) Context(android.content.Context) 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) 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) UserHandle(android.os.UserHandle) ViewModelProviders(androidx.lifecycle.ViewModelProviders) Log(android.util.Log) R(com.android.settings.R) BaseSearchIndexProvider(com.android.settings.search.BaseSearchIndexProvider) Collator(java.text.Collator) UserManager(android.os.UserManager) 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) Secure(android.provider.Settings.Secure) FeatureFactory(com.android.settings.overlay.FeatureFactory) 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) Utils(com.android.settings.Utils) Collections(java.util.Collections) ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference) TtsEngines(android.speech.tts.TtsEngines) TextToSpeech(android.speech.tts.TextToSpeech)

Example 10 with ActionButtonsPreference

use of com.android.settingslib.widget.ActionButtonsPreference in project android_packages_apps_Settings by omnirom.

the class WifiDetailPreferenceController2Test method createMock.

private ActionButtonsPreference createMock() {
    final ActionButtonsPreference pref = mock(ActionButtonsPreference.class);
    when(pref.setButton1Text(anyInt())).thenReturn(pref);
    when(pref.setButton1Icon(anyInt())).thenReturn(pref);
    when(pref.setButton1Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton1Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton1OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton2Text(anyInt())).thenReturn(pref);
    when(pref.setButton2Icon(anyInt())).thenReturn(pref);
    when(pref.setButton2Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton2Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton2OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton3Text(anyInt())).thenReturn(pref);
    when(pref.setButton3Icon(anyInt())).thenReturn(pref);
    when(pref.setButton3Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton3Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton3OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    when(pref.setButton4Text(anyInt())).thenReturn(pref);
    when(pref.setButton4Icon(anyInt())).thenReturn(pref);
    when(pref.setButton4Enabled(anyBoolean())).thenReturn(pref);
    when(pref.setButton4Visible(anyBoolean())).thenReturn(pref);
    when(pref.setButton4OnClickListener(any(View.OnClickListener.class))).thenReturn(pref);
    return pref;
}
Also used : ActionButtonsPreference(com.android.settingslib.widget.ActionButtonsPreference) OnClickListener(android.view.View.OnClickListener)

Aggregations

ActionButtonsPreference (com.android.settingslib.widget.ActionButtonsPreference)10 SettingsEnums (android.app.settings.SettingsEnums)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 ContentResolver (android.content.ContentResolver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 TTS_DEFAULT_PITCH (android.provider.Settings.Secure.TTS_DEFAULT_PITCH)2 TTS_DEFAULT_RATE (android.provider.Settings.Secure.TTS_DEFAULT_RATE)2 TTS_DEFAULT_SYNTH (android.provider.Settings.Secure.TTS_DEFAULT_SYNTH)2 TextToSpeech (android.speech.tts.TextToSpeech)2 EngineInfo (android.speech.tts.TextToSpeech.EngineInfo)2 TtsEngines (android.speech.tts.TtsEngines)2 UtteranceProgressListener (android.speech.tts.UtteranceProgressListener)2 TextUtils (android.text.TextUtils)2 Log (android.util.Log)2 Pair (android.util.Pair)2 OnClickListener (android.view.View.OnClickListener)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 ListPreference (androidx.preference.ListPreference)2