Search in sources :

Example 41 with SwitchPreference

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

Example 42 with SwitchPreference

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

Example 43 with SwitchPreference

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

Example 44 with SwitchPreference

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

Example 45 with SwitchPreference

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;
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) ComponentName(android.content.ComponentName)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)139 Test (org.junit.Test)61 Before (org.junit.Before)29 Intent (android.content.Intent)9 Preference (androidx.preference.Preference)6 ComponentName (android.content.ComponentName)5 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)5 ListPreference (androidx.preference.ListPreference)4 PreferenceScreen (androidx.preference.PreferenceScreen)4 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)4 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Context (android.content.Context)2 ServiceInfo (android.content.pm.ServiceInfo)2 KeyboardLayout (android.hardware.input.KeyboardLayout)2 Parcel (android.os.Parcel)2 PersistableBundle (android.os.PersistableBundle)2 RemoteException (android.os.RemoteException)2 TelephonyManager (android.telephony.TelephonyManager)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2