use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class CurrentDreamPreferenceController method setGearClickListenerForPreference.
private void setGearClickListenerForPreference(Preference preference) {
if (!(preference instanceof GearPreference))
return;
GearPreference gearPreference = (GearPreference) preference;
Optional<DreamInfo> info = getActiveDreamInfo();
if (!info.isPresent() || info.get().settingsComponentName == null) {
gearPreference.setOnGearClickListener(null);
return;
}
gearPreference.setOnGearClickListener(gearPref -> launchScreenSaverSettings());
}
use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by crdroidandroid.
the class CurrentDreamPreferenceController method setGearClickListenerForPreference.
private void setGearClickListenerForPreference(Preference preference) {
if (!(preference instanceof GearPreference))
return;
GearPreference gearPreference = (GearPreference) preference;
Optional<DreamInfo> info = getActiveDreamInfo();
if (!info.isPresent() || info.get().settingsComponentName == null) {
gearPreference.setOnGearClickListener(null);
return;
}
gearPreference.setOnGearClickListener(gearPref -> launchScreenSaverSettings());
}
use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by crdroidandroid.
the class TextToSpeechSettings method initSettings.
private void initSettings() {
final ContentResolver resolver = getContentResolver();
// Set up the default rate and pitch.
mDefaultRate = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_RATE, TextToSpeech.Engine.DEFAULT_RATE);
mDefaultPitch = android.provider.Settings.Secure.getInt(resolver, TTS_DEFAULT_PITCH, TextToSpeech.Engine.DEFAULT_PITCH);
mDefaultRatePref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, mDefaultRate));
mDefaultRatePref.setOnPreferenceChangeListener(this);
mDefaultRatePref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_RATE, MAX_SPEECH_RATE));
mDefaultPitchPref.setProgress(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, mDefaultPitch));
mDefaultPitchPref.setOnPreferenceChangeListener(this);
mDefaultPitchPref.setMax(getSeekBarProgressFromValue(KEY_DEFAULT_PITCH, MAX_SPEECH_PITCH));
if (mTts != null) {
mCurrentEngine = mTts.getCurrentEngine();
mTts.setSpeechRate(mDefaultRate / 100.0f);
mTts.setPitch(mDefaultPitch / 100.0f);
}
SettingsActivity activity = null;
if (getActivity() instanceof SettingsActivity) {
activity = (SettingsActivity) getActivity();
} else {
throw new IllegalStateException("TextToSpeechSettings used outside a " + "Settings");
}
if (mCurrentEngine != null) {
EngineInfo info = mEnginesHelper.getEngineInfo(mCurrentEngine);
Preference mEnginePreference = findPreference(KEY_TTS_ENGINE_PREFERENCE);
((GearPreference) mEnginePreference).setOnGearClickListener(this);
mEnginePreference.setSummary(info.label);
}
checkVoiceData(mCurrentEngine);
}
use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by SudaMod.
the class CurrentDreamPreferenceControllerTest method gearShowsIfActiveDreamInfoHasOptions.
@Test
public void gearShowsIfActiveDreamInfoHasOptions() {
mDreamInfo.settingsComponentName = mock(ComponentName.class);
mDreamInfo.isActive = true;
when(mBackend.getDreamInfos()).thenReturn(new ArrayList<>(Arrays.asList(mDreamInfo)));
GearPreference mockPref = mock(GearPreference.class);
ArgumentCaptor<GearPreference.OnGearClickListener> captor = ArgumentCaptor.forClass(GearPreference.OnGearClickListener.class);
// verify that updateState sets a non-null gear click listener
mController.updateState(mockPref);
verify(mockPref).setOnGearClickListener(captor.capture());
captor.getAllValues().forEach(listener -> assertThat(listener).isNotNull());
}
use of com.android.settings.widget.GearPreference in project android_packages_apps_Settings by SudaMod.
the class CurrentDreamPreferenceController method setGearClickListenerForPreference.
private void setGearClickListenerForPreference(Preference preference) {
if (!(preference instanceof GearPreference))
return;
GearPreference gearPreference = (GearPreference) preference;
Optional<DreamInfo> info = getActiveDreamInfo();
if (!info.isPresent() || info.get().settingsComponentName == null) {
gearPreference.setOnGearClickListener(null);
return;
}
gearPreference.setOnGearClickListener(gearPref -> launchScreenSaverSettings());
}
Aggregations