Java Code Examples for android.preference.EditTextPreference#getText()
The following examples show how to use
android.preference.EditTextPreference#getText() .
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: PreferencesActivity.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
private static void updatePrefSummary(Preference pref) { if (pref instanceof ListPreference) { ListPreference listPref = (ListPreference) pref; pref.setSummary(listPref.getEntry()); } if (pref instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) pref; if (pref.getKey().contains("password") || pref.getKey().contains("secret")) { pref.setSummary("******"); } else if (editTextPref.getText() != null) { ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); pref.setSummary(editTextPref.getText()); } else { for (PluginBase plugin : MainApp.getPluginsList()) { plugin.updatePreferenceSummary(pref); } } } if (pref != null) adjustUnitDependentPrefs(pref); }
Example 2
Source File: PreferencesDecorator.java From document-viewer with GNU General Public License v3.0 | 6 votes |
protected void decorateEditPreference(final EditTextPreference textPrefs) { final CharSequence summary = textPrefs.getSummary(); summaries.put(textPrefs.getKey(), summary); final String value = textPrefs.getText(); setPreferenceSummary(textPrefs, value); addListener(textPrefs, new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(final Preference preference, final Object newValue) { setPreferenceSummary(textPrefs, (String) newValue); return true; } }); }
Example 3
Source File: SetupActivity.java From trigger with GNU General Public License v2.0 | 5 votes |
private String getText(String key) { Preference p = findAnyPreference(key, null); if (p instanceof EditTextPreference) { EditTextPreference etp = (EditTextPreference) p; return etp.getText(); } else if (p instanceof ListPreference) { ListPreference lp = (ListPreference) p; return lp.getValue(); } else { Log.w("SetupActivity.setText", "Cannot find EditTextPreference/ListPreference in PreferenceGroup with key: " + key); return ""; } }
Example 4
Source File: BaseImplementation.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
protected boolean isEmpty(EditTextPreference edt){ if(edt.getText() == null){ return true; } if(edt.getText().equals("")){ return true; } return false; }
Example 5
Source File: OthersPreferenceFragment.java From SkyTube with GNU General Public License v3.0 | 5 votes |
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if(key != null) { if (key.equals(getString(R.string.pref_key_default_tab_name))) { // If the user changed the Default Tab Preference, update the summary to show the new default tab ListPreference defaultTabPref = (ListPreference) findPreference(key); defaultTabPref.setSummary(String.format(getString(R.string.pref_summary_default_tab), defaultTabPref.getEntry())); } else if (key.equals(getString(R.string.pref_key_hide_tabs))) { displayRestartDialog(R.string.pref_hide_tabs_restart, true); } else if (key.equals(getString(R.string.pref_youtube_api_key))) { // Validate the entered API Key when saved (and not empty), with a simple call to get the most popular video EditTextPreference youtubeAPIKeyPref = (EditTextPreference) findPreference(getString(R.string.pref_youtube_api_key)); String youtubeAPIKey = youtubeAPIKeyPref.getText(); if (youtubeAPIKey != null) { youtubeAPIKey = youtubeAPIKey.trim(); if (!youtubeAPIKey.isEmpty()) { // validate the user's API key new ValidateYouTubeAPIKeyTask(youtubeAPIKey).executeInParallel(); } else { // inform the user that we are going to use the default YouTube API key and // that we need to restart the app displayRestartDialog(R.string.pref_youtube_api_key_default,false); } } } else if (key.equals(getString(R.string.pref_key_subscriptions_alphabetical_order))) { SubsAdapter subsAdapter = SubsAdapter.get(getActivity()); subsAdapter.refreshSubsList(); }/*else if (key.equals(getString(R.string.pref_feed_notification_key))) { ListPreference feedNotificationPref = (ListPreference) findPreference(key); feedNotificationPref.setSummary(String.format(getString(R.string.pref_summary_feed_notification), feedNotificationPref.getEntry())); int interval = Integer.parseInt(feedNotificationPref.getValue()); SkyTubeApp.setFeedUpdateInterval(interval); }*/ } }
Example 6
Source File: SettingsActivity.java From AnkiDroid-Wear with GNU General Public License v2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.activity_settings); NumberPickerPreference fontSizeNumberPicker = (NumberPickerPreference) this.findPreference(getResources().getString(R.string.font_size_key)); NumberPickerPreference screenTimeoutNumberPicker = (NumberPickerPreference) this.findPreference(getResources().getString(R.string.screen_timeout)); EditTextPreference mediaLocationDir = (EditTextPreference) this.findPreference(getResources().getString(R.string.media_folder_location)); if (mediaLocationDir.getText() == null || mediaLocationDir.getText().isEmpty()) { mediaLocationDir.setText(Environment.getExternalStorageDirectory() + "/AnkiDroid/collection.media"); } CardMedia.mediaFolder = mediaLocationDir.getText(); SendToWatchWhenPreferencesChangeListener listener = new SendToWatchWhenPreferencesChangeListener(); fontSizeNumberPicker.setOnPreferenceChangeListener(listener); screenTimeoutNumberPicker.setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.card_flip_animation_key)).setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.double_tap_key)).setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.play_sounds)).setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.ask_before_first_sound)).setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.day_mode)).setOnPreferenceChangeListener(listener); this.findPreference(getResources().getString(R.string.ambient_mode_key)) .setOnPreferenceChangeListener(listener); mediaLocationDir.setOnPreferenceChangeListener(listener); }
Example 7
Source File: ChanFragment.java From Dashchan with Apache License 2.0 | 5 votes |
private void updateDefaultBoardSummary() { EditTextPreference preference = defaultBoardPreference; String text = preference.getText(); if (!StringUtils.isEmpty(text)) { String boardName = StringUtils.validateBoardName(text); if (boardName != null) { text = StringUtils.formatBoardTitle(chanName, boardName, ChanConfiguration.get(chanName).getBoardTitle(boardName)); } else { text = null; } } preference.setSummary(text); }
Example 8
Source File: BasePreferenceFragment.java From Dashchan with Apache License 2.0 | 5 votes |
private void updateEditTextSummary(EditTextPreference preference) { String text = preference.getText(); if (StringUtils.isEmpty(text)) { CharSequence hint = preference.getEditText().getHint(); text = hint != null ? hint.toString() : null; } preference.setSummary(text); }
Example 9
Source File: SettingsActivity.java From android-app with GNU General Public License v3.0 | 5 votes |
private void setPasswordSummary(String key) { EditTextPreference preference = (EditTextPreference)findPreference(key); if(preference != null) { String value = preference.getText(); preference.setSummary(value == null || value.isEmpty() ? "" : "********"); } }
Example 10
Source File: SettingsFragment.java From physical-web with Apache License 2.0 | 5 votes |
private void updatePwsPreference() { ListPreference listPreference = (ListPreference) findPreference( getString(R.string.pws_endpoint_setting_key)); String entry = (String) listPreference.getEntry(); if (entry == null) { return; } if (entry.equals(getString(R.string.custom_pws))) { // User selected custom PWS therefore need to update it accordingly EditTextPreference customPwsUrlPreference = (EditTextPreference) mCustomEndpointCategory.findPreference( getString(R.string.custom_pws_url_key)); ListPreference customPwsVersionPreference = (ListPreference) mCustomEndpointCategory.findPreference( getString(R.string.custom_pws_version_key)); EditTextPreference customPwsApiKeyPreference = (EditTextPreference) mCustomEndpointCategory.findPreference( getString(R.string.custom_pws_api_key_key)); String customPwsUrl = customPwsUrlPreference.getText(); int customPwsVersion = Integer.parseInt(customPwsVersionPreference.getValue()); String customPwsApiKey = customPwsApiKeyPreference.getText(); customPwsUrl = customPwsUrl == null ? "" : customPwsUrl; customPwsApiKey = customPwsApiKey == null ? "" : customPwsApiKey; listPreference.setValue(Utils.formatEndpointForSharedPrefernces(customPwsUrl, customPwsVersion, customPwsApiKey)); getPreferenceScreen().addPreference(mCustomEndpointCategory); } else { getPreferenceScreen().removePreference(mCustomEndpointCategory); } }
Example 11
Source File: PriceHitAlarmSettingsFragment.java From boilr with GNU General Public License v3.0 | 5 votes |
@Override protected void updateDependentOnPair() { super.updateDependentOnPair(); EditTextPreference[] edits = { mUpperLimitPref, mLowerLimitPref }; String text; for (EditTextPreference edit : edits) { edit.setEnabled(true); text = edit.getText(); if(text != null && !text.equals("")) edit.setSummary(text + " " + alarm.getPair().getExchange()); } }
Example 12
Source File: BaseImplementation.java From CSipSimple with GNU General Public License v3.0 | 4 votes |
protected boolean isMatching(EditTextPreference edt, String regex) { if(edt.getText() == null){ return false; } return Pattern.matches(regex, edt.getText()); }
Example 13
Source File: BaseImplementation.java From CSipSimple with GNU General Public License v3.0 | 2 votes |
/** * @see EditTextPreference#getText() * @param edt */ protected String getText(EditTextPreference edt){ return edt.getText(); }