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();
}
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);
}
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;
}
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();
}
}
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);
}
}
Aggregations