List of usage examples for android.preference CheckBoxPreference isChecked
public boolean isChecked()
From source file:org.exobel.routerkeygen.ui.Preferences.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); getActionBar().setDisplayHomeAsUpEnabled(true); findPreference("download").setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { if (isDictionaryServiceRunning()) { Toast.makeText(getBaseContext(), getString(R.string.pref_msg_download_running), Toast.LENGTH_SHORT).show(); return true; }/*from ww w . j a v a 2 s. c o m*/ ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo == null || !netInfo.isConnectedOrConnecting()) { Toast.makeText(getBaseContext(), getString(R.string.pref_msg_no_network), Toast.LENGTH_SHORT) .show(); return true; } // Don't complain about dictionary size if user is on a // wifi connection if ((((WifiManager) getBaseContext().getSystemService(Context.WIFI_SERVICE))).getConnectionInfo() .getSSID() != null) { try { checkCurrentDictionary(); } catch (FileNotFoundException e) { e.printStackTrace(); } } else showDialog(DIALOG_ASK_DOWNLOAD); return true; } }); // boolean app_installed = AdsUtils.checkDonation(this); final PreferenceCategory mCategory = (PreferenceCategory) findPreference("2section"); // if (!app_installed) { // mCategory.removePreference(findPreference("analytics_enabled")); // // If you haven't the donate app installed remove the paypal donate // // link. // mCategory.removePreference(findPreference("donate_paypal")); // findPreference("donate_playstore").setOnPreferenceClickListener( // new OnPreferenceClickListener() { // public boolean onPreferenceClick(Preference preference) { // try { // startActivity(new Intent(Intent.ACTION_VIEW, // Uri.parse("market://details?id=" // + GOOGLE_PLAY_DOWNLOADER))); // } catch (android.content.ActivityNotFoundException anfe) { // startActivity(new Intent( // Intent.ACTION_VIEW, // Uri.parse("http://play.google.com/store/apps/details?id=" // + GOOGLE_PLAY_DOWNLOADER))); // } // Toast.makeText(getApplicationContext(), // R.string.msg_donation, Toast.LENGTH_LONG) // .show(); // return true; // } // }); // } else { // // If you have the donate app installed no need to link to it. // mCategory.removePreference(findPreference("donate_playstore")); // if (BuildConfig.APPLICATION_ID.equals("io.github.routerkeygen")) { // //Play Store is quite restrictive nowadays // mCategory.removePreference(findPreference("donate_paypal")); // } else { // findPreference("donate_paypal").setOnPreferenceClickListener( // new OnPreferenceClickListener() { // public boolean onPreferenceClick(Preference preference) { // final String donateLink = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=V3FFBTRTTV5DN"; // Uri uri = Uri.parse(donateLink); // startActivity(new Intent(Intent.ACTION_VIEW, uri)); // // return true; // } // }); // } // } if (BuildConfig.APPLICATION_ID.equals("io.github.routerkeygen")) { mCategory.removePreference(findPreference("update")); } else { findPreference("update").setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { protected void onPreExecute() { showDialog(DIALOG_WAIT); } protected Void doInBackground(Void... params) { lastVersion = UpdateCheckerService.getLatestVersion(); return null; } protected void onPostExecute(Void result) { removeDialog(DIALOG_WAIT); if (isFinishing()) return; if (lastVersion == null) { showDialog(DIALOG_ERROR); return; } if (!Preferences.VERSION.equals(lastVersion.version)) { showDialog(DIALOG_UPDATE_NEEDED); } else { Toast.makeText(Preferences.this, R.string.msg_app_updated, Toast.LENGTH_SHORT) .show(); } } }; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { task.execute(); } else { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } // Checking for updates every week startService(new Intent(getApplicationContext(), UpdateCheckerService.class)); return true; } }); } findPreference("changelog").setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { showDialog(DIALOG_CHANGELOG); return true; } }); findPreference("about").setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { showDialog(DIALOG_ABOUT); return true; } }); findPreference(dicLocalPref).setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { startActivityForResult(new Intent(getApplicationContext(), FileChooserActivity.class), 0); return true; } }); final CheckBoxPreference autoScan = (CheckBoxPreference) findPreference("autoScan"); autoScan.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { findPreference("autoScanInterval").setEnabled(autoScan.isChecked()); return true; } }); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); findPreference("autoScanInterval").setEnabled( prefs.getBoolean(Preferences.autoScanPref, getResources().getBoolean(R.bool.autoScanDefault))); }
From source file:org.linphone.AccountPreferencesFragment.java
private void initAccountPreferencesFields(PreferenceScreen parent) { boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n; accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl()); accountCreator.setListener(this); PreferenceCategory account = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_sipaccount_key)); EditTextPreference username = (EditTextPreference) account.getPreference(0); username.setOnPreferenceChangeListener(usernameChangedListener); if (!isNewAccount) { username.setText(mPrefs.getAccountUsername(n)); username.setSummary(username.getText()); }/*from w ww . j a va2s . co m*/ EditTextPreference userid = (EditTextPreference) account.getPreference(1); userid.setOnPreferenceChangeListener(useridChangedListener); if (!isNewAccount) { userid.setText(mPrefs.getAccountUserId(n)); userid.setSummary(userid.getText()); } EditTextPreference password = (EditTextPreference) account.getPreference(2); password.setOnPreferenceChangeListener(passwordChangedListener); if (!isNewAccount) { password.setText(mPrefs.getAccountPassword(n)); } EditTextPreference domain = (EditTextPreference) account.getPreference(3); domain.setOnPreferenceChangeListener(domainChangedListener); if (!isNewAccount) { domain.setText(mPrefs.getAccountDomain(n)); domain.setSummary(domain.getText()); } EditTextPreference displayName = (EditTextPreference) account.getPreference(4); displayName.setOnPreferenceChangeListener(displayNameChangedListener); if (!isNewAccount) { displayName.setText(mPrefs.getAccountDisplayName(n)); displayName.setSummary(displayName.getText()); } PreferenceCategory advanced = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_advanced_key)); mTransportPreference = (ListPreference) advanced.getPreference(0); initializeTransportPreference(mTransportPreference); mTransportPreference.setOnPreferenceChangeListener(transportChangedListener); if (!isNewAccount) { mTransportPreference.setSummary(mPrefs.getAccountTransportString(n)); } mProxyPreference = (EditTextPreference) advanced.getPreference(1); mProxyPreference.setOnPreferenceChangeListener(proxyChangedListener); if (!isNewAccount) { mProxyPreference.setText(mPrefs.getAccountProxy(n)); mProxyPreference .setSummary("".equals(mProxyPreference.getText()) || (mProxyPreference.getText() == null) ? getString(R.string.pref_help_proxy) : mProxyPreference.getText()); } CheckBoxPreference outboundProxy = (CheckBoxPreference) advanced.getPreference(2); outboundProxy.setOnPreferenceChangeListener(outboundProxyChangedListener); if (!isNewAccount) { outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(n)); } EditTextPreference expires = (EditTextPreference) advanced.getPreference(3); expires.setOnPreferenceChangeListener(expiresChangedListener); if (!isNewAccount) { expires.setText(mPrefs.getExpires(n)); expires.setSummary(mPrefs.getExpires(n)); } EditTextPreference prefix = (EditTextPreference) advanced.getPreference(4); prefix.setOnPreferenceChangeListener(prefixChangedListener); if (!isNewAccount) { String prefixValue = mPrefs.getPrefix(n); prefix.setText(prefixValue); prefix.setSummary(prefixValue); } CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(5); avpf.setOnPreferenceChangeListener(avpfChangedListener); if (!isNewAccount) { avpf.setChecked(mPrefs.avpfEnabled(n)); } EditTextPreference avpfRRInterval = (EditTextPreference) advanced.getPreference(6); avpfRRInterval.setOnPreferenceChangeListener(avpfRRIntervalChangedListener); if (!isNewAccount) { avpfRRInterval.setText(mPrefs.getAvpfRRInterval(n)); avpfRRInterval.setSummary(mPrefs.getAvpfRRInterval(n)); } CheckBoxPreference escape = (CheckBoxPreference) advanced.getPreference(7); escape.setOnPreferenceChangeListener(escapeChangedListener); if (!isNewAccount) { escape.setChecked(mPrefs.getReplacePlusByZeroZero(n)); } Preference linkAccount = advanced.getPreference(8); linkAccount.setOnPreferenceClickListener(linkAccountListener); PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_manage_key)); final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0); disable.setEnabled(true); disable.setOnPreferenceChangeListener(disableChangedListener); if (!isNewAccount) { disable.setChecked(!mPrefs.isAccountEnabled(n)); } CheckBoxPreference mainAccount = (CheckBoxPreference) manage.getPreference(1); mainAccount.setChecked(isDefaultAccount); mainAccount.setEnabled(!mainAccount.isChecked()); mainAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { mPrefs.setDefaultAccount(n); disable.setEnabled(false); disable.setChecked(false); preference.setEnabled(false); return true; } }); if (!isNewAccount) { mainAccount.setEnabled(!mainAccount.isChecked()); } final Preference changePassword = manage.getPreference(2); if (mPrefs.getAccountDomain(n).compareTo(getString(R.string.default_domain)) == 0) { changePassword.setEnabled(!isNewAccount); changePassword.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { final AlertDialog.Builder alert = new AlertDialog.Builder(LinphoneActivity.instance()); LayoutInflater inflater = LinphoneActivity.instance().getLayoutInflater(); View layout = inflater.inflate(R.layout.new_password, null); final EditText pass1 = (EditText) layout.findViewById(R.id.password1); final EditText pass2 = (EditText) layout.findViewById(R.id.password2); alert.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LinphoneAccountCreator.PasswordCheck status = accountCreator .setPassword(pass1.getText().toString()); if (status.equals(LinphoneAccountCreator.PasswordCheck.Ok)) { if (pass1.getText().toString().compareTo(pass2.getText().toString()) == 0) { accountCreator.setUsername(mPrefs.getAccountUsername(n)); accountCreator.setHa1(mPrefs.getAccountHa1(n)); LinphoneAccountCreator.RequestStatus req_status = accountCreator .updatePassword(pass1.getText().toString()); if (!req_status.equals(LinphoneAccountCreator.RequestStatus.Ok)) { LinphoneUtils.displayErrorAlert( LinphoneUtils.errorForRequestStatus(req_status), LinphoneActivity.instance()); } else { progress = ProgressDialog.show(LinphoneActivity.instance(), null, null); Drawable d = new ColorDrawable(ContextCompat .getColor(LinphoneActivity.instance(), R.color.colorE)); d.setAlpha(200); progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); progress.getWindow().setBackgroundDrawable(d); progress.setContentView(R.layout.progress_dialog); progress.show(); } } else { LinphoneUtils.displayErrorAlert(getString(R.string.wizard_passwords_unmatched), LinphoneActivity.instance()); } return; } LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForPasswordStatus(status), LinphoneActivity.instance()); } }); alert.setView(layout); alert.show(); return true; } }); } else { changePassword.setEnabled(false); } final Preference delete = manage.getPreference(3); delete.setEnabled(!isNewAccount); delete.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { mPrefs.deleteAccount(n); LinphoneActivity.instance().refreshAccounts(); LinphoneActivity.instance().displaySettings(); return true; } }); }
From source file:co.taqat.call.AccountPreferencesFragment.java
private void initAccountPreferencesFields(PreferenceScreen parent) { boolean isDefaultAccount = mPrefs.getDefaultAccountIndex() == n; accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(), LinphonePreferences.instance().getXmlrpcUrl()); accountCreator.setListener(this); PreferenceCategory account = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_sipaccount_key)); EditTextPreference username = (EditTextPreference) account.getPreference(0); username.setOnPreferenceChangeListener(usernameChangedListener); if (!isNewAccount) { username.setText(mPrefs.getAccountUsername(n)); username.setSummary(username.getText()); }/*from w ww . ja va 2 s.c o m*/ EditTextPreference userid = (EditTextPreference) account.getPreference(1); userid.setOnPreferenceChangeListener(useridChangedListener); if (!isNewAccount) { userid.setText(mPrefs.getAccountUserId(n)); userid.setSummary(userid.getText()); } EditTextPreference password = (EditTextPreference) account.getPreference(2); password.setOnPreferenceChangeListener(passwordChangedListener); if (!isNewAccount) { password.setText(mPrefs.getAccountPassword(n)); } EditTextPreference domain = (EditTextPreference) account.getPreference(3); domain.setOnPreferenceChangeListener(domainChangedListener); if (!isNewAccount) { domain.setText(mPrefs.getAccountDomain(n)); domain.setSummary(domain.getText()); } EditTextPreference displayName = (EditTextPreference) account.getPreference(4); displayName.setOnPreferenceChangeListener(displayNameChangedListener); if (!isNewAccount) { displayName.setText(mPrefs.getAccountDisplayName(n)); displayName.setSummary(displayName.getText()); } PreferenceCategory advanced = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_advanced_key)); mTransportPreference = (ListPreference) advanced.getPreference(0); initializeTransportPreference(mTransportPreference); mTransportPreference.setOnPreferenceChangeListener(transportChangedListener); if (!isNewAccount) { mTransportPreference.setSummary(mPrefs.getAccountTransportString(n)); } mProxyPreference = (EditTextPreference) advanced.getPreference(1); mProxyPreference.setOnPreferenceChangeListener(proxyChangedListener); if (!isNewAccount) { mProxyPreference.setText(mPrefs.getAccountProxy(n)); mProxyPreference .setSummary("".equals(mProxyPreference.getText()) || (mProxyPreference.getText() == null) ? getString(R.string.pref_help_proxy) : mProxyPreference.getText()); } CheckBoxPreference outboundProxy = (CheckBoxPreference) advanced.getPreference(2); outboundProxy.setOnPreferenceChangeListener(outboundProxyChangedListener); if (!isNewAccount) { outboundProxy.setChecked(mPrefs.isAccountOutboundProxySet(n)); } EditTextPreference expires = (EditTextPreference) advanced.getPreference(3); expires.setOnPreferenceChangeListener(expiresChangedListener); if (!isNewAccount) { expires.setText(mPrefs.getExpires(n)); expires.setSummary(mPrefs.getExpires(n)); } EditTextPreference prefix = (EditTextPreference) advanced.getPreference(4); prefix.setOnPreferenceChangeListener(prefixChangedListener); if (!isNewAccount) { String prefixValue = mPrefs.getPrefix(n); prefix.setText(prefixValue); prefix.setSummary(prefixValue); } CheckBoxPreference avpf = (CheckBoxPreference) advanced.getPreference(5); avpf.setOnPreferenceChangeListener(avpfChangedListener); if (!isNewAccount) { avpf.setChecked(mPrefs.avpfEnabled(n)); } EditTextPreference avpfRRInterval = (EditTextPreference) advanced.getPreference(6); avpfRRInterval.setOnPreferenceChangeListener(avpfRRIntervalChangedListener); if (!isNewAccount) { avpfRRInterval.setText(mPrefs.getAvpfRRInterval(n)); avpfRRInterval.setSummary(mPrefs.getAvpfRRInterval(n)); } CheckBoxPreference escape = (CheckBoxPreference) advanced.getPreference(7); escape.setOnPreferenceChangeListener(escapeChangedListener); if (!isNewAccount) { escape.setChecked(mPrefs.getReplacePlusByZeroZero(n)); } CheckBoxPreference friendlistSubscribe = (CheckBoxPreference) advanced.getPreference(8); friendlistSubscribe.setOnPreferenceChangeListener(friendlistSubscribeListener); if (!isNewAccount) { friendlistSubscribe.setChecked(mPrefs.isFriendlistsubscriptionEnabled()); } Preference linkAccount = advanced.getPreference(9); linkAccount.setOnPreferenceClickListener(linkAccountListener); PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen() .findPreference(getString(R.string.pref_manage_key)); final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0); disable.setEnabled(true); disable.setOnPreferenceChangeListener(disableChangedListener); if (!isNewAccount) { disable.setChecked(!mPrefs.isAccountEnabled(n)); } CheckBoxPreference mainAccount = (CheckBoxPreference) manage.getPreference(1); mainAccount.setChecked(isDefaultAccount); mainAccount.setEnabled(!mainAccount.isChecked()); mainAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { mPrefs.setDefaultAccount(n); disable.setEnabled(false); disable.setChecked(false); preference.setEnabled(false); return true; } }); if (!isNewAccount) { mainAccount.setEnabled(!mainAccount.isChecked()); } final Preference changePassword = manage.getPreference(2); if (mPrefs.getAccountDomain(n).compareTo(getString(R.string.default_domain)) == 0) { changePassword.setEnabled(!isNewAccount); changePassword.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { final AlertDialog.Builder alert = new AlertDialog.Builder(LinphoneActivity.instance()); LayoutInflater inflater = LinphoneActivity.instance().getLayoutInflater(); View layout = inflater.inflate(R.layout.new_password, null); final EditText pass1 = (EditText) layout.findViewById(R.id.password1); final EditText pass2 = (EditText) layout.findViewById(R.id.password2); alert.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { LinphoneAccountCreator.Status status = accountCreator .setPassword(pass1.getText().toString()); if (status.equals(LinphoneAccountCreator.Status.Ok)) { if (pass1.getText().toString().compareTo(pass2.getText().toString()) == 0) { accountCreator.setUsername(mPrefs.getAccountUsername(n)); accountCreator.setHa1(mPrefs.getAccountHa1(n)); status = accountCreator.updatePassword(pass1.getText().toString()); if (!status.equals(LinphoneAccountCreator.Status.Ok)) { LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), LinphoneActivity.instance()); } else { progress = ProgressDialog.show(LinphoneActivity.instance(), null, null); Drawable d = new ColorDrawable(ContextCompat .getColor(LinphoneActivity.instance(), R.color.colorE)); d.setAlpha(200); progress.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); progress.getWindow().setBackgroundDrawable(d); progress.setContentView(R.layout.progress_dialog); progress.show(); } } else { LinphoneUtils.displayErrorAlert(getString(R.string.wizard_passwords_unmatched), LinphoneActivity.instance()); } return; } LinphoneUtils.displayErrorAlert(LinphoneUtils.errorForStatus(status), LinphoneActivity.instance()); } }); alert.setView(layout); alert.show(); return true; } }); } else { changePassword.setEnabled(false); } final Preference delete = manage.getPreference(3); delete.setEnabled(!isNewAccount); delete.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { mPrefs.deleteAccount(n); LinphoneActivity.instance().refreshAccounts(); LinphoneActivity.instance().displaySettings(); return true; } }); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Ensures that the duration of the chosen sound does not exceed a quarter of the chosen interval. *//* ww w . j a va 2 s.c o m*/ private boolean mediateSoundDurationRelatedSettings(MinutesIntervalPickerPreference preferenceFrequency, Object newUseWorkaroundBellValue, ListPreferenceWithSummaryFix preferenceReminderBell, String preferenceRingtoneValue, CheckBoxPreference preferenceSound) { return mediateSoundDurationRelatedSettings(preferenceFrequency.getTime(), (Boolean) newUseWorkaroundBellValue, preferenceReminderBell.getValue(), preferenceRingtoneValue, preferenceSound.isChecked()); }
From source file:com.nttec.everychan.chans.allchan.AllchanModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type captchaPreference.setTitle(R.string.pref_captcha_type); captchaPreference.setDialogTitle(R.string.pref_captcha_type); captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE)); captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS); captchaPreference.setEntries(CAPTCHA_TYPES); captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT); int i = Arrays.asList(CAPTCHA_TYPES_KEYS) .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT)); if (i >= 0) captchaPreference.setSummary(CAPTCHA_TYPES[i]); preferenceGroup.addPreference(captchaPreference); addHttpsPreference(preferenceGroup, true); addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup .findPreference(getSharedKey(PREF_KEY_USE_PROXY)); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override//from www .java 2s .c o m public boolean onPreferenceClick(Preference preference) { if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); } return false; } }); captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (proxyPreference.isChecked() && newValue.equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); return false; } return true; } }); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Ensures that the duration of the chosen sound does not exceed a quarter of the chosen interval. *///from w ww. j a va 2s . co m private boolean mediateSoundDurationRelatedSettings(MinutesIntervalPickerPreference preferenceFrequency, CheckBoxPreference preferenceUseWorkaroundBell, String newReminderBellValue, String preferenceRingtoneValue, CheckBoxPreference preferenceSound) { return mediateSoundDurationRelatedSettings(preferenceFrequency.getTime(), preferenceUseWorkaroundBell.isChecked(), newReminderBellValue, preferenceRingtoneValue, preferenceSound.isChecked()); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Ensures that the duration of the chosen sound does not exceed a quarter of the chosen interval. *//*from w w w . j av a2s. co m*/ private boolean mediateSoundDurationRelatedSettings(MinutesIntervalPickerPreference preferenceFrequency, CheckBoxPreference preferenceUseWorkaroundBell, ListPreferenceWithSummaryFix preferenceReminderBell, String preferenceRingtoneValue, Object newSoundValue) { return mediateSoundDurationRelatedSettings(preferenceFrequency.getTime(), preferenceUseWorkaroundBell.isChecked(), preferenceReminderBell.getValue(), preferenceRingtoneValue, (Boolean) newSoundValue); }
From source file:nya.miku.wishmaster.chans.tumbach.TumbachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type captchaPreference.setTitle(R.string.pref_captcha_type); captchaPreference.setDialogTitle(R.string.pref_captcha_type); captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE)); captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS); captchaPreference.setEntries(CAPTCHA_TYPES); captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT); int i = Arrays.asList(CAPTCHA_TYPES_KEYS) .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT)); if (i >= 0) captchaPreference.setSummary(CAPTCHA_TYPES[i]); preferenceGroup.addPreference(captchaPreference); addPasswordPreference(preferenceGroup); addHttpsPreference(preferenceGroup, true); addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup .findPreference(getSharedKey(PREF_KEY_USE_PROXY)); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override//from www . j a va 2 s .c o m public boolean onPreferenceClick(Preference preference) { if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); } return false; } }); captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (proxyPreference.isChecked() && newValue.equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); return false; } return true; } }); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Ensures that the duration of the chosen sound does not exceed a quarter of the chosen interval. *//*from w w w. ja v a2 s. c om*/ private boolean mediateSoundDurationRelatedSettings(MinutesIntervalPickerPreference preferenceFrequency, CheckBoxPreference preferenceUseWorkaroundBell, ListPreferenceWithSummaryFix preferenceReminderBell, String newRingtoneValue, CheckBoxPreference preferenceSound) { return mediateSoundDurationRelatedSettings(preferenceFrequency.getTime(), preferenceUseWorkaroundBell.isChecked(), preferenceReminderBell.getValue(), newRingtoneValue, preferenceSound.isChecked()); }
From source file:com.googlecode.mindbell.MindBellPreferences.java
/** * Ensures that the duration of the chosen sound does not exceed a quarter of the chosen interval. *//*from w w w . j a v a 2 s . co m*/ private boolean mediateSoundDurationRelatedSettings(Object newFrequencyValue, CheckBoxPreference preferenceUseWorkaroundBell, ListPreferenceWithSummaryFix preferenceReminderBell, String preferenceRingtoneValue, CheckBoxPreference preferenceSound) { return mediateSoundDurationRelatedSettings(new TimeOfDay((String) newFrequencyValue), preferenceUseWorkaroundBell.isChecked(), preferenceReminderBell.getValue(), preferenceRingtoneValue, preferenceSound.isChecked()); }