Search in sources :

Example 66 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ZenModeRepeatCallersPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    SwitchPreference pref = (SwitchPreference) preference;
    switch(getZenMode()) {
        case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
        case Settings.Global.ZEN_MODE_ALARMS:
            pref.setEnabled(false);
            pref.setChecked(false);
            break;
        default:
            boolean anyCallersCanBypassDnd = (mBackend.isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS) && mBackend.getPriorityCallSenders() == Policy.PRIORITY_SENDERS_ANY);
            // 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(mBackend.isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_REPEAT_CALLERS));
            }
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 67 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ZenModeEventsPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    SwitchPreference pref = (SwitchPreference) preference;
    switch(getZenMode()) {
        case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
        case Settings.Global.ZEN_MODE_ALARMS:
            pref.setEnabled(false);
            pref.setChecked(false);
            break;
        default:
            pref.setChecked(mBackend.isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_EVENTS));
            pref.setEnabled(true);
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 68 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ZenModeRemindersPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    SwitchPreference pref = (SwitchPreference) preference;
    switch(getZenMode()) {
        case Settings.Global.ZEN_MODE_NO_INTERRUPTIONS:
        case Settings.Global.ZEN_MODE_ALARMS:
            pref.setEnabled(false);
            pref.setChecked(false);
            break;
        default:
            pref.setEnabled(true);
            pref.setChecked(mBackend.isPriorityCategoryEnabled(NotificationManager.Policy.PRIORITY_CATEGORY_REMINDERS));
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 69 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ZenModeSystemPreferenceController 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(false);
            break;
        default:
            pref.setEnabled(true);
            pref.setChecked(mBackend.isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_SYSTEM));
    }
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Example 70 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ZenRuleCustomSwitchPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    if (mRule == null || mRule.getZenPolicy() == null) {
        return;
    }
    SwitchPreference pref = (SwitchPreference) preference;
    pref.setChecked(mRule.getZenPolicy().isCategoryAllowed(mCategory, false));
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

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