Java Code Examples for android.support.v7.preference.CheckBoxPreference#setOnPreferenceChangeListener()
The following examples show how to use
android.support.v7.preference.CheckBoxPreference#setOnPreferenceChangeListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppProtectionPreferenceFragment.java From Silence with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); masterSecret = getArguments().getParcelable("master_secret"); disablePassphrase = (CheckBoxPreference) this.findPreference("pref_enable_passphrase_temporary"); this.findPreference(SilencePreferences.CHANGE_PASSPHRASE_PREF) .setOnPreferenceClickListener(new ChangePassphraseClickListener()); this.findPreference(SilencePreferences.PASSPHRASE_TIMEOUT_INTERVAL_PREF) .setOnPreferenceClickListener(new PassphraseIntervalClickListener()); this.findPreference(PREFERENCE_CATEGORY_BLOCKED) .setOnPreferenceClickListener(new BlockedContactsClickListener()); disablePassphrase .setOnPreferenceChangeListener(new DisablePassphraseClickListener()); }
Example 2
Source File: SettingsFragment.java From nevo-decorators-sms-captchas with GNU General Public License v3.0 | 5 votes |
@Override public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.main_setting); getPreferenceScreen().setEnabled(false); mCaptchaHideOnLocked = (CheckBoxPreference) findPreference(Settings.SETTING_CAPTCHA_HIDE_ON_LOCKED); mCaptchaOverrideDefaultAction = (CheckBoxPreference) findPreference(Settings.SETTING_CAPTCHA_OVERRIDE_DEFAULT_ACTION); mCaptchaPostCopyAction = (ListPreference) findPreference(Settings.SETTING_CAPTCHA_POST_COPY_ACTION); mCaptchaIdentifyPattern = (EditTextPreference) findPreference(Settings.SETTING_CAPTCHA_IDENTIFY_PATTERN); mCaptchaParsePattern = (EditTextPreference) findPreference(Settings.SETTING_CAPTCHA_PARSE_PATTERN); mSubscribeIdentityPattern = (EditTextPreference) findPreference(Settings.SETTING_SUBSCRIBE_IDENTIFY_PATTERN); mSubscribePriority = findPreference(Settings.SETTING_SUBSCRIBE_PRIORITY); mHideInLauncher = (CheckBoxPreference) findPreference(KEY_HIDE_IN_LAUNCHER); mCaptchaHideOnLocked.setOnPreferenceChangeListener(this::onPreferenceChange); mCaptchaOverrideDefaultAction.setOnPreferenceChangeListener(this::onPreferenceChange); mCaptchaPostCopyAction.setOnPreferenceChangeListener(this::onPreferenceChange); mCaptchaIdentifyPattern.setOnPreferenceChangeListener(this::onPreferenceChange); mCaptchaParsePattern.setOnPreferenceChangeListener(this::onPreferenceChange); mSubscribeIdentityPattern.setOnPreferenceChangeListener(this::onPreferenceChange); mHideInLauncher.setOnPreferenceChangeListener(this::onPreferenceChange); mSubscribePriority.setOnPreferenceChangeListener(this::onPreferenceChange); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) { mSubscribePriority.setOnPreferenceClickListener((Preference p) -> { startActivity( new Intent("android.settings.APP_NOTIFICATION_SETTINGS"). putExtra("android.provider.extra.APP_PACKAGE" , Global.NEVOLUTION_PACKAGE_NAME)); return false; }); } new Thread(this::loadSettingsAndUpdateViews).start(); }
Example 3
Source File: NGWSettingsFragment.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
protected void addAutoSyncProperty( final IGISApplication application, final Account account, PreferenceGroup syncCategory) { final String accountNameHash = "_" + account.name.hashCode(); SharedPreferences sharedPreferences = mStyledContext.getSharedPreferences(Constants.PREFERENCES, Context.MODE_MULTI_PROCESS); CheckBoxPreference enablePeriodicSync = new CheckBoxPreference(mStyledContext); enablePeriodicSync.setKey(KEY_SYNC); enablePeriodicSync.setPersistent(false); enablePeriodicSync.setTitle(R.string.auto_sync); boolean isAccountSyncEnabled = isAccountSyncEnabled(account, application.getAuthority()); enablePeriodicSync.setChecked(isAccountSyncEnabled); enablePeriodicSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange( Preference preference, Object newValue) { boolean isChecked = (boolean) newValue; setAccountSyncEnabled(account, application.getAuthority(), isChecked); return true; } }); long timeStamp = sharedPreferences.getLong( com.nextgis.maplib.util.SettingsConstants.KEY_PREF_LAST_SYNC_TIMESTAMP + accountNameHash, 0); if (isAccountSyncEnabled && timeStamp > 0) { enablePeriodicSync.setSummary(ControlHelper.getSyncTime(mStyledContext, timeStamp)); } else { enablePeriodicSync.setSummary(R.string.auto_sync_summary); } syncCategory.addPreference(enablePeriodicSync); }
Example 4
Source File: UTilitiesPreferenceFragment.java From utexas-utilities with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { Bundle args = getArguments(); preferenceScreenKey = args.getString("preferenceScreenKey"); super.onCreate(savedInstanceState); FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(getActivity()); switch (preferenceScreenKey) { case "root": autologin = (CheckBoxPreference) findPreference("autologin"); loginfield = findPreference("eid"); passwordfield = findPreference("password"); // bypass the default SharedPreferences and save the password to the // encrypted SP instead passwordfield.setOnPreferenceChangeListener((preference, newValue) -> { UTilitiesApplication.getInstance(getActivity()).getSecurePreferences().edit() .putString(preference.getKey(), (String) newValue).apply(); return false; }); final Preference logincheckbox = findPreference(getString(R.string.pref_logintype_key)); // Disable autologin when user switches to temp login logincheckbox.setOnPreferenceChangeListener((preference, newValue) -> { if (!((Boolean) newValue)) { autologin.setChecked(false); } return true; }); logincheckbox.setOnPreferenceClickListener(preference -> { UTilitiesApplication mApp = (UTilitiesApplication) getActivity().getApplication(); boolean checked = ((CheckBoxPreference) preference).isChecked(); if (checked) { new AutoLoginWarningDialog().show(getChildFragmentManager(), AutoLoginWarningDialog.class.getSimpleName()); } else { /* * if they switch to temp login we'll save their EID, but * clear their password for security purposes */ mApp.getSecurePreferences().edit().remove("password").apply(); ba.notifyDataSetChanged(); } // whenever they switch between temp and persistent, log them out mApp.logoutAll(); setupLoginFields(); firebaseAnalytics.setUserProperty("persistent_login", Boolean.toString(checked)); return true; }); setupLoginFields(); final CheckBoxPreference analytics = (CheckBoxPreference) findPreference(getString(R.string.pref_analytics_key)); analytics.setOnPreferenceChangeListener((preference, newValue) -> { firebaseAnalytics.setAnalyticsCollectionEnabled((Boolean) newValue); return true; }); final Preference about = findPreference("about"); about.setOnPreferenceClickListener(preference -> { final Intent about_intent = new Intent(getActivity(), AboutMeActivity.class); startActivity(about_intent); return true; }); break; case "experimental": final Preference updateBusStops = findPreference("update_stops"); updateBusStops.setOnPreferenceClickListener(preference -> { try { Utility.updateBusStops(getActivity()); } catch (IOException e) { e.printStackTrace(); Toast.makeText(getActivity(), "Stops could not be written to file.", Toast.LENGTH_SHORT).show(); } return true; }); break; default: throw new IllegalStateException("Unimplemented PreferenceScreen: " + preferenceScreenKey); } }