List of usage examples for android.preference CheckBoxPreference setDefaultValue
public void setDefaultValue(Object defaultValue)
From source file:com.nttec.everychan.chans.dvach.DvachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false); onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); preferenceGroup.addPreference(domainPref); domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:com.nttec.everychan.chans.infinity.InfinityModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); CheckBoxPreference httpsPref = addHttpsPreference(preferenceGroup, true); CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context); onionPref.setTitle(R.string.pref_use_onion); onionPref.setSummary(R.string.pref_use_onion_summary); onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION)); onionPref.setDefaultValue(false); onionPref.setDisableDependentsState(true); preferenceGroup.addPreference(onionPref); httpsPref.setDependency(getSharedKey(PREF_KEY_USE_ONION)); addProxyPreferences(preferenceGroup); }
From source file:com.nttec.everychan.chans.horochan.HorochanModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); // recaptcha fallback fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback); fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary); fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_RECAPTCHA_FALLBACK)); fallbackRecaptchaPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackRecaptchaPref); addHttpsPreference(preferenceGroup, true); //https addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); }
From source file:com.prey.activities.PreyConfigurationSMSActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences_sms); PreyStatus.getInstance().setPreyConfigurationActivityResume(true); try {// w ww .j a va 2 s . com CheckBoxPreference pSMS = (CheckBoxPreference) findPreference("PREFS_SMS_COMMAND"); PreyConfig preyConfig = PreyConfig.getPreyConfig(getApplicationContext()); PreyLogger.i("preyConfig.isSmsCommand:" + preyConfig.isSmsCommand()); pSMS.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { CheckBoxPreference pSMS = (CheckBoxPreference) findPreference("PREFS_SMS_COMMAND"); PreyLogger.i("preyConfig.newValue:" + newValue); boolean value = ((Boolean) newValue).booleanValue(); PreyConfig.getPreyConfig(getApplicationContext()).setSmsCommand(value); pSMS.setChecked(value); pSMS.setDefaultValue(value); if (value) { requestPermission(); ; } return false; } }); if (!preyConfig.isSmsCommand()) { pSMS.setChecked(false); pSMS.setDefaultValue(false); } else { pSMS.setChecked(true); pSMS.setDefaultValue(true); } } catch (Exception e) { } setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
From source file:com.nttec.everychan.chans.dobrochan.DobroModule.java
private void addCaptchaPreference(PreferenceGroup group) { Context context = group.getContext(); CheckBoxPreference showCaptchaPreference = new LazyPreferences.CheckBoxPreference(context); showCaptchaPreference.setTitle(R.string.dobrochan_prefs_show_captcha); showCaptchaPreference.setSummary(R.string.dobrochan_prefs_show_captcha_summary); showCaptchaPreference.setKey(getSharedKey(PREF_KEY_SHOW_CAPTCHA)); showCaptchaPreference.setDefaultValue(false); group.addPreference(showCaptchaPreference); }
From source file:com.nttec.everychan.chans.makaba.MakabaModule.java
private void addMobileAPIPreference(PreferenceGroup group) { final Context context = group.getContext(); CheckBoxPreference mobileAPIPref = new LazyPreferences.CheckBoxPreference(context); mobileAPIPref.setTitle(R.string.makaba_prefs_mobile_api); mobileAPIPref.setSummary(R.string.pref_only_new_posts_summary); mobileAPIPref.setKey(getSharedKey(PREF_KEY_MOBILE_API)); mobileAPIPref.setDefaultValue(true); group.addPreference(mobileAPIPref);//from w w w.j av a2 s. com }
From source file:com.nttec.everychan.chans.makaba.MakabaModule.java
/** ? ( .. https) */ private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override//from www . j av a 2 s .c om public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true)); return true; } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) { updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean) newValue); return true; } return false; } }; PreferenceCategory domainCat = new PreferenceCategory(context); domainCat.setTitle(R.string.makaba_prefs_domain_category); group.addPreference(domainCat); EditTextPreference domainPref = new EditTextPreference(context); // domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.getEditText().setHint(DEFAULT_DOMAIN); domainPref.getEditText().setSingleLine(); domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); domainPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(domainPref); CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //? "? https" httpsPref.setTitle(R.string.pref_use_https); httpsPref.setSummary(R.string.pref_use_https_summary); httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA)); httpsPref.setDefaultValue(true); httpsPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(httpsPref); }