List of usage examples for android.preference PreferenceCategory removeAll
public void removeAll()
From source file:com.probam.updater.activity.GooActivity.java
@SuppressWarnings("deprecation") public void refreshWatchlist() { PreferenceCategory category = (PreferenceCategory) getPreferenceScreen().findPreference("category"); category.removeAll(); 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); }//from ww w . ja va 2s . c o m } }
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 www . j av a2 s . com*/ 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:org.wordpress.android.ui.prefs.SettingsFragment.java
public void refreshWPComAuthCategory() { PreferenceCategory wpComCategory = (PreferenceCategory) findPreference( getActivity().getString(R.string.pref_key_wpcom)); wpComCategory.removeAll(); addWpComSignIn(wpComCategory, 0);/* w ww .j av a2 s. c o m*/ addWpComShowHideButton(wpComCategory, 5); List<Map<String, Object>> accounts = WordPress.wpDB.getAccountsBy("dotcomFlag = 1 AND isHidden = 0", null); addAccounts(wpComCategory, accounts, 10); }
From source file:org.wordpress.android.ui.prefs.SettingsFragment.java
/** * Update the "wpcom blogs" preference category to contain a preference for each blog to configure * blog-specific settings.//from w w w.j a v a 2 s . c o m */ void updateSelfHostedBlogsPreferenceCategory() { PreferenceCategory blogsCategory = (PreferenceCategory) findPreference( getActivity().getString(R.string.pref_key_self_hosted)); blogsCategory.removeAll(); int order = 0; // Add self-hosted blog button Preference addBlogPreference = new Preference(getActivity()); addBlogPreference.setTitle(R.string.add_self_hosted_blog); Intent intentWelcome = new Intent(getActivity(), SignInActivity.class); intentWelcome.putExtra(SignInActivity.START_FRAGMENT_KEY, SignInActivity.ADD_SELF_HOSTED_BLOG); addBlogPreference.setIntent(intentWelcome); addBlogPreference.setOrder(order++); blogsCategory.addPreference(addBlogPreference); // Add self hosted list List<Map<String, Object>> accounts = WordPress.wpDB.getAccountsBy("dotcomFlag=0", null); addAccounts(blogsCategory, accounts, order); }
From source file:net.basilwang.StaticAttachmentActivity.java
private void reloadData(PreferenceCategory logonPreference, PreferenceScreen logonAddPreference, PreferenceManager preferenceManager) { // 2012-11-23 basilwang refresh tabbar title refreshActionBarTitle();/*from w w w . j a v a 2 s. c o m*/ logonPreference.removeAll(); logonPreference.addPreference(logonAddPreference); int accountId = PreferenceManager.getDefaultSharedPreferences(this) .getInt(LOGON_ACCOUNT_ID, 0); AccountService service = new AccountService(this); List<Account> list = service.getAccounts(); if (list.size() == 0) { logonAddPreference.setEnabled(true); } else { logonAddPreference.setEnabled(false); for (Account account : list) { PreferenceScreen preferenceItem = preferenceManager .createPreferenceScreen(this); // CheckBoxPreference checkBoxPreference = new // CheckBoxPreference(this); // make sure each key is unique preferenceItem.setKey(LOGON_ACCOUNT_PREFERENCES); preferenceItem.setTitle(PreferenceUtils.getPreferUserName(this)); if (accountId == account.getId()) preferenceItem.setSummary(R.string.already_checked); // preferenceItem.setChecked(false); // checkBoxPreference.setDisableDependentsState(disableDependentsState) // checkBoxPreference.setSelectable(false); preferenceItem.setOrder(0); preferenceItem.setOnPreferenceClickListener(this); logonPreference.addPreference(preferenceItem); } } }
From source file:org.linphone.SettingsFragment.java
private void emptyAndHidePreferenceCategory(int preferenceKey) { Preference preference = findPreference(getString(preferenceKey)); if (!(preference instanceof PreferenceCategory)) return;//from w w w . j a v a 2s . co m PreferenceCategory preferenceCategory = (PreferenceCategory) preference; preferenceCategory.removeAll(); hidePreference(preferenceCategory); }
From source file:org.linphone.SettingsFragment.java
private void initAccounts() { PreferenceCategory accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key)); accounts.removeAll(); // Get already configured extra accounts int defaultAccountID = mPrefs.getDefaultAccountIndex(); int nbAccounts = mPrefs.getAccountCount(); for (int i = 0; i < nbAccounts; i++) { final int accountId = i; // For each, add menus to configure it String username = mPrefs.getAccountUsername(accountId); String domain = mPrefs.getAccountDomain(accountId); LedPreference account = new LedPreference(LinphoneService.instance()); if (username == null) { account.setTitle(getString(R.string.pref_sipaccount)); } else {// w w w . j a va 2 s . co m account.setTitle(username + "@" + domain); } if (defaultAccountID == i) { account.setSummary(R.string.default_account_flag); } account.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { MainActivity.instance().displayAccountSettings(accountId); return false; } }); updateAccountLed(account, username, domain, mPrefs.isAccountEnabled(i)); accounts.addPreference(account); } }
From source file:org.linphone.SettingsFragment.java
private void initAudioSettings() { PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_codecs_key)); if (codecs == null) return;/* w w w. j a v a 2 s. co m*/ codecs.removeAll(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); for (final PayloadType pt : lc.getAudioCodecs()) { CheckBoxPreference codec = new CheckBoxPreference(LinphoneService.instance()); codec.setTitle(pt.getMime()); codec.setSummary(pt.getRate() + " Hz"); codec.setChecked(lc.isPayloadTypeEnabled(pt)); codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean enable = (Boolean) newValue; try { LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable); } catch (LinphoneCoreException e) { e.printStackTrace(); } return true; } }); codecs.addPreference(codec); } CheckBoxPreference echoCancellation = (CheckBoxPreference) findPreference( getString(R.string.pref_echo_cancellation_key)); echoCancellation.setChecked(mPrefs.isEchoCancellationEnabled()); if (mPrefs.isEchoCancellationEnabled()) { Preference echoCalibration = findPreference(getString(R.string.pref_echo_canceller_calibration_key)); echoCalibration .setSummary(String.format(getString(R.string.ec_calibrated), mPrefs.getEchoCalibration())); } CheckBoxPreference adaptiveRateControl = (CheckBoxPreference) findPreference( getString(R.string.pref_adaptive_rate_control_key)); adaptiveRateControl.setChecked(mPrefs.isAdaptiveRateControlEnabled()); ListPreference adaptiveRateAlgorithm = (ListPreference) findPreference( getString(R.string.pref_adaptive_rate_algorithm_key)); adaptiveRateAlgorithm.setSummary(String.valueOf(mPrefs.getAdaptiveRateAlgorithm())); adaptiveRateAlgorithm.setValue(String.valueOf(mPrefs.getAdaptiveRateAlgorithm())); ListPreference bitrateLimit = (ListPreference) findPreference( getString(R.string.pref_codec_bitrate_limit_key)); bitrateLimit.setSummary(String.valueOf(mPrefs.getCodecBitrateLimit())); bitrateLimit.setValue(String.valueOf(mPrefs.getCodecBitrateLimit())); }
From source file:org.linphone.SettingsFragment.java
private void initVideoSettings() { initializePreferredVideoSizePreferences( (ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key))); PreferenceCategory codecs = (PreferenceCategory) findPreference(getString(R.string.pref_video_codecs_key)); if (codecs == null) return;/*from ww w . j a va2 s .c o m*/ codecs.removeAll(); LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull(); for (final PayloadType pt : lc.getVideoCodecs()) { CheckBoxPreference codec = new CheckBoxPreference(LinphoneService.instance()); codec.setTitle(pt.getMime()); if (!pt.getMime().equals("VP8")) { if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) { continue; } else { if (!Version.hasFastCpuWithAsmOptim() && pt.getMime().equals("H264")) { // Android without neon doesn't support H264 Log.w("CPU does not have asm optimisations available, disabling H264"); continue; } } } codec.setChecked(lc.isPayloadTypeEnabled(pt)); codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean enable = (Boolean) newValue; try { LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable); } catch (LinphoneCoreException e) { e.printStackTrace(); } return true; } }); codecs.addPreference(codec); } ((CheckBoxPreference) findPreference(getString(R.string.pref_video_enable_key))) .setChecked(mPrefs.isVideoEnabled()); ((CheckBoxPreference) findPreference(getString(R.string.pref_video_use_front_camera_key))) .setChecked(mPrefs.useFrontCam()); ((CheckBoxPreference) findPreference(getString(R.string.pref_video_initiate_call_with_video_key))) .setChecked(mPrefs.shouldInitiateVideoCall()); //((CheckBoxPreference) findPreference(getString(R.string.pref_video_automatically_share_my_video_key))).setChecked(mPrefs.shouldAutomaticallyShareMyVideo()); ((CheckBoxPreference) findPreference(getString(R.string.pref_video_automatically_accept_video_key))) .setChecked(mPrefs.shouldAutomaticallyAcceptVideoRequests()); }