List of usage examples for android.preference ListPreference setValue
public void setValue(String value)
From source file:Main.java
public static void PopulateFSList(Preference preference, String[] List, String filesystem) { PopulateList(preference, List); ListPreference PrefList = (ListPreference) preference; if (filesystem != null) { String currentfs = GetCurrentFileSystem(filesystem); PrefList.setSummary("current filesystem: " + currentfs); PrefList.setValue(currentfs); } else {//from w ww .jav a2 s . co m PrefList.setValue(""); } }
From source file:bander.notepad.PrefsFragment.java
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { // TODO: Implement this method final String key = preference.getKey(); if (KEY_COLOR.equals(key) || KEY_THEME_TYPE.equals(key)) { getActivity().recreate();//from ww w .j a v a 2s. c o m return true; } if (KEY_SORTORDER.equals(key)) { ListPreference sortOrderPreference = (ListPreference) preference; sortOrderPreference.setValue((String) newValue); setSortOrderSummary(sortOrderPreference); setSortAscendingEnabled(!newValue.equals("0")); return false; } if (KEY_TEXTSIZE.equals(key)) { ListPreference textSizePreference = (ListPreference) preference; textSizePreference.setValue((String) newValue); setTextSizeSummary(textSizePreference); return false; } return true; }
From source file:com.android.switchaccess.SwitchAccessPreferenceActivity.java
private void adjustAutoscanPrefs() { if (isAutoScanEnabled(this)) { ListPreference scanMethodsPref = (ListPreference) findPreference( getString(R.string.pref_scanning_methods_key)); String optionScanKey = getString(R.string.option_scanning_key); if (isOptionScanningEnabled(this)) { /* If somehow both autoscan and option scan are enabled, turn off option scan */ scanMethodsPref.setValue(getString(R.string.row_col_scanning_key)); SharedPreferencesUtils.getSharedPreferences(this).edit() .putString(getString(R.string.pref_scanning_methods_key), getString(R.string.row_col_scanning_key)) .commit();/*ww w . j av a 2 s .c om*/ } ArrayList<String> entries = new ArrayList<>( Arrays.asList(getResources().getStringArray(R.array.switch_access_scanning_methods_entries))); ArrayList<String> entryValues = new ArrayList<>( Arrays.asList(getResources().getStringArray(R.array.switch_access_scanning_methods_values))); int optionScanIndex = entryValues.indexOf(optionScanKey); entries.remove(optionScanIndex); entryValues.remove(optionScanIndex); scanMethodsPref.setEntries(entries.toArray(new String[entries.size()])); scanMethodsPref.setEntryValues(entryValues.toArray(new String[entries.size()])); } else { PreferenceScreen mainPrefScreen = (PreferenceScreen) findPreference( getString(R.string.main_pref_screen_key)); PreferenceScreen keyAssignmentScreen = (PreferenceScreen) findPreference( getString(R.string.pref_category_scan_mappings_key)); mainPrefScreen.removePreference(findPreference(getString(R.string.pref_key_auto_scan_time_delay))); removeKeyAssignmentPressIfEmpty(keyAssignmentScreen, R.string.pref_key_mapped_to_auto_scan_key); removeKeyAssignmentPressIfEmpty(keyAssignmentScreen, R.string.pref_key_mapped_to_reverse_auto_scan_key); if (isOptionScanningEnabled(this)) { mainPrefScreen.removePreference(findPreference(getString(R.string.pref_key_auto_scan_enabled))); } } }
From source file:com.ichi2.anki.FilteredDeckOptions.java
protected void buildLists() { ListPreference newOrderPref = (ListPreference) findPreference("order"); newOrderPref.setEntries(R.array.cram_deck_conf_order_labels); newOrderPref.setEntryValues(R.array.cram_deck_conf_order_values); newOrderPref.setValue(mPref.getString("order", "0")); }
From source file:com.hichinaschool.flashcards.anki.CramDeckOptions.java
protected void buildLists() { ListPreference newOrderPref = (ListPreference) findPreference("order"); newOrderPref.setEntries(R.array.cram_deck_conf_order_labels); newOrderPref.setEntryValues(R.array.cram_deck_conf_order_values); newOrderPref.setValue(mPref.getString("order", "0")); if (mPresetSearchSuffix != null) { EditTextPreference searchPref = (EditTextPreference) findPreference("search"); searchPref.setText(mPresetSearchSuffix); }//from w w w .j a va2 s . co m }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
/** * Will try to extract the file source preferences (frequency, sample rate, format) from the filename *//* w ww . ja va2 s .c o m*/ public void updateFileSourcePrefs() { EditTextPreference etp_filename = (EditTextPreference) findPreference( getString(R.string.pref_filesource_file)); EditTextPreference etp_frequency = (EditTextPreference) findPreference( getString(R.string.pref_filesource_frequency)); EditTextPreference etp_sampleRate = (EditTextPreference) findPreference( getString(R.string.pref_filesource_sampleRate)); ListPreference lp_format = (ListPreference) findPreference(getString(R.string.pref_filesource_format)); String filename = etp_filename.getText(); // Format. Search for strings like hackrf, rtl-sdr, ... if (filename.matches(".*hackrf.*") || filename.matches(".*HackRF.*") || filename.matches(".*HACKRF.*") || filename.matches(".*hackrfone.*")) lp_format.setValue("0"); if (filename.matches(".*rtlsdr.*") || filename.matches(".*rtl-sdr.*") || filename.matches(".*RTLSDR.*") || filename.matches(".*RTL-SDR.*")) lp_format.setValue("1"); // Sampe Rate. Search for pattern XXXXXXXSps if (filename.matches(".*(_|-|\\s)([0-9]+)(sps|Sps|SPS).*")) etp_sampleRate.setText(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(sps|Sps|SPS).*", "$2")); if (filename.matches(".*(_|-|\\s)([0-9]+)(msps|Msps|MSps|MSPS).*")) etp_sampleRate.setText( "" + Integer.valueOf(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(msps|Msps|MSps|MSPS).*", "$2")) * 1000000); // Frequency. Search for pattern XXXXXXXHz if (filename.matches(".*(_|-|\\s)([0-9]+)(hz|Hz|HZ).*")) etp_frequency.setText(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(hz|Hz|HZ).*", "$2")); if (filename.matches(".*(_|-|\\s)([0-9]+)(mhz|Mhz|MHz|MHZ).*")) etp_frequency.setText( "" + Integer.valueOf(filename.replaceFirst(".*(_|-|\\s)([0-9]+)(mhz|Mhz|MHz|MHZ).*", "$2")) * 1000000); }
From source file:nz.Intelx.DroidNetLogin.DroidNetLoginActivity.java
@Override public boolean onPreferenceChange(Preference pref, Object newValue) { //match summary for Login list preference to selected preference if (pref.getKey().equals("login_preference")) { ListPreference login_preference = (ListPreference) pref; login_preference.setValue((String) newValue); CharSequence Login_Summary = login_preference.getEntry(); login_preference.setSummary(Login_Summary); }//from w w w .j a v a 2s . c om if (pref.getKey().equals("debug_preference")) { CheckBoxPreference debug_preference = (CheckBoxPreference) pref; debug_preference.setChecked((Boolean) newValue); } if (pref.getKey().equals("proxy_preference")) { CheckBoxPreference proxy_preference = (CheckBoxPreference) pref; proxy_preference.setChecked((Boolean) newValue); } updatePreference(pref.getSharedPreferences()); return true; }
From source file:org.span.manager.ChangeSettingsActivity.java
private void updateView() { // user id/*from w w w . j a v a2 s . co m*/ 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:com.hichinaschool.flashcards.anki.DeckOptions.java
protected void buildLists() { ListPreference deckConfPref = (ListPreference) findPreference("deckConf"); ArrayList<JSONObject> confs = mCol.getDecks().allConf(); Collections.sort(confs, new JSONNameComparator()); String[] confValues = new String[confs.size()]; String[] confLabels = new String[confs.size()]; try {//from w w w .j av a 2s . c om for (int i = 0; i < confs.size(); i++) { JSONObject o = confs.get(i); confValues[i] = o.getString("id"); confLabels[i] = o.getString("name"); } } catch (JSONException e) { throw new RuntimeException(e); } deckConfPref.setEntries(confLabels); deckConfPref.setEntryValues(confValues); deckConfPref.setValue(mPref.getString("deckConf", "0")); ListPreference newOrderPref = (ListPreference) findPreference("newOrder"); newOrderPref.setEntries(R.array.new_order_labels); newOrderPref.setEntryValues(R.array.new_order_values); newOrderPref.setValue(mPref.getString("newOrder", "0")); ListPreference leechActPref = (ListPreference) findPreference("lapLeechAct"); leechActPref.setEntries(R.array.leech_action_labels); leechActPref.setEntryValues(R.array.leech_action_values); leechActPref.setValue(mPref.getString("lapLeechAct", "0")); }
From source file:org.linphone.SettingsFragment.java
private void initTunnelSettings() { setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_host_key, mPrefs.getTunnelHost()); setPreferenceDefaultValueAndSummary(R.string.pref_tunnel_port_key, String.valueOf(mPrefs.getTunnelPort())); ListPreference tunnelModePref = (ListPreference) findPreference(getString(R.string.pref_tunnel_mode_key)); String tunnelMode = mPrefs.getTunnelMode(); if (tunnelModePref != null) { tunnelModePref.setSummary(tunnelMode); tunnelModePref.setValue(tunnelMode); }/*from ww w. ja v a2 s.co m*/ }