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;
}
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);
}
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;
}
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();
}
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;
}
Aggregations