Search in sources :

Example 56 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project Klyph by jonathangerbaud.

the class PreferencesActivity method handleSetNotifications.

private void handleSetNotifications() {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    @SuppressWarnings("deprecation") CheckBoxPreference cpref = (CheckBoxPreference) findPreference("preference_notifications");
    pendingAnnounce = false;
    final Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!permissions.containsAll(PERMISSIONS)) {
        pendingAnnounce = true;
        editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, false);
        editor.commit();
        cpref.setChecked(false);
        AlertUtil.showAlert(this, R.string.preferences_notifications_permissions_title, R.string.preferences_notifications_permissions_message, R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                requestPublishPermissions(session);
            }
        }, R.string.cancel, null);
        return;
    }
    editor.putBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS, true);
    editor.commit();
    cpref.setChecked(true);
    startOrStopNotificationsServices();
    if (sharedPreferences.getBoolean(KlyphPreferences.PREFERENCE_NOTIFICATIONS_BIRTHDAY, false) == true)
        KlyphService.startBirthdayService();
}
Also used : SharedPreferences(android.content.SharedPreferences) CheckBoxPreference(android.preference.CheckBoxPreference) DialogInterface(android.content.DialogInterface) Session(com.facebook.Session)

Example 57 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class OpenvpnEditor method loadExtraPreferencesTo.

@Override
protected void loadExtraPreferencesTo(PreferenceGroup subpanel) {
    final Context c = subpanel.getContext();
    final OpenvpnProfile profile = (OpenvpnProfile) getProfile();
    mUserAuth = new CheckBoxPreference(c);
    mUserAuth.setTitle(R.string.vpn_openvpn_userauth);
    mUserAuth.setSummary(R.string.vpn_openvpn_userauth_summary);
    mUserAuth.setChecked(profile.getUserAuth());
    mUserAuth.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference pref, Object newValue) {
            boolean enabled = (Boolean) newValue;
            profile.setUserAuth(enabled);
            mUserAuth.setChecked(enabled);
            return true;
        }
    });
    subpanel.addPreference(mUserAuth);
    mCACert = createList(c, R.string.vpn_ca_certificate_title, profile.getCAName(), mKeyStore.saw(Credentials.CA_CERTIFICATE), new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference pref, Object newValue) {
            String f = (String) newValue;
            profile.setCAName(f);
            setSummary(mCACert, R.string.vpn_ca_certificate, profile.getCAName());
            return true;
        }
    });
    setSummary(mCACert, R.string.vpn_ca_certificate, profile.getCAName());
    subpanel.addPreference(mCACert);
    mCert = createList(c, R.string.vpn_user_certificate_title, profile.getCertName(), mKeyStore.saw(Credentials.USER_CERTIFICATE), new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference pref, Object newValue) {
            String f = (String) newValue;
            profile.setCertName(f);
            setSummary(mCert, R.string.vpn_user_certificate, profile.getCertName());
            return true;
        }
    });
    setSummary(mCert, R.string.vpn_user_certificate, profile.getCertName());
    subpanel.addPreference(mCert);
}
Also used : Context(android.content.Context) CheckBoxPreference(android.preference.CheckBoxPreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) OpenvpnProfile(android.net.vpn.OpenvpnProfile)

Example 58 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class PptpEditor method createEncryptionPreference.

private Preference createEncryptionPreference(Context c) {
    final PptpProfile profile = (PptpProfile) getProfile();
    CheckBoxPreference encryption = mEncryption = new CheckBoxPreference(c);
    boolean enabled = profile.isEncryptionEnabled();
    setCheckBoxTitle(encryption, R.string.vpn_pptp_encryption_title);
    encryption.setChecked(enabled);
    setEncryptionSummary(encryption, enabled);
    encryption.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference pref, Object newValue) {
            boolean enabled = (Boolean) newValue;
            profile.setEncryptionEnabled(enabled);
            setEncryptionSummary(mEncryption, enabled);
            return true;
        }
    });
    return encryption;
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) PptpProfile(android.net.vpn.PptpProfile)

Example 59 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class AccessibilitySettings method handleEnableAccessibilityStateChange.

/**
 * Handles the change of the accessibility enabled setting state.
 *
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference) {
    if (preference.isChecked()) {
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 1);
        setAccessibilityServicePreferencesState(true);
    } else {
        final CheckBoxPreference checkBoxPreference = preference;
        AlertDialog dialog = (new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 0);
                setAccessibilityServicePreferencesState(false);
            }
        }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                checkBoxPreference.setChecked(true);
            }
        }).create();
        dialog.show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) CheckBoxPreference(android.preference.CheckBoxPreference) DialogInterface(android.content.DialogInterface)

Example 60 with CheckBoxPreference

use of android.preference.CheckBoxPreference in project android_packages_apps_Settings by LineageOS.

the class ApplicationSettings method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.application_settings);
    mToggleAppInstallation = (CheckBoxPreference) findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
    mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
    mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
    // Is app default install location set?
    boolean userSetInstLocation = (Settings.System.getInt(getContentResolver(), Settings.Secure.SET_INSTALL_LOCATION, 0) != 0);
    if (!userSetInstLocation) {
        getPreferenceScreen().removePreference(mInstallLocation);
    } else {
        mInstallLocation.setValue(getAppInstallLocation());
        mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            public boolean onPreferenceChange(Preference preference, Object newValue) {
                String value = (String) newValue;
                handleUpdateAppInstallLocation(value);
                return false;
            }
        });
    }
    if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) {
        // No hard keyboard, remove the setting for quick launch
        Preference quickLaunchSetting = findPreference(KEY_QUICK_LAUNCH);
        getPreferenceScreen().removePreference(quickLaunchSetting);
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Aggregations

CheckBoxPreference (android.preference.CheckBoxPreference)138 Preference (android.preference.Preference)70 ListPreference (android.preference.ListPreference)53 Intent (android.content.Intent)28 SharedPreferences (android.content.SharedPreferences)23 EditTextPreference (android.preference.EditTextPreference)23 PreferenceCategory (android.preference.PreferenceCategory)22 PreferenceScreen (android.preference.PreferenceScreen)22 ArrayList (java.util.ArrayList)17 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)13 DialogInterface (android.content.DialogInterface)11 Context (android.content.Context)10 PackageManager (android.content.pm.PackageManager)10 SuppressLint (android.annotation.SuppressLint)8 Bundle (android.os.Bundle)7 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)7 PreferenceManager (android.preference.PreferenceManager)7 File (java.io.File)7 AlertDialog (android.app.AlertDialog)6 Uri (android.net.Uri)6