Java Code Examples for android.preference.CheckBoxPreference#setKey()
The following examples show how to use
android.preference.CheckBoxPreference#setKey() .
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: SettingsActivity.java From nitroshare-android with MIT License | 6 votes |
/** * Create a SwitchPreference for the specified preference * @param titleResId resource ID to use for the title * @param summaryResId resource ID to use for the summary * @param key preference key * @return newly created preference */ private CheckBoxPreference createCheckBoxPreference(@StringRes int titleResId, @StringRes int summaryResId, Settings.Key key) { final CheckBoxPreference checkBoxPreference = new CheckBoxPreference(getActivity()); checkBoxPreference.setDefaultValue(mSettings.getDefault(key)); checkBoxPreference.setKey(key.name()); checkBoxPreference.setSummary(summaryResId); checkBoxPreference.setTitle(titleResId); checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { checkBoxPreference.setChecked((boolean) newValue); return true; } }); return checkBoxPreference; }
Example 2
Source File: FiltersPrefFragment.java From Onosendai with Apache License 2.0 | 6 votes |
protected void refreshFiltersList () { getPreferenceScreen().removeAll(); final CheckBoxPreference showFiltered = new CheckBoxPreference(getActivity()); showFiltered.setKey(KEY_SHOW_FILTERED); showFiltered.setTitle("Show filtered"); //ES showFiltered.setSummary("For testing filters. Does not work on seamless columns."); //ES getPreferenceScreen().addPreference(showFiltered); final Preference reapplyFilters = new Preference(getActivity()); reapplyFilters.setTitle("Reapply Filters"); //ES reapplyFilters.setSummary("Apply filter rules to already downloaded tweets"); //ES reapplyFilters.setOnPreferenceClickListener(this.reapplyFiltersListener); getPreferenceScreen().addPreference(reapplyFilters); final Preference addFilter = new Preference(getActivity()); addFilter.setTitle("Add Filter"); //ES addFilter.setSummary("Plain string or regex"); //ES addFilter.setOnPreferenceClickListener(new AddFilterClickListener(this)); getPreferenceScreen().addPreference(addFilter); for (final String filterId : getPrefs().readFilterIds()) { final String filter = getPrefs().readFilter(filterId); getPreferenceScreen().addPreference(new FilterDialogPref(getActivity(), filterId, filter, this)); } }
Example 3
Source File: DvachModule.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
@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); }
Example 4
Source File: FakeSignatureGlobalUI.java From haystack with GNU General Public License v3.0 | 6 votes |
static CheckBoxPreference addPreference(PreferenceFragment fragment) { //>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) { PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY); if (pg != null) { /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext()); //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext()); p.setKey(PREFERENCE_KEY); p.setTitle(PREFERENCE_TITLE); p.setSummary(PREFERENCE_SUMMARY); p.setPersistent(false); pg.addPreference(p); return p; } else { Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category"); return null; } }
Example 5
Source File: FakeSignatureGlobalUI.java From haystack with GNU General Public License v3.0 | 6 votes |
static CheckBoxPreference addPreference(PreferenceFragment fragment) { //>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) { PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY); if (pg != null) { /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext()); //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext()); p.setKey(PREFERENCE_KEY); p.setTitle(PREFERENCE_TITLE); p.setSummary(PREFERENCE_SUMMARY); p.setPersistent(false); pg.addPreference(p); return p; } else { Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category"); return null; } }
Example 6
Source File: FakeSignatureGlobalUI.java From haystack with GNU General Public License v3.0 | 6 votes |
static CheckBoxPreference addPreference(PreferenceFragment fragment) { //>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) { PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY); if (pg != null) { /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext()); //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext()); p.setKey(PREFERENCE_KEY); p.setTitle(PREFERENCE_TITLE); p.setSummary(PREFERENCE_SUMMARY); p.setPersistent(false); pg.addPreference(p); return p; } else { Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category"); return null; } }
Example 7
Source File: CloudflareChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
protected void addCloudflareRecaptchaFallbackPreference(PreferenceGroup preferenceGroup) { if (canCloudflare()) { Context context = preferenceGroup.getContext(); CheckBoxPreference fallbackPref = new LazyPreferences.CheckBoxPreference(context); fallbackPref.setTitle(R.string.pref_cf_recaptcha_fallback); fallbackPref.setSummary(R.string.pref_cf_recaptcha_fallback_summary); fallbackPref.setKey(getSharedKey(PREF_KEY_CLOUDFLARE_RECAPTCHA_FALLBACK)); fallbackPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackPref); } }
Example 8
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static CheckBoxPreference Check(Context context, PreferenceCategory category, int caption, int summary, String key, Object defaultValue, boolean enabled) { CheckBoxPreference retval = new CheckBoxPreference(context); if (caption > 0) retval.setTitle(caption); if (summary > 0) retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); if (category != null) category.addPreference(retval); return retval; }
Example 9
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) настройку выбора HTTPS (защищённого соединения). * Для хранения используется ключ общих параметров {@link #PREF_KEY_USE_HTTPS} ({@link #getSharedKey(String)}). * См. также: {@link #useHttps(boolean)} - для получения значения параметра. * @param group группа, на которую добавляется параметр * @param defaultValue значение параметра по умолчанию * return объект {@link CheckBoxPreference} с параметром */ protected CheckBoxPreference addHttpsPreference(PreferenceGroup group, boolean defaultValue) { final Context context = group.getContext(); CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); httpsPref.setTitle(R.string.pref_use_https); httpsPref.setSummary(R.string.pref_use_https_summary); httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS)); httpsPref.setDefaultValue(defaultValue); group.addPreference(httpsPref); return httpsPref; }
Example 10
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) настройку выбора использования инкрементальной загрузки (загрузки только новых постов). * Для хранения используется ключ общих параметров {@link #PREF_KEY_ONLY_NEW_POSTS} ({@link #getSharedKey(String)}). * См. также: {@link #loadOnlyNewPosts(boolean)} - для получения значения параметра. * @param group группа, на которую добавляется параметр * @param defaultValue значение параметра по умолчанию * return объект {@link CheckBoxPreference} с параметром */ protected CheckBoxPreference addOnlyNewPostsPreference(PreferenceGroup group, boolean defaultValue) { final Context context = group.getContext(); CheckBoxPreference onlyNewPostsPref = new LazyPreferences.CheckBoxPreference(context); onlyNewPostsPref.setTitle(R.string.pref_only_new_posts); onlyNewPostsPref.setSummary(R.string.pref_only_new_posts_summary); onlyNewPostsPref.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS)); onlyNewPostsPref.setDefaultValue(defaultValue); group.addPreference(onlyNewPostsPref); return onlyNewPostsPref; }
Example 11
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
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); }
Example 12
Source File: HorochanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@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); }
Example 13
Source File: FetchingPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addSyncScroll () { final CheckBoxPreference pref = new CheckBoxPreference(getActivity()); pref.setKey(KEY_SYNC_SCROLL); pref.setTitle("Sync column scroll position"); //ES pref.setSummary("But only if last scroll was upward."); //ES getPreferenceScreen().addPreference(pref); }
Example 14
Source File: MakabaModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** Добавить категорию настроек домена (в т.ч. https) */ private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override 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); }
Example 15
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static CheckBoxPreference Check(Context context, PreferenceCategory category, String caption, String summary, String key, Object defaultValue, boolean enabled) { CheckBoxPreference retval = new CheckBoxPreference(context); retval.setTitle(caption); retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); if (category != null) category.addPreference(retval); return retval; }
Example 16
Source File: BasePreferenceFragment.java From Dashchan with Apache License 2.0 | 5 votes |
public CheckBoxPreference makeCheckBox(PreferenceGroup parent, boolean persistent, String key, boolean defaultValue, CharSequence title, CharSequence summary) { CheckBoxPreference preference = new CheckBoxPreference(getActivity()); preference.setPersistent(persistent); preference.setKey(key); preference.setTitle(title); if (summary != null) { preference.setSummary(summary); } preference.setDefaultValue(defaultValue); addPreference(parent, preference); return preference; }
Example 17
Source File: PreferenceMatchersTest.java From android-test with Apache License 2.0 | 5 votes |
@Test public void withKeyTest() { CheckBoxPreference pref = new CheckBoxPreference(getApplicationContext()); pref.setKey("foo"); assertThat(pref, withKey("foo")); assertThat(pref, not(withKey("bar"))); assertThat(pref, withKey(is("foo"))); }
Example 18
Source File: UiPrefFragment.java From Onosendai with Apache License 2.0 | 4 votes |
private void addColumnsRtl () { final CheckBoxPreference pref = new CheckBoxPreference(getActivity()); pref.setKey(KEY_COLUMNS_RTL); pref.setTitle("Columns RTL"); //ES getPreferenceScreen().addPreference(pref); }
Example 19
Source File: NotifySettingsActivity.java From AndroidPNClient with Apache License 2.0 | 4 votes |
private PreferenceScreen createPreferenceHierarchy() { Log.d(LOGTAG, "createSettingsPreferenceScreen()..."); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME); preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE); PreferenceScreen root = preferenceManager.createPreferenceScreen(this); // PreferenceCategory prefCat = new PreferenceCategory(this); // // inlinePrefCat.setTitle(""); // root.addPreference(prefCat); CheckBoxPreference notifyPref = new CheckBoxPreference(this); notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED); notifyPref.setTitle(R.string.notifications_enabled); notifyPref.setSummaryOn(R.string.receive_push_messages); notifyPref.setSummaryOff(R.string.do_not_receive_push_messages); notifyPref.setDefaultValue(Boolean.TRUE); notifyPref .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); if (checked) { preference.setTitle(R.string.notifications_enabled); } else { preference.setTitle(R.string.notifications_disabled); } return true; } }); CheckBoxPreference soundPref = new CheckBoxPreference(this); soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED); soundPref.setTitle(R.string.sound); soundPref.setSummary(R.string.play_sound_for_notifications); soundPref.setDefaultValue(Boolean.TRUE); // soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); CheckBoxPreference vibratePref = new CheckBoxPreference(this); vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED); vibratePref.setTitle(R.string.vibrate); vibratePref.setSummary(R.string.vibrate_the_phone_for_notifications); vibratePref.setDefaultValue(Boolean.TRUE); // vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED); root.addPreference(notifyPref); root.addPreference(soundPref); root.addPreference(vibratePref); // prefCat.addPreference(notifyPref); // prefCat.addPreference(soundPref); // prefCat.addPreference(vibratePref); // root.addPreference(prefCat); return root; }
Example 20
Source File: NotificationSettingsActivity.java From AndroidPNClient with Apache License 2.0 | 4 votes |
private PreferenceScreen createPreferenceHierarchy() { Log.d(LOGTAG, "createSettingsPreferenceScreen()..."); PreferenceManager preferenceManager = getPreferenceManager(); preferenceManager .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME); preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE); PreferenceScreen root = preferenceManager.createPreferenceScreen(this); CheckBoxPreference notifyPref = new CheckBoxPreference(this); notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED); notifyPref.setTitle("Notifications Enabled"); notifyPref.setSummaryOn("Receive push messages"); notifyPref.setSummaryOff("Do not receive push messages"); notifyPref.setDefaultValue(Boolean.TRUE); notifyPref .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { boolean checked = Boolean.valueOf(newValue.toString()); if (checked) { preference.setTitle("Notifications Enabled"); } else { preference.setTitle("Notifications Disabled"); } return true; } }); CheckBoxPreference soundPref = new CheckBoxPreference(this); soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED); soundPref.setTitle("Sound"); soundPref.setSummary("Play a sound for notifications"); soundPref.setDefaultValue(Boolean.TRUE); CheckBoxPreference vibratePref = new CheckBoxPreference(this); vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED); vibratePref.setTitle("Vibrate"); vibratePref.setSummary("Vibrate the phone for notifications"); vibratePref.setDefaultValue(Boolean.TRUE); root.addPreference(notifyPref); root.addPreference(soundPref); root.addPreference(vibratePref); return root; }