List of usage examples for android.preference PreferenceCategory PreferenceCategory
public PreferenceCategory(Context context)
From source file:com.guipenedo.pokeradar.activities.settings.PokemonFilterSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { getDelegate().installViewFactory();//www. ja v a2 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.airflo.preferences.ListPreferenceActivity.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override//from w ww . j ava 2s .c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } root = getPreferenceManager().createPreferenceScreen(this); //Array of sorting preference keys to be included. //SortType must be specified in bookitems.xml! String[] sortValues = new String[] { "number", "date;starttime", "site;date;starttime", "duration", "maxheight", "maxvario", "starttype;date;starttime" }; //Generate according Entry Strings. String[] sortEntries = new String[sortValues.length]; for (int i = 0; i < sortEntries.length; i++) sortEntries[i] = sortKeyToString(sortValues[i]); //Make sorting category PreferenceCategory cat = new PreferenceCategory(this); cat.setTitle(R.string.list_pref_cat_sort_title); root.addPreference(cat); final ListPreference listPref = new ListPreference(this); listPref.setKey("list_pref_sort"); listPref.setEntries(sortEntries); listPref.setEntryValues(sortValues); listPref.setDialogTitle(R.string.list_pref_sort_criterium); listPref.setSummary(sortKeyToString(root.getSharedPreferences().getString("list_pref_sort", "number"))); listPref.setTitle(R.string.list_pref_sort_criterium); cat.addPreference(listPref); listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { listPref.setSummary(sortKeyToString((String) newValue)); return true; } }); final ListPreference orderPref = new ListPreference(this); orderPref.setKey("list_pref_order"); orderPref.setEntries(new String[] { OnlyContext.rString("list_pref_sort_ascending"), OnlyContext.rString("list_pref_sort_decending") }); orderPref.setEntryValues(new String[] { "list_pref_sort_ascending", "list_pref_sort_decending" }); orderPref.setDialogTitle(R.string.list_pref_sort_sequence); orderPref.setSummary(OnlyContext .rString(root.getSharedPreferences().getString("list_pref_order", "list_pref_sort_decending"))); orderPref.setTitle(R.string.list_pref_sort_sequence); cat.addPreference(orderPref); orderPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { orderPref.setSummary(OnlyContext.rString((String) newValue)); return true; } }); //Make item categories addManyListItems(R.string.list_pref_cat1_title, "listhead", 3); addManyListItems(R.string.list_pref_cat2_title, "listsub", 3); this.setPreferenceScreen(root); }
From source file:nya.miku.wishmaster.chans.endchan.EndChanModule.java
private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override/* w w w .j a va 2s . c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { updateDomain((String) 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); }
From source file:com.fhhst.prodroid.gui.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*from ww w. ja v a2s . c o m*/ */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'printer' preferences. addPreferencesFromResource(R.xml.pref_printer); if (getPreferenceScreen() != null) { // Add 'notifications' preferences, and a corresponding header. PreferenceCategory fakeHeader1 = new PreferenceCategory(this); fakeHeader1.setTitle(R.string.pref_header_communication); getPreferenceScreen().addPreference(fakeHeader1); addPreferencesFromResource(R.xml.pref_communication); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("pref_comm_baudrateselect")); bindPreferenceSummaryToValue(findPreference("pref_comm_databitsselect")); bindPreferenceSummaryToValue(findPreference("pref_comm_stopbitsselect")); bindPreferenceSummaryToValue(findPreference("pref_comm_paritybitselect")); bindPreferenceSummaryToValue(findPreference("pref_comm_webserver_port")); bindPreferenceSummaryToValue(findPreference("pref_print_xyfeedrate")); bindPreferenceSummaryToValue(findPreference("pref_print_zfeedrate")); bindPreferenceSummaryToValue(findPreference("pref_print_efeedrate")); Preference button = (Preference) findPreference("pref_comm_dropbx"); button.setEnabled(false); } }
From source file:io.northernlights.logcleaner.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*w ww.ja v a2 s . c om*/ */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_notifications); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_notification); }
From source file:pro.jariz.reisplanner.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.// w w w. j a v a2 s . co m */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_notifications); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_notification); // Add 'data and sync' preferences, and a corresponding header. fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_data_sync); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_data_sync); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("example_text")); bindPreferenceSummaryToValue(findPreference("example_list")); bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone")); bindPreferenceSummaryToValue(findPreference("sync_frequency")); }
From source file:org.segin.ttleditor.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*w ww. ja v a2 s.com*/ */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } ActionBar actionBar = getActionBar(); try { actionBar.setIcon(getResources().getDrawable(R.drawable.ic_settings)); } catch (Exception e) { e.printStackTrace(); } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'notifications' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_debug); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_debug); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. bindPreferenceSummaryToValue(findPreference("iface")); bindPreferenceSummaryToValue(findPreference("ttl")); Preference sharePref = (Preference) findPreference("share"); sharePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text)); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_subject)); sendIntent.setType("text/plain"); startActivity(sendIntent); return true; } }); }
From source file:com.probam.updater.activity.GooActivity.java
@SuppressWarnings("deprecation") @Override/*ww w .ja va2 s .co m*/ protected void onCreate(Bundle savedInstanceState) { boolean useDarkTheme = ManagerFactory.getPreferencesManager(this).isDarkTheme(); setTheme(useDarkTheme ? R.style.DarkTheme : R.style.AppTheme); super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.empty_pref_screen); PreferenceScreen pScreen = getPreferenceScreen(); mInfos = new HashMap<String, PackageInfo>(); if (CURRENT_NAVIGATION == null) { Preference preference = null; preference = new Preference(this); preference.getExtras().putBoolean("BROWSING_ALL", false); preference.getExtras().putBoolean("FOLDER", true); preference.getExtras().putString("PATH", "/devs"); preference.setKey(Constants.GOO_SEARCH_URL + "/devs&ro_board=" + mDevice); preference.setTitle(R.string.goo_browse_all_compatible); pScreen.addPreference(preference); preference = new Preference(this); preference.getExtras().putBoolean("BROWSING_ALL", true); preference.getExtras().putBoolean("FOLDER", true); preference.getExtras().putString("PATH", "/devs"); preference.setKey(Constants.GOO_SEARCH_URL + "/devs"); preference.setTitle(R.string.goo_browse_all); pScreen.addPreference(preference); preference = new Preference(this); preference.getExtras().putBoolean("BROWSING_ALL", false); preference.getExtras().putBoolean("FOLDER", false); preference.getExtras().putString("PATH", ""); preference.setKey("watchlist"); preference.setTitle(R.string.goo_browse_watchlist); pScreen.addPreference(preference); } else { if ("watchlist".equals(CURRENT_FOLDER)) { PreferenceCategory category = new PreferenceCategory(this); category.setKey("category"); category.setTitle( getResources().getString(R.string.goo_category_title, new Object[] { CURRENT_FOLDER })); pScreen.addPreference(category); refreshWatchlist(); } else { PreferenceCategory category = new PreferenceCategory(this); category.setTitle( getResources().getString(R.string.goo_category_title, new Object[] { CURRENT_FOLDER })); pScreen.addPreference(category); try { JSONObject object = (JSONObject) new JSONTokener(CURRENT_NAVIGATION).nextValue(); JSONArray list = object.getJSONArray("list"); for (int i = 0; i < list.length(); i++) { JSONObject result = list.getJSONObject(i); String fileName = result.optString("filename"); if (fileName != null && !"".equals(fileName.trim())) { String path = result.optString("path"); if (!BROWSING_ALL && !mDevice.equals(result.optString("ro_board"))) { continue; } GooPackage info = new GooPackage(result, -1); mInfos.put(path, info); Preference preference = new Preference(this); preference.getExtras().putBoolean("FOLDER", false); preference.setKey(path); preference.setTitle(fileName); preference.setSummary(path); category.addPreference(preference); } else { String folder = result.optString("folder"); String folderName = folder.substring(folder.lastIndexOf("/") + 1); Preference preference = new FolderPreference(this, folder, false); preference.getExtras().putBoolean("BROWSING_ALL", BROWSING_ALL); preference.getExtras().putBoolean("FOLDER", true); preference.getExtras().putString("PATH", folder); if (!BROWSING_ALL) { preference.setKey(Constants.GOO_SEARCH_URL + folder + "&ro_board=" + mDevice); } else { preference.setKey(Constants.GOO_SEARCH_URL + folder); } preference.setTitle(folderName); preference.setSummary(folder); category.addPreference(preference); } } } catch (Exception ex) { ex.printStackTrace(); Toast.makeText(this, R.string.goo_browse_error, Toast.LENGTH_LONG).show(); } } } if (DIALOG != null) DIALOG.dismiss(); DIALOG = null; ListView listView = getListView(); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ListView listView = (ListView) parent; ListAdapter listAdapter = listView.getAdapter(); Object obj = listAdapter.getItem(position); if (obj != null && obj instanceof View.OnLongClickListener) { View.OnLongClickListener longListener = (View.OnLongClickListener) obj; return longListener.onLongClick(view); } return false; } }); }
From source file:blackman.matt.Settings.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown.//from ww w . ja va2 s . c o m */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.pref_general); // Add 'data and sync' preferences, and a corresponding header. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_data_sync); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_data_sync); bindPreferenceSummaryToValue(findPreference("default_board")); bindPreferenceSummaryToValue(findPreference("sync_frequency")); }
From source file:de.azapps.mirakel.settings.model_settings.special_list.SpecialListDetailFragment.java
@NonNull private List<Preference> getPrefernces() { List<Preference> preferences = new ArrayList<>(); PreferenceCategory summary = new PreferenceCategory(getActivity()); summary.setTitle(R.string.special_list_summary); preferences.add(summary);//from www . j a v a 2s .co m final EditTextPreference name = getNamePreference(); preferences.add(name); final CheckBoxPreference active = getIsActivePreference(); preferences.add(active); if (!MirakelCommonPreferences.isDebug()) { final Preference where = getWhereStringPreference(); preferences.add(where); } PreferenceCategory defaultValues = new PreferenceCategory(getActivity()); defaultValues.setTitle(R.string.special_lists_defaults); preferences.add(defaultValues); final Preference defList = getDefaultListPreference(); preferences.add(defList); final Preference defDate = getDefaultDatePreference(); preferences.add(defDate); PreferenceCategory conditions = new PreferenceCategory(getActivity()); conditions.setTitle(R.string.special_lists_condition_title); preferences.add(conditions); return preferences; }