use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeAlarmsPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
super.updateState(preference);
SwitchPreference pref = (SwitchPreference) preference;
switch(getZenMode()) {
case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
pref.setEnabled(false);
pref.setChecked(false);
break;
case Settings.Global.ZEN_MODE_ALARMS:
pref.setEnabled(false);
pref.setChecked(true);
break;
default:
pref.setEnabled(true);
pref.setChecked(mBackend.isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_ALARMS));
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenRuleRepeatCallersPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (mRule == null || mRule.getZenPolicy() == null) {
return;
}
SwitchPreference pref = (SwitchPreference) preference;
boolean anyCallersCanBypassDnd = mRule.getZenPolicy().getPriorityCallSenders() == ZenPolicy.PEOPLE_TYPE_ANYONE;
// if any caller can bypass dnd then repeat callers preference is disabled
if (anyCallersCanBypassDnd) {
pref.setEnabled(false);
pref.setChecked(true);
} else {
pref.setEnabled(true);
pref.setChecked(mRule.getZenPolicy().getPriorityCategoryRepeatCallers() == ZenPolicy.STATE_ALLOW);
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class GestureAnywhereSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.gesture_anywhere);
mContext = getActivity();
mEnabledPref = (SwitchPreference) findPreference(KEY_ENABLED);
mEnabledPref.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, 0) == 1));
mEnabledPref.setOnPreferenceChangeListener(this);
PreferenceScreen prefSet = getPreferenceScreen();
mPositionPref = (ListPreference) prefSet.findPreference(KEY_POSITION);
mPositionPref.setOnPreferenceChangeListener(this);
int position = Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_POSITION, Gravity.LEFT);
mPositionPref.setValue(String.valueOf(position));
mTriggerWidthPref = (CustomSeekBarPreference) findPreference(KEY_TRIGGER_WIDTH);
mTriggerWidthPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, 40));
mTriggerWidthPref.setOnPreferenceChangeListener(this);
mTriggerTopPref = (CustomSeekBarPreference) findPreference(KEY_TRIGGER_TOP);
mTriggerTopPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, 0));
mTriggerTopPref.setOnPreferenceChangeListener(this);
mTriggerBottomPref = (CustomSeekBarPreference) findPreference(KEY_TRIGGER_BOTTOM);
mTriggerBottomPref.setValue(Settings.System.getInt(getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, 100));
mTriggerBottomPref.setOnPreferenceChangeListener(this);
Preference pref = findPreference(KEY_GESTURES);
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(getActivity(), GestureAnywhereBuilderActivity.class));
return true;
}
});
int anim = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.RR_CONFIG_ANIM, 0);
try {
if (anim == 0) {
removePreference("animation");
} else if (anim == 1) {
removePreference("preview");
} else if (anim == 2) {
removePreference("animation");
removePreference("preview");
}
} catch (Exception e) {
}
if (SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)) {
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.ga_warning_message);
}
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
the class KeyboardLayoutPickerController method createPreferenceHierarchy.
private void createPreferenceHierarchy() {
for (KeyboardLayout layout : mKeyboardLayouts) {
final SwitchPreference pref = new SwitchPreference(mScreen.getContext());
pref.setTitle(layout.getLabel());
pref.setSummary(layout.getCollection());
pref.setKey(layout.getDescriptor());
mScreen.addPreference(pref);
mPreferenceMap.put(pref, layout);
}
}
use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.
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;
}
Aggregations