List of usage examples for android.preference CheckBoxPreference setKey
public void setKey(String key)
From source file:nya.miku.wishmaster.chans.incah.InachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); CheckBoxPreference ajaxPref = new CheckBoxPreference(context); ajaxPref.setTitle(R.string.inach_prefs_ajax_update); ajaxPref.setSummary(R.string.inach_prefs_ajax_update_summary); ajaxPref.setKey(getSharedKey(PREF_AJAX_UPDATE)); ajaxPref.setDefaultValue(true);//from w ww. ja v a 2s. co m preferenceGroup.addPreference(ajaxPref); super.addPreferencesOnScreen(preferenceGroup); }
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);//ww w.j a va2 s. c om 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.guipenedo.pokeradar.activities.settings.PokemonFilterSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory();//from w w w .j av a 2 s.c o m getDelegate().onCreate(savedInstanceState); super.onCreate(savedInstanceState); PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(this); PreferenceCategory category = new PreferenceCategory(this); category.setTitle(R.string.filter_pokemons); screen.addPreference(category); try { JSONArray pokemonList = new JSONArray(Utils.loadJSONFromFile(this, "pokemon.json")); for (int i = 0; i < pokemonList.length(); i++) { JSONObject pokemon = pokemonList.getJSONObject(i); CheckBoxPreference checkBox = new CheckBoxPreference(this); checkBox.setTitle(pokemon.getString("Name")); checkBox.setIcon(new BitmapDrawable(getResources(), Utils.bitmapForPokemon(this, Integer.parseInt(pokemon.getString("Number"))))); checkBox.setDefaultValue(true); checkBox.setSummary(String.format(getString(R.string.setting_filter_pokemon_summary), pokemon.getString("Name"))); checkBox.setKey("pref_key_show_pokemon_" + Integer.parseInt(pokemon.getString("Number"))); category.addPreference(checkBox); } } catch (JSONException e) { e.printStackTrace(); } setPreferenceScreen(screen); }
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);/*from w w w . j a v a2 s . co m*/ 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:net.freifunk.android.discover.SettingsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.pref_data_sync); // get data via the key ArrayList<NodeMap> nodeMapArrayList = new ArrayList<NodeMap>(MapMaster.getInstance().getMaps().values()); PreferenceCategory communities = (PreferenceCategory) findPreference("communities"); // sort by Name Collections.sort(nodeMapArrayList, new NodeMapComparator()); if (nodeMapArrayList != null && communities != null) { for (final NodeMap nm : nodeMapArrayList) { PreferenceScreen communityPreferenceScreen = getPreferenceManager() .createPreferenceScreen(SettingsActivity.this); communityPreferenceScreen.setTitle(nm.getMapName()); communityPreferenceScreen.setKey(nm.getMapName()); final CheckBoxPreference deactivateCommunityPreference = new CheckBoxPreference( SettingsActivity.this); // TODO: move Strings to resources deactivateCommunityPreference.setTitle("Community aktiv"); deactivateCommunityPreference .setSummary("deaktivieren, falls Community nicht auf der Karte angezeigt werden soll"); deactivateCommunityPreference.setKey("community_deactivate_" + nm.getMapName()); deactivateCommunityPreference.setChecked(nm.isActive()); deactivateCommunityPreference .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); boolean newActive = newValue.toString().equals("true") ? true : false; nm.setActive(newActive); db.addNodeMap(nm); // reload if set to active if (newActive) { nm.loadNodes(); } else { nm.updateNodes(); }/* www . jav a2 s . c o m*/ return true; } }); EditTextPreference editCommunityPreference = new EditTextPreference(SettingsActivity.this); // TODO: move Strings to resources editCommunityPreference.setTitle("URL bearbeiten"); editCommunityPreference.setSummary("aendern, falls eine andere Quelle genutzt werden soll."); editCommunityPreference.setKey("community_edit_" + nm.getMapName()); editCommunityPreference.setText(nm.getMapUrl()); editCommunityPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { Database db = Database.getInstance(null); // remove old nodes from map nm.setActive(false); EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_NODES, nm)); // we should probably do this async as well db.deleteAllNodesForMap(nm); // load new nodes NodeMap newMap = new NodeMap(nm.getMapName(), (String) newValue, true); db.addNodeMap(newMap); //HashMap<String, NodeMap> nodeResult = new HashMap<String, NodeMap>(1); //nodeResult.put(nm.getMapName(), nm); newMap.updateNodes(); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.LOAD_NODES, nm)); //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_MAP, nodeResult)); return true; } }); communityPreferenceScreen.addPreference(deactivateCommunityPreference); communityPreferenceScreen.addPreference(editCommunityPreference); communities.addPreference(communityPreferenceScreen); } } setupActionBar(); }
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);/* w w w .j a v a 2 s .c o m*/ }