List of usage examples for android.preference ListPreference setEntryValues
public void setEntryValues(@ArrayRes int entryValuesResId)
From source file:com.jparkie.aizoban.presenters.SettingsPresenterImpl.java
@Override public void initializeDownloadDirectory() { ListPreference downloadPreference = mSettingsMapper.getDownloadStoragePreference(); if (downloadPreference != null) { String[] downloadDirectories = DiskUtils.getStorageDirectories(); downloadPreference.setEntries(downloadDirectories); downloadPreference.setEntryValues(downloadDirectories); downloadPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override/*from w w w.jav a 2s .c o m*/ public boolean onPreferenceChange(Preference preference, Object newValue) { String downloadDirectory = (String) newValue; if (downloadDirectory != null) { File actualDirectory = new File(downloadDirectory); if (!actualDirectory.equals(AizobanApplication.getInstance().getFilesDir())) { boolean isWritable = actualDirectory.mkdirs(); try { File tempFile = File.createTempFile("tempTestDirectory", "0", actualDirectory); tempFile.delete(); isWritable = true; } catch (IOException e) { isWritable = false; } if (!isWritable) { mSettingsView.toastExternalStorageError(); return false; } } } return true; } }); } }
From source file:com.nttec.everychan.chans.synch.SynchModule.java
@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);/*from w w w. j ava 2s . c om*/ domainPref.setEntryValues(DOMAINS); domainPref.setDefaultValue(DOMAINS[0]); preferenceGroup.addPreference(domainPref); super.addPreferencesOnScreen(preferenceGroup); }
From source file:org.trosnoth.serveradmin.ServerSettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); telnet = ConnectionActivity.telnet;//from w w w .j av a2s.c o m telnet.send("game = getGame()"); pref = new ServerSettings(); pref.registerOnSharedPreferenceChangeListener(this); addPreferencesFromResource(R.xml.server_settings); gameModes = telnet.parseJSON(telnet.readWrite("print json.dumps(getGame().listGameModes())")); ListPreference gameModesPref = (ListPreference) this.findPreference("gameMode"); String[] strArray = new String[gameModes.size()]; gameModes.toArray(strArray); gameModesPref.setEntries(strArray); gameModesPref.setEntryValues(strArray); EditTextPreference setting; EditText settingText; setting = (EditTextPreference) findPreference("playersPerTeam"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("playersTotal"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER); settingText.setFilters(InputFilters.integerFilter(255)); setting = (EditTextPreference) findPreference("gameSpeed"); settingText = setting.getEditText(); settingText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); // Update every 5 seconds Runnable looper = new Runnable() { public void run() { update(); mHandler.postDelayed(this, ConnectionActivity.UPDATE_FREQ); } }; if (ConnectionActivity.automaticUpdate) { mHandler.removeCallbacks(looper); mHandler.post(looper); } else { update(); } }
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); }/* www .ja va 2 s.c o m*/ }
From source file:net.bible.android.view.activity.settings.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // change theme according to light sensor UiUtils.applyTheme(this); super.onCreate(savedInstanceState); // allow partial integration with And Bible framework - without this TTS stops // putting this before the below ensures any error dialog will be displayed in front of the settings screen and not the previous screen // see onStop for paired iAmNoLongerCurrent method call CurrentActivityHolder.getInstance().setCurrentActivity(this); try {//from w ww . j a v a 2s . c om addPreferencesFromResource(R.xml.settings); //If no light sensor exists switch to old boolean check box // see here for method: http://stackoverflow.com/questions/4081533/how-to-remove-android-preferences-from-the-screen Preference unusedNightModePreference = getPreferenceScreen() .findPreference(ScreenSettings.getUnusedNightModePreferenceKey()); getPreferenceScreen().removePreference(unusedNightModePreference); // if no tilt sensor then remove tilt-to-scroll setting if (!PageTiltScrollControl.isTiltSensingPossible()) { Preference tiltToScrollPreference = getPreferenceScreen() .findPreference(PageTiltScrollControl.TILT_TO_SCROLL_PREFERENCE_KEY); getPreferenceScreen().removePreference(tiltToScrollPreference); } // only JellyBean supports Malayalam so remove ml for older versions of Android if (!CommonUtils.isJellyBeanPlus()) { ListPreference localePref = (ListPreference) getPreferenceScreen().findPreference(LOCALE_PREF); CharSequence[] entries = localePref.getEntries(); CharSequence[] entryValues = localePref.getEntryValues(); int mlIndex = ArrayUtils.indexOf(entryValues, "ml"); if (mlIndex != -1) { Log.d(TAG, "removing Malayalam from preference list"); localePref.setEntries(ArrayUtils.remove(entries, mlIndex)); localePref.setEntryValues(ArrayUtils.remove(entryValues, mlIndex)); } } addScreenTimeoutSettings(); } catch (Exception e) { Log.e(TAG, "Error preparing preference screen", e); Dialogs.getInstance().showErrorMsg(R.string.error_occurred); } }
From source file:com.bellman.bible.android.view.activity.settings.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // change theme according to light sensor UiUtils.applyTheme(this); super.onCreate(savedInstanceState); // allow partial integration with Embedded Bible framework - without this TTS stops // putting this before the below ensures any error dialog will be displayed in front of the settings screen and not the previous screen // see onStop for paired iAmNoLongerCurrent method call CurrentActivityHolder.getInstance().setCurrentActivity(this); try {/*from w w w . j a va 2s . c o m*/ addPreferencesFromResource(R.xml.settings); //If no light sensor exists switch to old boolean check box // see here for method: http://stackoverflow.com/questions/4081533/how-to-remove-android-preferences-from-the-screen Preference unusedNightModePreference = getPreferenceScreen() .findPreference(ScreenSettings.getUnusedNightModePreferenceKey()); getPreferenceScreen().removePreference(unusedNightModePreference); // if no tilt sensor then remove tilt-to-scroll setting if (!PageTiltScrollControl.isTiltSensingPossible()) { Preference tiltToScrollPreference = getPreferenceScreen() .findPreference(PageTiltScrollControl.TILT_TO_SCROLL_PREFERENCE_KEY); getPreferenceScreen().removePreference(tiltToScrollPreference); } // only JellyBean supports Malayalam so remove ml for older versions of Android if (!CommonUtils.isJellyBeanPlus()) { ListPreference localePref = (ListPreference) getPreferenceScreen().findPreference(LOCALE_PREF); CharSequence[] entries = localePref.getEntries(); CharSequence[] entryValues = localePref.getEntryValues(); int mlIndex = ArrayUtils.indexOf(entryValues, "ml"); if (mlIndex != -1) { Log.d(TAG, "removing Malayalam from preference list"); localePref.setEntries(ArrayUtils.remove(entries, mlIndex)); localePref.setEntryValues(ArrayUtils.remove(entryValues, mlIndex)); } } addScreenTimeoutSettings(); } catch (Exception e) { Log.e(TAG, "Error preparing preference screen", e); Dialogs.getInstance().showErrorMsg(R.string.error_occurred, e); } }
From source file:com.door43.translationstudio.SettingsActivity.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*from w w w. j a va2 s . c o m*/ */ private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. // Add 'general' preferences. addPreferencesFromResource(R.xml.general_preferences); // NOTE: this is a copy paste from GeneralPreferenceFragment // identify all typefaces in the assets directory AssetManager am = getResources().getAssets(); String fileList[] = null; ArrayList<String> entries = new ArrayList<String>(); ArrayList<String> entryValues = new ArrayList<String>(); try { fileList = am.list("fonts"); } catch (IOException e) { Logger.e(this.getClass().getName(), "failed to load font assets", e); } if (fileList != null) { for (int i = 0; i < fileList.length; i++) { File typeface = AppContext.context().getAssetAsFile("fonts/" + fileList[i]); if (typeface != null) { TTFAnalyzer analyzer = new TTFAnalyzer(); String fontname = ""; fontname = analyzer.getTtfFontName(typeface.getAbsolutePath()); if (fontname == null) { fontname = FilenameUtils.removeExtension(typeface.getName()); } entries.add(fontname); entryValues.add(fileList[i]); } } } ListPreference pref = (ListPreference) findPreference(KEY_PREF_TRANSLATION_TYPEFACE); pref.setEntries(entries.toArray(new CharSequence[entries.size()])); pref.setEntryValues(entryValues.toArray(new CharSequence[entryValues.size()])); bindPreferenceSummaryToValue(pref); // Add 'sharing' preferences, and a corresponding header. // PreferenceCategory preferenceHeader = new PreferenceCategory(this); // preferenceHeader.setTitle(R.string.pref_header_sharing); // getPreferenceScreen().addPreference(preferenceHeader); // addPreferencesFromResource(R.xml.sharing_preferences); // Add 'server' preferences, and a corresponding header. PreferenceCategory preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_synchronization); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.server_preferences); // Add 'legal' preferences, and a corresponding header. preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_legal); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.legal_preferences); // add 'advanced' preferences and coresponding hreader preferenceHeader = new PreferenceCategory(this); preferenceHeader.setTitle(R.string.pref_header_advanced); getPreferenceScreen().addPreference(preferenceHeader); addPreferencesFromResource(R.xml.advanced_preferences); // bind the correct legal document to the preference intent bindPreferenceClickToLegalDocument(findPreference("license_agreement"), R.string.license); bindPreferenceClickToLegalDocument(findPreference("statement_of_faith"), R.string.statement_of_faith); bindPreferenceClickToLegalDocument(findPreference("translation_guidelines"), R.string.translation_guidlines); bindPreferenceClickToLegalDocument(findPreference("software_licenses"), R.string.software_licenses); // Bind the summaries of EditText/List/Dialog/Ringtone preferences to // their values. When their values change, their summaries are updated // to reflect the new value, per the Android Design guidelines. // bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTOSAVE)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTH_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_GIT_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_AUTH_SERVER_PORT)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_GIT_SERVER_PORT)); // bindPreferenceSummaryToValue(findPreference(KEY_PREF_EXPORT_FORMAT)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_MEDIA_SERVER)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_LOGGING_LEVEL)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_BACKUP_INTERVAL)); bindPreferenceSummaryToValue(findPreference(KEY_PREF_TYPEFACE_SIZE)); }
From source file:jackpal.androidterm.TermPreferences.java
private void setAppPickerList() { PackageManager pm = this.getApplicationContext().getPackageManager(); final List<ApplicationInfo> installedAppList = pm.getInstalledApplications(0); final TreeMap<String, String> items = new TreeMap<>(); for (ApplicationInfo app : installedAppList) { Intent intent = pm.getLaunchIntentForPackage(app.packageName); if (intent != null) items.put(app.loadLabel(pm).toString(), app.packageName); }// w w w . j a v a 2s.c om List<String> list = new ArrayList<>(items.keySet()); final String labels[] = list.toArray(new String[list.size()]); list = new ArrayList<>(items.values()); final String packageNames[] = list.toArray(new String[list.size()]); String id = "external_app_package_name"; ListPreference packageName = (ListPreference) getPreferenceScreen().findPreference(id); packageName.setEntries(labels); packageName.setEntryValues(packageNames); }