List of usage examples for android.preference PreferenceCategory addPreference
public boolean addPreference(Preference preference)
From source file:org.namelessrom.devicecontrol.ui.views.CustomPreferenceFragment.java
protected void isSupported(final PreferenceCategory preferenceCategory, final Context context, final int sId) { if (preferenceCategory.getPreferenceCount() == 0) { preferenceCategory.addPreference(createPreference(context, sId)); }/* ww w. j a v a2 s. co m*/ }
From source file:org.namelessrom.devicecontrol.device.DeviceInformationGeneralFragment.java
private CustomPreference addPreference(final PreferenceCategory category, final String key, final String title, final String summary) { final CustomPreference preference = new CustomPreference(getActivity()); preference.setKey(key);// www. ja v a2s . c o m preference.setTitle(title); preference.setSummary(TextUtils.isEmpty(summary) ? getString(R.string.unknown) : summary); category.addPreference(preference); return preference; }
From source file:com.airflo.preferences.ListPreferenceActivity.java
/** * Add one slider preference to the category. * @param cat//from ww w .j a v a 2 s. c o m * @param key * @param title */ private void addOneListItem(PreferenceCategory cat, String key, String title) { final ListPreference listPref = new ListPreference(this); listPref.setKey(key); listPref.setEntries(FlightData.identis.getPrefListChars(true)); listPref.setEntryValues(FlightData.identis.getPrefListChars(false)); listPref.setDialogTitle(title); listPref.setSummary( FlightData.identis.getIdenti(root.getSharedPreferences().getString(key, "empty")).getStringRep()); listPref.setTitle(title); cat.addPreference(listPref); listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { listPref.setSummary(FlightData.identis.getIdenti((String) newValue).getStringRep()); return true; } }); }
From source file:com.anysoftkeyboard.ui.settings.KeyboardAddOnSettingsFragment.java
@Override public void onStart() { super.onStart(); PreferenceCategory keyboardsGroup = (PreferenceCategory) findPreference("keyboard_addons_group"); Activity activity = getActivity();/*from w w w. j a va 2 s .co m*/ PassengerFragmentSupport.setActivityTitle(this, getString(R.string.keyboards_group)); // getting all keyboards final ArrayList<KeyboardAddOnAndBuilder> creators = KeyboardFactory .getAllAvailableKeyboards(activity.getApplicationContext()); keyboardsGroup.removeAll(); for (final KeyboardAddOnAndBuilder creator : creators) { final AddOnCheckBoxPreference checkBox = new AddOnCheckBoxPreference(activity, null, R.style.Theme_AppCompat_Light); checkBox.setAddOn(creator); keyboardsGroup.addPreference(checkBox); } }
From source file:com.airflo.preferences.ListPreferenceActivity.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override/* w w w . j a v a2 s.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//from ww w . j av a 2 s .com 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:org.wordpress.android.ui.prefs.SettingsFragment.java
private void addWpComShowHideButton(PreferenceCategory wpComCategory, int order) { if (WordPress.wpDB.getNumDotComAccounts() > 0) { Preference manageBlogPreference = new Preference(getActivity()); manageBlogPreference.setTitle(R.string.show_and_hide_blogs); Intent intentManage = new Intent(getActivity(), ManageBlogsActivity.class); manageBlogPreference.setIntent(intentManage); manageBlogPreference.setOrder(order); wpComCategory.addPreference(manageBlogPreference); }/* www.j a v a 2 s . com*/ }
From source file:org.wordpress.android.ui.prefs.SettingsFragment.java
private void addWpComSignIn(PreferenceCategory wpComCategory, int order) { if (WordPress.hasDotComToken(getActivity())) { String username = mSettings.getString(WordPress.WPCOM_USERNAME_PREFERENCE, null); Preference usernamePref = new Preference(getActivity()); usernamePref.setTitle(getString(R.string.username)); usernamePref.setSummary(username); usernamePref.setSelectable(false); usernamePref.setOrder(order);//w ww.j av a 2 s.co m wpComCategory.addPreference(usernamePref); Preference createWPComBlogPref = new Preference(getActivity()); createWPComBlogPref.setTitle(getString(R.string.create_new_blog_wpcom)); Intent intent = new Intent(getActivity(), NewBlogActivity.class); createWPComBlogPref.setIntent(intent); createWPComBlogPref.setOrder(order + 1); wpComCategory.addPreference(createWPComBlogPref); } else { Preference signInPref = new Preference(getActivity()); signInPref.setTitle(getString(R.string.sign_in)); signInPref.setOnPreferenceClickListener(signInPreferenceClickListener); wpComCategory.addPreference(signInPref); PreferenceScreen rootScreen = (PreferenceScreen) findPreference( getActivity().getString(R.string.pref_key_settings_root)); PreferenceGroup notificationsGroup = (PreferenceGroup) findPreference( getActivity().getString(R.string.pref_key_notifications_section)); if (notificationsGroup != null) { rootScreen.removePreference(notificationsGroup); } } }
From source file:nya.miku.wishmaster.api.AbstractChanModule.java
/** * ( ?/ ) ? ?-?/*from w w w. j a va 2 s.c om*/ * @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:com.probam.updater.activity.GooActivity.java
@SuppressWarnings("deprecation") public void refreshWatchlist() { PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference("category"); category.removeAll();/*from ww w.ja v a 2 s.c o m*/ String[] watchlist = getWatchlist(); for (String folder : watchlist) { if (!"".equals(folder)) { Preference preference = new FolderPreference(this, folder, true); preference.getExtras().putBoolean("BROWSING_ALL", true); preference.getExtras().putBoolean("FOLDER", true); preference.getExtras().putString("PATH", folder); preference.setKey(Constants.GOO_SEARCH_URL + folder); preference.setTitle(folder); preference.setSummary(folder); category.addPreference(preference); } } }