List of usage examples for android.preference EditTextPreference getText
public String getText()
From source file:org.thoughtcrime.securesms.MmsPreferencesFragment.java
private void initializeEditTextSummary(final EditTextPreference preference) { if (preference.getText() == null) { preference.setSummary("Not set"); } else {//from w w w.j ava2 s. c o m preference.setSummary(preference.getText()); } preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference pref, Object newValue) { preference.setSummary(newValue == null ? "Not set" : ((String) newValue)); return true; } }); }
From source file:de.wolfgang_popp.shoppinglist.activity.SettingsFragment.java
private void updatePreferences(Preference p) { if (p instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) p; p.setSummary(editTextPref.getText()); }//w w w .j ava 2 s . c om }
From source file:com.manning.androidhacks.hack004.MainActivity.java
private void updateUserText() { EditTextPreference pref; pref = (EditTextPreference) findPreference("pref_username"); String user = pref.getText(); if (user == null) { user = "?"; }/*from w ww. jav a 2 s. co m*/ pref.setSummary(String.format("Username: %s", user)); }
From source file:com.windnow.SettingsActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_type_prefs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { getActionBar().setDisplayHomeAsUpEnabled(true); }/*ww w.j av a 2 s . c o m*/ addPreferencesFromResource(R.xml.pref_general); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.registerOnSharedPreferenceChangeListener(this); Preference p = findPreference("user_dir"); EditTextPreference editTextPref = (EditTextPreference) p; p.setSummary(getString(R.string.pref_dialog_sum_dir) + " " + editTextPref.getText()); Preference q = findPreference("pref_list"); ListPreference listPref = (ListPreference) q; q.setSummary(getString(R.string.maximum_number_summary) + " " + listPref.getValue()); }
From source file:com.windnow.SettingsActivity.java
@SuppressWarnings("deprecation") @Override/*from ww w .j av a 2s . c o m*/ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Preference p = findPreference(key); if (p.getKey().equals("pref_list") && p instanceof ListPreference) { MainActivity.maxRetries = Integer.parseInt(prefs.getString("pref_list", "5")); ListPreference listPref = (ListPreference) p; p.setSummary(getString(R.string.maximum_number_summary) + " " + listPref.getValue()); } if (p.getKey().equals("user_dir") && p instanceof EditTextPreference) { LoadSaveOps.userDir = prefs.getString("user_dir", "WindNow"); EditTextPreference editTextPref = (EditTextPreference) p; p.setSummary(getString(R.string.pref_dialog_sum_dir) + " " + editTextPref.getText()); } }
From source file:org.deviceconnect.android.client.fragment.AbstractSettingsFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.settings); Bundle args = new Bundle(); args.putParcelableArrayList(OpenSourceLicenseFragment.EXTRA_OSS, getOpenSourceSoftware()); mOssFragment = new OpenSourceLicenseFragment(); mOssFragment.setArguments(args);/* w w w. j av a 2s. c o m*/ Bundle policyArgs = new Bundle(); policyArgs.putInt(Intent.EXTRA_TITLE, R.string.privacy_policy); policyArgs.putInt(Intent.EXTRA_TEXT, R.raw.privacypolicy); mPrivacyPolicyFragment = new TextDialogFragment(); mPrivacyPolicyFragment.setArguments(policyArgs); Bundle tosArgs = new Bundle(); tosArgs.putInt(Intent.EXTRA_TITLE, R.string.terms_of_service); tosArgs.putInt(Intent.EXTRA_TEXT, R.raw.termsofservice); mTermsOfServiceFragment = new TextDialogFragment(); mTermsOfServiceFragment.setArguments(tosArgs); PreferenceScreen versionPreferences = (PreferenceScreen) getPreferenceScreen() .findPreference(getString(R.string.key_settings_about_appinfo)); try { versionPreferences.setSummary((getActivity().getPackageManager() .getPackageInfo(getActivity().getPackageName(), 0).versionName)); } catch (NameNotFoundException e) { e.printStackTrace(); } CheckBoxPreference checkBoxSslPreferences = (CheckBoxPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_ssl)); checkBoxSslPreferences.setOnPreferenceChangeListener(this); EditTextPreference editHostPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_host)); editHostPreferences.setOnPreferenceChangeListener(this); editHostPreferences.setSummary(editHostPreferences.getText()); EditTextPreference editPortPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_port)); editPortPreferences.setOnPreferenceChangeListener(this); editPortPreferences.setSummary(editPortPreferences.getText()); // Local OAuth SettingsActivity activity = (SettingsActivity) getActivity(); EditTextPreference editClientIdPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_client_id)); editClientIdPreferences.setSummary(activity.getClientId()); EditTextPreference editClientSecretPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_client_secret)); editClientSecretPreferences.setSummary(activity.getClientSecret()); EditTextPreference editAccessTokenPreferences = (EditTextPreference) getPreferenceScreen() .findPreference(getString(R.string.key_settings_dconn_access_token)); editAccessTokenPreferences.setSummary(activity.getAccessToken()); }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
/** * Will go through each preference element and initialize/update the summary according to its value. * @note this will also correct invalid user inputs on EdittextPreferences! *///from ww w . j a v a 2 s . co m public void updateSummaries() { // Source Type ListPreference listPref = (ListPreference) findPreference(getString(R.string.pref_sourceType)); listPref.setSummary(getString(R.string.pref_sourceType_summ, listPref.getEntry())); // Direct Sampling listPref = (ListPreference) findPreference(getString(R.string.pref_rtlsdr_directSamp)); listPref.setSummary(getString(R.string.pref_rtlsdr_directSamp_summ, listPref.getEntry())); // Frequency display listPref = (ListPreference) findPreference(getString(R.string.pref_surface_unit)); listPref.setSummary(getString(R.string.pref_surface_unit_summ, listPref.getEntry())); // FileSource Frequency EditTextPreference editTextPref = (EditTextPreference) findPreference( getString(R.string.pref_filesource_frequency)); if (editTextPref.getText().length() == 0) editTextPref.setText(getString(R.string.pref_filesource_frequency_default)); editTextPref.setSummary(getString(R.string.pref_filesource_frequency_summ, editTextPref.getText())); // FileSource Sample Rate editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_filesource_sampleRate)); if (editTextPref.getText().length() == 0) editTextPref.setText(getString(R.string.pref_filesource_sampleRate_default)); editTextPref.setSummary(getString(R.string.pref_filesource_sampleRate_summ, editTextPref.getText())); // FileSource File editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_filesource_file)); editTextPref.setSummary(getString(R.string.pref_filesource_file_summ, editTextPref.getText())); // FileSource Format listPref = (ListPreference) findPreference(getString(R.string.pref_filesource_format)); listPref.setSummary(getString(R.string.pref_filesource_format_summ, listPref.getEntry())); // HackRF frequency shift editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_hackrf_frequencyOffset)); if (editTextPref.getText().length() == 0) editTextPref.setText("0"); editTextPref.setSummary(getString(R.string.pref_hackrf_frequencyOffset_summ, editTextPref.getText())); // RTL-SDR IP editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_rtlsdr_ip)); editTextPref.setSummary(getString(R.string.pref_rtlsdr_ip_summ, editTextPref.getText())); // RTL-SDR Port editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_rtlsdr_port)); editTextPref.setSummary(getString(R.string.pref_rtlsdr_port_summ, editTextPref.getText())); // RTL-SDR frequency correction editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_rtlsdr_frequencyCorrection)); if (editTextPref.getText().length() == 0) editTextPref.setText(getString(R.string.pref_rtlsdr_frequencyCorrection_default)); editTextPref.setSummary(getString(R.string.pref_rtlsdr_frequencyCorrection_summ, editTextPref.getText())); // RTL-SDR frequency shift editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_rtlsdr_frequencyOffset)); if (editTextPref.getText().length() == 0) editTextPref.setText("0"); editTextPref.setSummary(getString(R.string.pref_rtlsdr_frequencyOffset_summ, editTextPref.getText())); // FFT size listPref = (ListPreference) findPreference(getString(R.string.pref_fftSize)); listPref.setSummary(getString(R.string.pref_fftSize_summ, listPref.getEntry())); // Color map type listPref = (ListPreference) findPreference(getString(R.string.pref_colorMapType)); listPref.setSummary(getString(R.string.pref_colorMapType_summ, listPref.getEntry())); // FFT drawing type listPref = (ListPreference) findPreference(getString(R.string.pref_fftDrawingType)); listPref.setSummary(getString(R.string.pref_fftDrawingType_summ, listPref.getEntry())); // Averaging listPref = (ListPreference) findPreference(getString(R.string.pref_averaging)); listPref.setSummary(getString(R.string.pref_averaging_summ, listPref.getEntry())); // Screen Orientation listPref = (ListPreference) findPreference(getString(R.string.pref_screenOrientation)); listPref.setSummary(getString(R.string.pref_screenOrientation_summ, listPref.getEntry())); // Spectrum Waterfall Ratio listPref = (ListPreference) findPreference(getString(R.string.pref_spectrumWaterfallRatio)); listPref.setSummary(getString(R.string.pref_spectrumWaterfallRatio_summ, listPref.getEntry())); // Font Size listPref = (ListPreference) findPreference(getString(R.string.pref_fontSize)); listPref.setSummary(getString(R.string.pref_fontSize_summ, listPref.getEntry())); // Frame Rate SwitchPreference switchPref = (SwitchPreference) findPreference(getString(R.string.pref_dynamicFrameRate)); listPref = (ListPreference) findPreference(getString(R.string.pref_frameRate)); if (switchPref.isChecked()) listPref.setSummary(getString(R.string.pref_frameRate_summ, "auto")); else listPref.setSummary(getString(R.string.pref_frameRate_summ, listPref.getEntry())); // Logfile editTextPref = (EditTextPreference) findPreference(getString(R.string.pref_logfile)); editTextPref.setSummary(getString(R.string.pref_logfile_summ, editTextPref.getText())); // Shared preferences updated in e.g. the onRequestPermissionResult() method are // not automatically updated in the preference fragment gui. do it manually: SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity()); switchPref = (SwitchPreference) findPreference(getString(R.string.pref_logging)); switchPref.setChecked(preferences.getBoolean(getString(R.string.pref_logging), false)); }
From source file:com.hichinaschool.flashcards.anki.Preferences.java
private void updateEditTextPreference(String key) { EditTextPreference pref = (EditTextPreference) getPreferenceScreen().findPreference(key); String entry;/*from w ww.ja v a 2s . c o m*/ try { entry = pref.getText(); } catch (NullPointerException e) { Log.e(AnkiDroidApp.TAG, "Error getting set preference value of " + key + ": " + e); entry = "?"; } if (mListsToUpdate.containsKey(key)) { pref.setSummary(replaceString(mListsToUpdate.get(key), entry)); } else { String oldsum = (String) pref.getSummary(); if (oldsum.contains("XXX")) { mListsToUpdate.put(key, oldsum); pref.setSummary(replaceString(oldsum, entry)); } else { pref.setSummary(entry); } } }
From source file:com.almalence.opencam.Fragment.java
private void updatePrefSummary(Preference p) { if (p instanceof ListPreference) { ListPreference listPref = (ListPreference) p; p.setSummary(listPref.getEntry()); }/*from w w w . j a v a 2 s. co m*/ if (p instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) p; if (p.getKey().equalsIgnoreCase("editKey")) { p.setSummary("*****"); } else { p.setSummary(editTextPref.getText()); } } }
From source file:com.mantz_it.rfanalyzer.SettingsFragment.java
/** * Will try to extract the file source preferences (frequency, sample rate, format) from the filename *///from w w w .java 2 s. com 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); }