List of usage examples for android.preference ListPreference setEntryValues
public void setEntryValues(@ArrayRes int entryValuesResId)
From source file:com.hichinaschool.flashcards.anki.Preferences.java
/** Initializes the list of custom fonts shown in the preferences. */ private void initializeCustomFontsDialog() { ListPreference customFontsPreference = (ListPreference) getPreferenceScreen().findPreference("defaultFont"); customFontsPreference.setEntries(getCustomFonts("System default")); customFontsPreference.setEntryValues(getCustomFonts("")); ListPreference browserEditorCustomFontsPreference = (ListPreference) getPreferenceScreen() .findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
From source file:net.naonedbus.activity.impl.OldSettingsActivity.java
/** * Lister les calendrier dans la ListPreference passe en paramtre * /*from w w w. j av a2 s . com*/ * @param list */ private void fillCalendars(final ListPreference list) { CharSequence[] entriesName; CharSequence[] entriesId; final Map<Integer, String> calendars = CalendarUtils.getCalendars(getContentResolver()); entriesName = new String[calendars.size()]; entriesId = new String[calendars.size()]; int i = 0; for (final Entry<Integer, String> cal : calendars.entrySet()) { entriesName[i] = cal.getValue(); entriesId[i++] = String.valueOf(cal.getKey()); } list.setEntries(entriesName); list.setEntryValues(entriesId); }
From source file:net.naonedbus.fragment.impl.SettingsFragment.java
/** * Lister les calendrier dans la ListPreference passe en paramtre. * /* ww w.j a v a 2s . c o m*/ * @param list */ private void fillCalendars(final ListPreference list) { CharSequence[] entriesName; CharSequence[] entriesId; final Map<Integer, String> calendars = CalendarUtils.getCalendars(getActivity().getContentResolver()); entriesName = new String[calendars.size()]; entriesId = new String[calendars.size()]; int i = 0; for (final Entry<Integer, String> cal : calendars.entrySet()) { entriesName[i] = cal.getValue(); entriesId[i++] = String.valueOf(cal.getKey()); } list.setEntries(entriesName); list.setEntryValues(entriesId); }
From source file:com.android.leanlauncher.SettingsActivity.java
private void displayIconThemePref(ListPreference lpIconSetting) { ArrayMap<String, String> iconPacks = LauncherAppState.getInstance().getIconCache().getAvailableIconPacks(); if (iconPacks != null && iconPacks.size() != 0) { String iconPackValues[] = iconPacks.keySet().toArray(new String[iconPacks.size() + 1]); iconPackValues[iconPacks.size()] = ""; String[] iconPackTitles = new String[iconPacks.size() + 1]; for (int i = 0; i < iconPacks.size(); i++) { iconPackTitles[i] = iconPacks.get(iconPacks.keyAt(i)); }//from w w w . j av a 2s .c o m iconPackTitles[iconPacks.size()] = getString(R.string.pref_no_icon_theme); lpIconSetting.setEntries(iconPackTitles); lpIconSetting.setEntryValues(iconPackValues); } else { lpIconSetting.setEnabled(false); lpIconSetting.setShouldDisableView(true); lpIconSetting.setSummary(R.string.pref_icon_theme_summary_disabled); } }
From source file:com.ichi2.anki.PreferenceContext.java
/** Initializes the list of custom fonts shown in the preferences. */ private void initializeCustomFontsDialog(PreferenceScreen screen) { ListPreference defaultFontPreference = (ListPreference) screen.findPreference("defaultFont"); if (defaultFontPreference != null) { defaultFontPreference.setEntries(getCustomFonts("System default")); defaultFontPreference.setEntryValues(getCustomFonts("")); }// w ww . jav a 2s . c o m ListPreference browserEditorCustomFontsPreference = (ListPreference) screen .findPreference("browserEditorFont"); browserEditorCustomFontsPreference.setEntries(getCustomFonts("System default")); browserEditorCustomFontsPreference.setEntryValues(getCustomFonts("", true)); }
From source file:com.nttec.everychan.chans.dobrochan.DobroModule.java
private void addRatingPreference(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateRatingListener = new Preference.OnPreferenceChangeListener() { @Override// w w w . j a v a2s. com public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_MAX_RATING))) { setMaxRating((String) newValue); return true; } return false; } }; ListPreference ratingPref = new LazyPreferences.ListPreference(context); ratingPref.setTitle(R.string.dobrochan_prefs_max_rating); ratingPref.setSummary(preferences.getString(getSharedKey(PREF_KEY_MAX_RATING), "R-15")); ratingPref.setEntries(RATINGS); ratingPref.setEntryValues(RATINGS); ratingPref.setDefaultValue("R-15"); ratingPref.setKey(getSharedKey(PREF_KEY_MAX_RATING)); ratingPref.setOnPreferenceChangeListener(updateRatingListener); group.addPreference(ratingPref); }
From source file:org.tvheadend.tvhclient.fragments.SettingsProfileFragment.java
/** * //from w ww . j a v a 2 s .c o m * @param preferenceList * @param profileList */ protected void addProfiles(ListPreference preferenceList, final List<Profiles> profileList) { // Initialize the arrays that contain the profile values final int size = profileList.size(); CharSequence[] entries = new CharSequence[size]; CharSequence[] entryValues = new CharSequence[size]; // Add the available profiles to list preference for (int i = 0; i < size; i++) { entries[i] = profileList.get(i).name; entryValues[i] = profileList.get(i).uuid; } preferenceList.setEntries(entries); preferenceList.setEntryValues(entryValues); // Enable the preference for use selection preferenceList.setEnabled(true); }
From source file:com.nttec.everychan.chans.allchan.AllchanModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type captchaPreference.setTitle(R.string.pref_captcha_type); captchaPreference.setDialogTitle(R.string.pref_captcha_type); captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE)); captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS); captchaPreference.setEntries(CAPTCHA_TYPES); captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT); int i = Arrays.asList(CAPTCHA_TYPES_KEYS) .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT)); if (i >= 0) captchaPreference.setSummary(CAPTCHA_TYPES[i]); preferenceGroup.addPreference(captchaPreference); addHttpsPreference(preferenceGroup, true); addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup .findPreference(getSharedKey(PREF_KEY_USE_PROXY)); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override//from w w w . j ava2 s .c o m public boolean onPreferenceClick(Preference preference) { if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); } return false; } }); captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (proxyPreference.isChecked() && newValue.equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); return false; } return true; } }); }
From source file:org.span.manager.ChangeSettingsActivity.java
private void updateView() { // user id/*from w ww.ja va2 s . c om*/ EditTextPreference uidEditTextPref = (EditTextPreference) findPreference("uidpref"); uidEditTextPref.setText(manetcfg.getUserId()); // wifi group wifiGroupPref = (PreferenceGroup) findPreference("wifiprefs"); boolean bluetoothOn = manetcfg.isUsingBluetooth(); wifiGroupPref.setEnabled(!bluetoothOn); // wifi encryption algorithm WifiEncryptionAlgorithmEnum encAlgorithm = manetcfg.getWifiEncryptionAlgorithm(); ListPreference wifiEncAlgorithmPref = (ListPreference) findPreference("encalgorithmpref"); wifiEncAlgorithmPref.setEnabled(false); // TODO: disable until tested wifiEncAlgorithmPref.setEntries(WifiEncryptionAlgorithmEnum.descriptionValues()); wifiEncAlgorithmPref.setEntryValues(WifiEncryptionAlgorithmEnum.stringValues()); wifiEncAlgorithmPref.setValueIndex(encAlgorithm.ordinal()); // wifi encryption setup method ListPreference wifiEncSetupMethodPref = (ListPreference) findPreference("encsetuppref"); wifiEncSetupMethodPref.setEnabled(false); // TODO: disable until tested if (encAlgorithm == WifiEncryptionAlgorithmEnum.NONE) { wifiEncSetupMethodPref.setEnabled(false); } else { wifiEncSetupMethodPref.setEnabled(true); if (manetcfg.getWifiDriver().startsWith("softap") || manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { if (wifiEncSetupMethodPref != null) { wifiGroupPref.removePreference(wifiEncSetupMethodPref); } } else { wifiEncSetupMethodPref.setEntries(WifiEncryptionSetupMethodEnum.descriptionValues()); wifiEncSetupMethodPref.setEntryValues(WifiEncryptionSetupMethodEnum.stringValues()); wifiEncSetupMethodPref.setValueIndex(manetcfg.getWifiEncryptionSetupMethod().ordinal()); } } // wifi encryption password final EditTextPreference wifiEncPasswordEditTextPref = (EditTextPreference) findPreference("passwordpref"); wifiEncPasswordEditTextPref.setEnabled(false); // TODO: disable until tested if (encAlgorithm == WifiEncryptionAlgorithmEnum.NONE) { wifiEncPasswordEditTextPref.setEnabled(false); } else { wifiEncPasswordEditTextPref.setEnabled(true); final int origTextColorWifiEncKey = wifiEncPasswordEditTextPref.getEditText().getCurrentTextColor(); if (manetcfg.getWifiDriver().startsWith("softap") || manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { Validation.setupWpaEncryptionValidators(wifiEncPasswordEditTextPref, origTextColorWifiEncKey); } else { Validation.setupWepEncryptionValidators(wifiEncPasswordEditTextPref, origTextColorWifiEncKey); } wifiEncPasswordEditTextPref.setText(manetcfg.getWifiEncryptionPassword()); } // wifi SSID EditTextPreference wifiSsidEditTextPref = (EditTextPreference) findPreference("ssidpref"); Validation.setupWifiSsidValidator(wifiSsidEditTextPref); wifiSsidEditTextPref.setText(manetcfg.getWifiSsid()); // wifi channel ListPreference channelpref = (ListPreference) findPreference("channelpref"); channelpref.setEnabled(false); // TODO: disable until tested String[] channelStrValues = WifiChannelEnum.stringValues(); String[] channelDescValues = WifiChannelEnum.descriptionValues(); // remove auto channel option if not supported by device if (!manetcfg.getWifiDriver().startsWith("softap") || !manetcfg.getWifiDriver().equals(DeviceConfig.DRIVER_HOSTAP)) { // auto channel option at first index String[] newChannelStrValues = new String[channelStrValues.length - 1]; String[] newChannelDescValues = new String[channelStrValues.length - 1]; for (int i = 1; i < channelStrValues.length; i++) { newChannelStrValues[i - 1] = channelStrValues[i]; newChannelDescValues[i - 1] = channelDescValues[i]; } channelpref.setEntries(newChannelDescValues); channelpref.setEntryValues(newChannelStrValues); WifiChannelEnum wifiChannel = manetcfg.getWifiChannel(); if (wifiChannel == WifiChannelEnum.AUTO) { channelpref.setValueIndex(WifiChannelEnum.CHANNEL_1.ordinal() - 1); } else { channelpref.setValueIndex(wifiChannel.ordinal() - 1); } } else { channelpref.setEntries(channelDescValues); channelpref.setEntryValues(channelStrValues); channelpref.setValueIndex(manetcfg.getWifiChannel().ordinal()); } // wifi transmit power ListPreference txpowerPreference = (ListPreference) findPreference("txpowerpref"); if (!manetcfg.isTransmitPowerSupported()) { // DEBUG if (txpowerPreference != null) { wifiGroupPref.removePreference(txpowerPreference); } } else { txpowerPreference.setEntries(WifiTxpowerEnum.descriptionValues()); txpowerPreference.setEntryValues(WifiTxpowerEnum.stringValues()); txpowerPreference.setValueIndex(manetcfg.getWifiTxpower().ordinal()); } // bluetooth group // disable bluetooth adhoc if not supported by the kernel if (true) { // !manetcfg.isBluetoothSupported() // TODO: disable until tested PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); btGroup.setEnabled(false); } // bluetooth // NOTE: bluetooth dependencies are specified in the layout XML // CheckBoxPreference bluetoothCheckboxPref = (CheckBoxPreference)findPreference("bluetoothonpref"); // bluetooth keep wifi CheckBoxPreference btKeepWifiCheckBoxPref = (CheckBoxPreference) findPreference("bluetoothkeepwifipref"); if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.ECLAIR) { PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); if (btKeepWifiCheckBoxPref != null) { btGroup.removePreference(btKeepWifiCheckBoxPref); } } else { btKeepWifiCheckBoxPref.setChecked(!manetcfg.isWifiDisabledWhenUsingBluetooth()); } // bluetooth discoverable CheckBoxPreference btdiscoverablePreference = (CheckBoxPreference) findPreference( "bluetoothdiscoverablepref"); if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.ECLAIR) { PreferenceGroup btGroup = (PreferenceGroup) findPreference("btprefs"); if (btdiscoverablePreference != null) { btGroup.removePreference(btdiscoverablePreference); } } else { btdiscoverablePreference.setChecked(manetcfg.isBluetoothDiscoverableWhenInAdhocMode()); } // ip address EditTextPreference ipAddressEditTextPref = (EditTextPreference) findPreference("ippref"); Validation.setupIpAddressValidator(ipAddressEditTextPref); ipAddressEditTextPref.setText(manetcfg.getIpAddress()); // dns server EditTextPreference dnsServerEditTextPref = (EditTextPreference) findPreference("dnspref"); Validation.setupIpAddressValidator(dnsServerEditTextPref); dnsServerEditTextPref.setText(manetcfg.getDnsServer()); // routing protocol String currRoutingProtocol = manetcfg.getRoutingProtocol(); List<String> routingProtocolList = CoreTask.getRoutingProtocols(); String[] routingProtocols = new String[routingProtocolList.size()]; routingProtocolList.toArray(routingProtocols); ListPreference routingProtocolPreference = (ListPreference) findPreference("routingprotocolpref"); routingProtocolPreference.setEntries(routingProtocols); routingProtocolPreference.setEntryValues(routingProtocols); routingProtocolPreference.setValue(currRoutingProtocol); // routing ignore list JSONArray array = new JSONArray(manetcfg.getRoutingIgnoreList()); sharedPreferences.edit().putString("ignorepref", array.toString()).commit(); // wifi interface String currInterface = manetcfg.getWifiInterface(); String defaultInterface = DeviceConfig.getWifiInterface(manetcfg.getDeviceType()); List<String> interfaceList = CoreTask.getNetworkInterfaces(); if (!interfaceList.contains(defaultInterface)) { interfaceList.add(defaultInterface); } String[] interfaces = new String[interfaceList.size()]; interfaceList.toArray(interfaces); ListPreference interfacePreference = (ListPreference) findPreference("interfacepref"); interfacePreference.setEntries(interfaces); interfacePreference.setEntryValues(interfaces); if (interfaceList.contains(currInterface)) { interfacePreference.setValue(currInterface); } else { interfacePreference.setValue(defaultInterface); currInterface = defaultInterface; } // routing gateway String currGatewayInterface = manetcfg.getGatewayInterface(); interfaceList.remove(currInterface); // remove ad-hoc interface interfaceList.add(0, ManetConfig.GATEWAY_INTERFACE_NONE); interfaces = new String[interfaceList.size()]; interfaceList.toArray(interfaces); ListPreference gatewayPreference = (ListPreference) findPreference("gatewaypref"); gatewayPreference.setEntries(interfaces); gatewayPreference.setEntryValues(interfaces); gatewayPreference.setValue(currGatewayInterface); if (interfaceList.contains(currGatewayInterface)) { gatewayPreference.setValue(currGatewayInterface); } else { gatewayPreference.setValue(ManetConfig.GATEWAY_INTERFACE_NONE); } // screen on CheckBoxPreference screenOnPreference = (CheckBoxPreference) findPreference("screenonpref"); screenOnPreference.setChecked(manetcfg.isScreenOnWhenInAdhocMode()); // battery temperature setupFlag = true; }
From source file:nya.miku.wishmaster.chans.tumbach.TumbachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); addOnlyNewPostsPreference(preferenceGroup, true); final ListPreference captchaPreference = new LazyPreferences.ListPreference(context); //captcha_type captchaPreference.setTitle(R.string.pref_captcha_type); captchaPreference.setDialogTitle(R.string.pref_captcha_type); captchaPreference.setKey(getSharedKey(PREF_KEY_CAPTCHA_TYPE)); captchaPreference.setEntryValues(CAPTCHA_TYPES_KEYS); captchaPreference.setEntries(CAPTCHA_TYPES); captchaPreference.setDefaultValue(CAPTCHA_TYPE_DEFAULT); int i = Arrays.asList(CAPTCHA_TYPES_KEYS) .indexOf(preferences.getString(getSharedKey(PREF_KEY_CAPTCHA_TYPE), CAPTCHA_TYPE_DEFAULT)); if (i >= 0) captchaPreference.setSummary(CAPTCHA_TYPES[i]); preferenceGroup.addPreference(captchaPreference); addPasswordPreference(preferenceGroup); addHttpsPreference(preferenceGroup, true); addCloudflareRecaptchaFallbackPreference(preferenceGroup); addProxyPreferences(preferenceGroup); final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup .findPreference(getSharedKey(PREF_KEY_USE_PROXY)); proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/* w ww . j a v a 2 s .co m*/ public boolean onPreferenceClick(Preference preference) { if (proxyPreference.isChecked() && captchaPreference.getValue().equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); } return false; } }); captchaPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (proxyPreference.isChecked() && newValue.equals("recaptcha")) { captchaPreference.setValue("recaptcha-fallback"); return false; } return true; } }); }