use of com.android.settings.widget.SeekBarPreference 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.settings.widget.SeekBarPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NightDisplayIntensityPreferenceController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
preference.setContinuousUpdates(true);
preference.setMax(getMax());
preference.setMin(getMin());
}
use of com.android.settings.widget.SeekBarPreference in project android_packages_apps_Settings by omnirom.
the class ReduceBrightColorsIntensityPreferenceController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
preference.setContinuousUpdates(true);
preference.setMax(getMax());
preference.setMin(getMin());
preference.setHapticFeedbackMode(SeekBarPreference.HAPTIC_FEEDBACK_MODE_ON_ENDS);
updateState(preference);
}
use of com.android.settings.widget.SeekBarPreference 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.settings.widget.SeekBarPreference in project android_packages_apps_Settings by omnirom.
the class ToggleReduceBrightColorsPreferenceFragment method updateGeneralCategoryOrder.
private void updateGeneralCategoryOrder() {
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
final SeekBarPreference intensity = findPreference(KEY_INTENSITY);
getPreferenceScreen().removePreference(intensity);
intensity.setOrder(mShortcutPreference.getOrder() - 2);
generalCategory.addPreference(intensity);
final SwitchPreference persist = findPreference(KEY_PERSIST);
getPreferenceScreen().removePreference(persist);
persist.setOrder(mShortcutPreference.getOrder() - 1);
generalCategory.addPreference(persist);
}
Aggregations