Search in sources :

Example 61 with SwitchPreference

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));
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 62 with SwitchPreference

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);
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 63 with SwitchPreference

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);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) CustomSeekBarPreference(com.android.settings.rr.Preferences.CustomSeekBarPreference) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) ListPreference(androidx.preference.ListPreference) Intent(android.content.Intent)

Example 64 with SwitchPreference

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);
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) KeyboardLayout(android.hardware.input.KeyboardLayout)

Example 65 with SwitchPreference

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;
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) KeyboardLayout(android.hardware.input.KeyboardLayout)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)299 Test (org.junit.Test)125 Before (org.junit.Before)68 Intent (android.content.Intent)17 Preference (androidx.preference.Preference)17 ComponentName (android.content.ComponentName)10 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)10 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)8 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)8 ListPreference (androidx.preference.ListPreference)7 PreferenceScreen (androidx.preference.PreferenceScreen)7 RemoteException (android.os.RemoteException)6 PreferenceCategory (androidx.preference.PreferenceCategory)6 HashSet (java.util.HashSet)6 Context (android.content.Context)5 Parcel (android.os.Parcel)5 VisibleForTesting (androidx.annotation.VisibleForTesting)5 BluetoothDevice (android.bluetooth.BluetoothDevice)4 ChangeConfig (android.compat.Compatibility.ChangeConfig)4 ServiceInfo (android.content.pm.ServiceInfo)4