public void updateNotificationPreference(ListPreference listpref) { CharSequence[] entries = listpref.getEntries(); CharSequence[] values = listpref.getEntryValues(); for (int i = 0; i < entries.length; i++) { int value = Integer.parseInt(values[i].toString()); if (entries[i].toString().contains("%d")) { entries[i] = String.format(entries[i].toString(), value); } } listpref.setEntries(entries); listpref.setSummary(listpref.getEntry().toString()); }
public ListPreferenceAssert hasEntryValues(CharSequence... values) { isNotNull(); CharSequence[] actualValues = actual.getEntryValues(); assertThat(actualValues) // .overridingErrorMessage("Expected entry values <%s> but was <%s>.", values, actualValues) // .isEqualTo(values); return this; }
@Test public void shouldHaveEntryValues() { CharSequence[] entryValues = { "this", "is", "only", "a", "test" }; assertThat(listPreference.getEntryValues()).isNull(); listPreference.setEntryValues(entryValues); assertThat(listPreference.getEntryValues()).isSameAs(entryValues); }
@Test public void shouldSetEntryValuesByResourceId() { assertThat(listPreference.getEntryValues()).isNull(); listPreference.setEntryValues(R.array.greetings); assertThat(listPreference.getEntryValues()).isNotNull(); }
String currentValue = m_updateList.getValue(); if (currentValue == null) { m_updateList.setValue((String)m_updateList.getEntryValues()[DEFAULT_UPDATE_TIME_INDEX]); currentValue = m_updateList.getValue();
private void preSelectListForBackward() { final ListPreference itemList = (ListPreference) findPreference("passSetting"); //remove other option if (Build.VERSION.SDK_INT < 21) { itemList.setEntries(itemList.getEntries()); itemList.setEntryValues(itemList.getEntryValues()); } if (itemList != null) { switch (G.protectionLevel()) { case "p0": itemList.setValueIndex(0); break; case "p1": itemList.setValueIndex(1); break; case "p2": itemList.setValueIndex(2); break; case "p3": itemList.setValueIndex(3); break; case "Disable": itemList.setValueIndex(0); break; default: itemList.setValueIndex(0); break; } } }
public boolean onPreferenceChange(Preference preference, Object newValue) { ListPreference x = (ListPreference) preference; int index = Arrays.asList(x.getEntryValues()).indexOf(newValue); preference.setSummary(x.getEntries()[index]); return true; } });
protected void setListPreferenceSummary(final ListPreference listPrefs, final String value) { final int selected = Arrays.asList(listPrefs.getEntryValues()).indexOf(value); setPreferenceSummary(listPrefs, selected != -1 ? (String) listPrefs.getEntries()[selected] : null); }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); String value = (String) ((ListPreference) preference).getEntryValues()[index]; ((ListPreference) preference).setSummary(value); return true; } });
/** * Changes catalog preference item to given filename. * Helper method to activate wifi catalog following successful download * * @param absoluteFile absolute filename (including path) */ private void activateWifiCatalog(final String absoluteFile) { final ListPreference lf = (ListPreference) findPreference(org.openbmap.Preferences.KEY_CATALOG_FILE); // get filename final String[] filenameArray = absoluteFile.split("\\/"); final String file = filenameArray[filenameArray.length - 1]; final CharSequence[] values = lf.getEntryValues(); for (int i = 0; i < values.length; i++) { if (file.equals(values[i].toString())) { lf.setValueIndex(i); } } }
public ListPreferenceAssert hasEntryValues(CharSequence... values) { isNotNull(); CharSequence[] actualValues = actual.getEntryValues(); assertThat(actualValues) // .overridingErrorMessage("Expected entry values <%s> but was <%s>.", values, actualValues) // .isEqualTo(values); return this; }
ArrayList<CharSequence>(Arrays.asList(preference.getEntries())); List<CharSequence> values = new ArrayList<CharSequence>(Arrays.asList(preference.getEntryValues()));
+ syncSource.getEntries().length]; CharSequence[] values = new CharSequence[synchronizers.size() + syncSource.getEntryValues().length]; System.arraycopy(syncSource.getEntries(), 0, entries, 0, syncSource.getEntries().length); System.arraycopy(syncSource.getEntryValues(), 0, values, 0, syncSource.getEntryValues().length);
protected void updatePrefsSummary(Preference pref) { if (pref == null) { return; } if (pref instanceof ListPreference) { ListPreference lst = (ListPreference) pref; String currentValue = lst.getValue(); int index = lst.findIndexOfValue(currentValue); CharSequence[] entries = lst.getEntries(); CharSequence[] entryValues = lst.getEntryValues(); if (index >= 0 && index < entries.length) { // Show info explaining that the small letters e.g. 3G/LTE etc are only shown when WiFi is off - this is standard Android behaviour boolean currentValueIsOffOrEmpty = currentValue.equals(entryValues[0]) || currentValue.equals(entryValues[1]); if (pref.getKey().equals(getString(R.string.key_signal_3g)) && !currentValueIsOffOrEmpty) { pref.setSummary(entries[index] + " - " + getString(R.string.network_icon_info)); } else { pref.setSummary(entries[index]); } } } else if (pref instanceof TimePreference) { if (pref.getKey().equals(getString(R.string.key_clock_time))) { String time = ((TimePreference) pref).getTime(); pref.setSummary(time); } } } }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String oldValue = ((ListPreference) preference).getValue(); int index = ((ListPreference) preference).findIndexOfValue(newValue.toString()); String entry = (String) ((ListPreference) preference).getEntries()[index]; String value = (String) ((ListPreference) preference).getEntryValues()[index]; ((ListPreference) preference).setSummary(entry); Intent prefIntent = null; if (value.equals(getString(R.string.protocol_odk_default))) { setDefaultAggregatePaths(); prefIntent = new Intent(PreferencesActivity.this, AggregatePreferencesActivity.class); } else if (value.equals(getString(R.string.protocol_google_maps_engine))) { //prefIntent = new Intent(PreferencesActivity.this, GMEPreferencesActivity.class); } else { // other prefIntent = new Intent(PreferencesActivity.this, OtherPreferencesActivity.class); } prefIntent.putExtra(INTENT_KEY_ADMIN_MODE, adminMode); mProtocolSettings.setIntent(prefIntent); if (!((String) newValue).equals(oldValue)) { startActivity(prefIntent); } return true; } });
private void highlightBetaLanguages() { ListPreference pref = (ListPreference) findPreference("dict"); CharSequence[] entries = pref.getEntries(); CharSequence[] values = pref.getEntryValues(); for (int i = 0; i < entries.length; i ++) { Language language = Language.fromOrNull(values[i].toString()); if (language != null) { if (language.isBeta()) { entries[i] = getString(R.string.pref_dict_beta, entries[i]); } } } pref.setEntries(entries); }
} else if (preference == mMaxFavPreference) { int index = mMaxFavPreference.findIndexOfValue(newValue.toString()); CharSequence[] entries = mMaxFavPreference.getEntryValues(); int maxFav = Integer.valueOf(entries[index].toString()); mSharedPreferences.edit().putInt("prefs_key_max_recent_word", maxFav).apply(); } else if (preference == mLangPreference) { int index = mLangPreference.findIndexOfValue(newValue.toString()); CharSequence[] entrieValues = mLangPreference.getEntryValues(); CharSequence[] entries = mLangPreference.getEntries(); String lang = entrieValues[index].toString();
CharSequence[] resEV = record_videoRes.getEntryValues();