List of usage examples for android.preference CheckBoxPreference setDefaultValue
public void setDefaultValue(Object defaultValue)
From source file:com.esminis.server.library.activity.DrawerFragment.java
protected CheckBoxPreference createPreferenceCheckbox(Context context, String key, boolean defaultValue, @StringRes int title, @StringRes int summary) { final CheckBoxPreference preference = new CheckBoxPreference(context); preference.setTitle(title);//from w w w. j a va 2 s.co m preference.setDefaultValue(defaultValue); preference.setSummary(summary); preference.setKey(key); return preference; }
From source file:com.guipenedo.pokeradar.activities.settings.PokemonFilterSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory();//from w w w. j a va 2 s. co 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:de.tum.in.tumcampus.fragments.SettingsFragment.java
private void populateNewsSources() { PreferenceCategory news_sources = (PreferenceCategory) findPreference("card_news_sources"); NewsManager cm = new NewsManager(mContext); Cursor cur = cm.getNewsSources(); if (cur.moveToFirst()) { do {/*from w w w .ja va 2 s. co m*/ final CheckBoxPreference pref = new CheckBoxPreference(mContext); pref.setKey("card_news_source_" + cur.getString(0)); pref.setDefaultValue(true); if (Build.VERSION.SDK_INT >= 11) { // Load news source icon in background and set it final String url = cur.getString(1); new Thread(new Runnable() { @Override public void run() { NetUtils net = new NetUtils(mContext); final Bitmap bmp = net.downloadImageToBitmap(url); mContext.runOnUiThread(new Runnable() { @TargetApi(11) @Override public void run() { pref.setIcon(new BitmapDrawable(getResources(), bmp)); } }); } }).start(); } pref.setTitle(cur.getString(2)); news_sources.addPreference(pref); } while (cur.moveToNext()); } cur.close(); }
From source file:nya.miku.wishmaster.api.AbstractWakabaModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasswordPreference(preferenceGroup); if (canHttps()) { CheckBoxPreference httpsPref = new 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(useHttpsDefaultValue()); preferenceGroup.addPreference(httpsPref); addUnsafeSslPreference(preferenceGroup, getSharedKey(PREF_KEY_USE_HTTPS)); }//from ww w.j a v a 2 s. c o m addProxyPreferences(preferenceGroup); }
From source file:com.mattprecious.notisync.preferences.DevicePreferenceFragment.java
@Override public void onResume() { super.onResume(); BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { return;//from w ww. j av a2 s . c om } PreferenceScreen screen = getPreferenceScreen(); screen.removeAll(); Set<String> selectedDevices = Preferences.getDevices(getActivity()); // Get a set of currently paired devices Set<BluetoothDevice> pairedDevices = btAdapter.getBondedDevices(); for (BluetoothDevice device : pairedDevices) { CheckBoxPreference preference = new CheckBoxPreference(getActivity()); preference.setOnPreferenceChangeListener(preferenceListener); preference.setTitle(device.getName()); preference.setSummary(device.getAddress()); int iconResId = Helpers.getBtClassDrawable(device); if (iconResId != 0) { preference.setIcon(iconResId); } if (selectedDevices.contains(device.getAddress())) { preference.setDefaultValue(true); localDeviceSet.add(device.getAddress()); } getPreferenceScreen().addPreference(preference); } }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) -? " SSL"// w w w. ja v a2s.com * @param group , ??? * @param dependencyKey -?? ? , null */ protected void addUnsafeSslPreference(PreferenceGroup group, String dependencyKey) { final Context context = group.getContext(); CheckBoxPreference unsafeSslPref = new CheckBoxPreference(context); //? " SSL" unsafeSslPref.setTitle(R.string.pref_ignore_ssl_errors); unsafeSslPref.setSummary(R.string.pref_ignore_ssl_errors_summary); unsafeSslPref.setKey(getSharedKey(PREF_KEY_UNSAFE_SSL)); unsafeSslPref.setDefaultValue(false); unsafeSslPref.setOnPreferenceChangeListener(updateHttpListener); group.addPreference(unsafeSslPref); if (dependencyKey != null) unsafeSslPref.setDependency(dependencyKey); }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?//from w w w . j a va 2 s . co m * @param group , ??? */ protected void addProxyPreferences(PreferenceGroup group) { final Context context = group.getContext(); PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ? proxyCat.setTitle(R.string.pref_cat_proxy); group.addPreference(proxyCat); CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "? ? " useProxyPref.setTitle(R.string.pref_use_proxy); useProxyPref.setSummary(R.string.pref_use_proxy_summary); useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY)); useProxyPref.setDefaultValue(false); useProxyPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(useProxyPref); EditTextPreference proxyHostPref = new EditTextPreference(context); // ? ?-? proxyHostPref.setTitle(R.string.pref_proxy_host); proxyHostPref.setDialogTitle(R.string.pref_proxy_host); proxyHostPref.setSummary(R.string.pref_proxy_host_summary); proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST)); proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST); proxyHostPref.getEditText().setSingleLine(); proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); proxyHostPref.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPref); proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); EditTextPreference proxyHostPort = new EditTextPreference(context); // ?-? proxyHostPort.setTitle(R.string.pref_proxy_port); proxyHostPort.setDialogTitle(R.string.pref_proxy_port); proxyHostPort.setSummary(R.string.pref_proxy_port_summary); proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT)); proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT); proxyHostPort.getEditText().setSingleLine(); proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER); proxyHostPort.setOnPreferenceChangeListener(updateHttpListener); proxyCat.addPreference(proxyHostPort); proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY)); }
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); preferenceGroup.addPreference(ajaxPref); super.addPreferencesOnScreen(preferenceGroup); }
From source file:nya.miku.wishmaster.chans.nullchancc.NullchanccModule.java
private void addOnlyNewPostsPreference(PreferenceGroup group) { Context context = group.getContext(); CheckBoxPreference onlyNewPostsPreference = new CheckBoxPreference(context); onlyNewPostsPreference.setTitle(R.string.nullchancc_prefs_only_new_posts); onlyNewPostsPreference.setSummary(R.string.nullchancc_prefs_only_new_posts_summary); onlyNewPostsPreference.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS)); onlyNewPostsPreference.setDefaultValue(true); group.addItemFromInflater(onlyNewPostsPreference); }