use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SwipeToNotificationPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
SwitchPreference pref = (SwitchPreference) preference;
if (TextUtils.equals(pref.getKey(), PREF_SWIPE_DOWN)) {
boolean enabled = ((Boolean) newValue).booleanValue();
Settings.Secure.putInt(mContext.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? ON : OFF);
pref.setChecked(enabled);
SwitchPreference dismissPref = (SwitchPreference) mPreferenceScreen.findPreference(PREF_SWIPE_DISMISS);
if (dismissPref != null) {
dismissPref.setEnabled(enabled);
}
} else if (TextUtils.equals(pref.getKey(), PREF_SWIPE_DISMISS)) {
boolean enabled = ((Boolean) newValue).booleanValue();
Settings.Secure.putInt(mContext.getContentResolver(), FP_SWIPE_TO_DISMISS_NOTIFICATIONS, enabled ? ON : OFF);
pref.setChecked(enabled);
}
return true;
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class Enhanced4gLtePreferenceController method updateState.
@Override
public void updateState(Preference preference) {
super.updateState(preference);
final SwitchPreference switchPreference = (SwitchPreference) preference;
final boolean show4GForLTE = mCarrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
int variant4glteTitleIndex = mCarrierConfig.getInt(CarrierConfigManager.KEY_ENHANCED_4G_LTE_TITLE_VARIANT_INT);
if (variant4glteTitleIndex != VARIANT_TITLE_ADVANCED_CALL) {
variant4glteTitleIndex = show4GForLTE ? VARIANT_TITLE_4G_CALLING : VARIANT_TITLE_VOLTE;
}
switchPreference.setTitle(mVariantTitles[variant4glteTitleIndex]);
switchPreference.setSummary(mVariantSumaries[variant4glteTitleIndex]);
switchPreference.setEnabled(is4gLtePrefEnabled());
switchPreference.setChecked(mImsManager.isEnhanced4gLteModeSettingEnabledByUser() && mImsManager.isNonTtyOrTtyOnVolteEnabled());
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AutoSyncDataPreferenceController method handlePreferenceTreeClick.
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (getPreferenceKey().equals(preference.getKey())) {
SwitchPreference switchPreference = (SwitchPreference) preference;
boolean checked = switchPreference.isChecked();
switchPreference.setChecked(!checked);
if (ActivityManager.isUserAMonkey()) {
Log.d(TAG, "ignoring monkey's attempt to flip sync state");
} else {
ConfirmAutoSyncChangeFragment.show(mParentFragment, checked, mUserHandle, switchPreference);
}
return true;
}
return false;
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class KeyboardLayoutPickerController method handlePreferenceTreeClick.
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!(preference instanceof SwitchPreference)) {
return false;
}
final SwitchPreference switchPref = (SwitchPreference) preference;
final KeyboardLayout layout = mPreferenceMap.get(switchPref);
if (layout != null) {
final boolean checked = switchPref.isChecked();
if (checked) {
mIm.addKeyboardLayoutForInputDevice(mInputDeviceIdentifier, layout.getDescriptor());
} else {
mIm.removeKeyboardLayoutForInputDevice(mInputDeviceIdentifier, layout.getDescriptor());
}
}
return true;
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TrustAgentsPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!(preference instanceof SwitchPreference)) {
return false;
}
for (TrustAgentInfo agent : mAvailableAgents.values()) {
final ComponentName componentName = agent.getComponentName();
if (!TextUtils.equals(preference.getKey(), componentName.flattenToString())) {
continue;
}
if ((Boolean) newValue && !mActiveAgents.contains(componentName)) {
mActiveAgents.add(componentName);
} else {
mActiveAgents.remove(componentName);
}
saveActiveAgents();
return true;
}
return false;
}
Aggregations