Java Code Examples for android.preference.PreferenceGroup#addPreference()
The following examples show how to use
android.preference.PreferenceGroup#addPreference() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomInputStyleSettingsFragment.java From openboard with GNU General Public License v3.0 | 6 votes |
@Override public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) { final InputMethodSubtype subtype = stylePref.getSubtype(); if (!stylePref.hasBeenModified()) { return; } if (findDuplicatedSubtype(subtype) == null) { mRichImm.setAdditionalInputMethodSubtypes(getSubtypes()); return; } // Saved subtype is duplicated. final PreferenceGroup group = getPreferenceScreen(); group.removePreference(stylePref); stylePref.revert(); group.addPreference(stylePref); showSubtypeAlreadyExistsToast(subtype); }
Example 2
Source File: AutofillPreferences.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void rebuildProfileList() { // Add an edit preference for each current Chrome profile. PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES); profileCategory.removeAll(); for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) { // Add an item on the current page... Preference pref = new Preference(getActivity()); pref.setTitle(profile.getFullName()); pref.setSummary(profile.getLabel()); if (profile.getIsLocal()) { pref.setFragment(AutofillProfileEditor.class.getName()); } else { pref.setWidgetLayoutResource(R.layout.autofill_server_data_label); pref.setFragment(AutofillServerProfilePreferences.class.getName()); } Bundle args = pref.getExtras(); args.putString(AUTOFILL_GUID, profile.getGUID()); profileCategory.addPreference(pref); } }
Example 3
Source File: TwoStatePreferenceHelper.java From openboard with GNU General Public License v3.0 | 6 votes |
private static void replaceAllCheckBoxPreferencesBySwitchPreferences( final PreferenceGroup group) { final ArrayList<Preference> preferences = new ArrayList<>(); final int count = group.getPreferenceCount(); for (int index = 0; index < count; index++) { preferences.add(group.getPreference(index)); } group.removeAll(); for (int index = 0; index < count; index++) { final Preference preference = preferences.get(index); if (preference instanceof CheckBoxPreference) { addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group); } else { group.addPreference(preference); if (preference instanceof PreferenceGroup) { replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference); } } } }
Example 4
Source File: TwoStatePreferenceHelper.java From openboard with GNU General Public License v3.0 | 6 votes |
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox, final PreferenceGroup group) { final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext()); switchPref.setTitle(checkBox.getTitle()); switchPref.setKey(checkBox.getKey()); switchPref.setOrder(checkBox.getOrder()); switchPref.setPersistent(checkBox.isPersistent()); switchPref.setEnabled(checkBox.isEnabled()); switchPref.setChecked(checkBox.isChecked()); switchPref.setSummary(checkBox.getSummary()); switchPref.setSummaryOn(checkBox.getSummaryOn()); switchPref.setSummaryOff(checkBox.getSummaryOff()); switchPref.setSwitchTextOn(EMPTY_TEXT); switchPref.setSwitchTextOff(EMPTY_TEXT); group.addPreference(switchPref); switchPref.setDependency(checkBox.getDependency()); }
Example 5
Source File: UserDictionaryList.java From Android-Keyboard with Apache License 2.0 | 6 votes |
/** * Creates the entries that allow the user to go into the user dictionary for each locale. * @param userDictGroup The group to put the settings in. */ protected void createUserDictSettings(final PreferenceGroup userDictGroup) { final Activity activity = getActivity(); userDictGroup.removeAll(); final TreeSet<String> localeSet = UserDictionaryList.getUserDictionaryLocalesSet(activity); if (localeSet.size() > 1) { // Have an "All languages" entry in the languages list if there are two or more active // languages localeSet.add(""); } if (localeSet.isEmpty()) { userDictGroup.addPreference(createUserDictionaryPreference(null)); } else { for (String locale : localeSet) { userDictGroup.addPreference(createUserDictionaryPreference(locale)); } } }
Example 6
Source File: AutofillPreferences.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void rebuildCreditCardList() { PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS); profileCategory.removeAll(); for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) { // Add an item on the current page... Preference pref = new Preference(getActivity()); pref.setTitle(card.getObfuscatedNumber()); pref.setSummary(card.getFormattedExpirationDate(getActivity())); if (card.getIsLocal()) { pref.setFragment(AutofillLocalCardEditor.class.getName()); } else { pref.setFragment(AutofillServerCardEditor.class.getName()); pref.setWidgetLayoutResource(R.layout.autofill_server_data_label); } Bundle args = pref.getExtras(); args.putString(AUTOFILL_GUID, card.getGUID()); profileCategory.addPreference(pref); } }
Example 7
Source File: CustomInputStyleSettingsFragment.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
@Override public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) { final InputMethodSubtype subtype = stylePref.getSubtype(); if (!stylePref.hasBeenModified()) { return; } if (findDuplicatedSubtype(subtype) == null) { mRichImm.setAdditionalInputMethodSubtypes(getSubtypes()); return; } // Saved subtype is duplicated. final PreferenceGroup group = getPreferenceScreen(); group.removePreference(stylePref); stylePref.revert(); group.addPreference(stylePref); showSubtypeAlreadyExistsToast(subtype); }
Example 8
Source File: KrautModule.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
public void addKompturcodePreference(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); EditTextPreference kompturcodePreference = new EditTextPreference(context); kompturcodePreference.setTitle(R.string.kraut_prefs_kompturcode); kompturcodePreference.setDialogTitle(R.string.kraut_prefs_kompturcode); kompturcodePreference.setSummary(R.string.kraut_prefs_kompturcode_summary); kompturcodePreference.setKey(getSharedKey(PREF_KEY_KOMPTURCODE_COOKIE)); kompturcodePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { setKompturcodeCookie((String) newValue); return true; } }); preferenceGroup.addPreference(kompturcodePreference); }
Example 9
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { domain = (String) newValue; if (domain.length() == 0) domain = DEFAULT_DOMAIN; loadHanabiraCookie(); return true; } return false; } }; 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); group.addPreference(domainPref); }
Example 10
Source File: MakabaModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** Добавить категорию настроек домена (в т.ч. https) */ private void addDomainPreferences(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) { updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true)); return true; } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) { updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean)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); CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать https" httpsPref.setTitle(R.string.pref_use_https); httpsPref.setSummary(R.string.pref_use_https_summary); httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA)); httpsPref.setDefaultValue(true); httpsPref.setOnPreferenceChangeListener(updateDomainListener); domainCat.addPreference(httpsPref); }
Example 11
Source File: BasePreferenceFragment.java From Dashchan with Apache License 2.0 | 5 votes |
public void addPreference(PreferenceGroup parent, Preference preference) { if (parent != null) { parent.addPreference(preference); } else { getPreferenceScreen().addPreference(preference); } preference.setOnPreferenceChangeListener(this); preference.setOnPreferenceClickListener(this); }
Example 12
Source File: SynchModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); ListPreference domainPref = new LazyPreferences.ListPreference(context); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.setTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setEntries(DOMAINS); domainPref.setEntryValues(DOMAINS); domainPref.setDefaultValue(DOMAINS[0]); preferenceGroup.addPreference(domainPref); super.addPreferencesOnScreen(preferenceGroup); }
Example 13
Source File: MakabaModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
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); }
Example 14
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
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); }
Example 15
Source File: FourchanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addPasscodePreference(preferenceGroup); CheckBoxPreference newRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); newRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha); newRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_summary); newRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA)); newRecaptchaPref.setDefaultValue(NEW_RECAPTCHA_DEFAULT); preferenceGroup.addPreference(newRecaptchaPref); final CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context); fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback); fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary); fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA_FALLBACK)); fallbackRecaptchaPref.setDefaultValue(false); preferenceGroup.addPreference(fallbackRecaptchaPref); fallbackRecaptchaPref.setDependency(getSharedKey(PREF_KEY_NEW_RECAPTCHA)); addPasswordPreference(preferenceGroup); addHttpsPreference(preferenceGroup, true); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup.findPreference(getSharedKey(PREF_KEY_USE_PROXY)); fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked()); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked()); if (proxyPreference.isChecked() && !fallbackRecaptchaPref.isChecked()) fallbackRecaptchaPref.setChecked(true); return false; } }); }
Example 16
Source File: HorochanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@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); }
Example 17
Source File: NullchanccModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
private void addDomainPreference(PreferenceGroup group) { Context context = group.getContext(); EditTextPreference domainPref = new EditTextPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setDialogTitle(R.string.pref_domain); 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); group.addPreference(domainPref); }
Example 18
Source File: CustomInputStyleSettingsFragment.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
private void setPrefSubtypes(final String prefSubtypes, final Context context) { final PreferenceGroup group = getPreferenceScreen(); group.removeAll(); final InputMethodSubtype[] subtypesArray = AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtypes); for (final InputMethodSubtype subtype : subtypesArray) { final CustomInputStylePreference pref = new CustomInputStylePreference(context, subtype, this); group.addPreference(pref); } }
Example 19
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) настройку выбора HTTPS (защищённого соединения). * Для хранения используется ключ общих параметров {@link #PREF_KEY_USE_HTTPS} ({@link #getSharedKey(String)}). * См. также: {@link #useHttps(boolean)} - для получения значения параметра. * @param group группа, на которую добавляется параметр * @param defaultValue значение параметра по умолчанию * return объект {@link CheckBoxPreference} с параметром */ protected CheckBoxPreference addHttpsPreference(PreferenceGroup group, boolean defaultValue) { final Context context = group.getContext(); CheckBoxPreference httpsPref = new LazyPreferences.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(defaultValue); group.addPreference(httpsPref); return httpsPref; }
Example 20
Source File: AbstractChanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * Добавить в группу параметров (на экран/в категорию) настройку выбора использования инкрементальной загрузки (загрузки только новых постов). * Для хранения используется ключ общих параметров {@link #PREF_KEY_ONLY_NEW_POSTS} ({@link #getSharedKey(String)}). * См. также: {@link #loadOnlyNewPosts(boolean)} - для получения значения параметра. * @param group группа, на которую добавляется параметр * @param defaultValue значение параметра по умолчанию * return объект {@link CheckBoxPreference} с параметром */ protected CheckBoxPreference addOnlyNewPostsPreference(PreferenceGroup group, boolean defaultValue) { final Context context = group.getContext(); CheckBoxPreference onlyNewPostsPref = new LazyPreferences.CheckBoxPreference(context); onlyNewPostsPref.setTitle(R.string.pref_only_new_posts); onlyNewPostsPref.setSummary(R.string.pref_only_new_posts_summary); onlyNewPostsPref.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS)); onlyNewPostsPref.setDefaultValue(defaultValue); group.addPreference(onlyNewPostsPref); return onlyNewPostsPref; }