protected void save() { preferences.activateAccelerometer(true); preferences.activateCamera(true); preferences.activateMicrophone(true); setPhoneNumber(); boolean remoteAccessActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).isChecked(); preferences.activateRemoteAccess(remoteAccessActive); String password = ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).getText(); if (checkValidStrings(password, preferences.getRemoteAccessCredential()) && (TextUtils.isEmpty(preferences.getRemoteAccessCredential()) || !password.trim().equals(preferences.getRemoteAccessCredential().trim()))) { preferences.setRemoteAccessCredential(password.trim()); app.stopServer(); app.startServer(); } mActivity.setResult(Activity.RESULT_OK); mActivity.finish(); }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && data != null) { String onionHost = data.getStringExtra("hs_host"); if (checkValidString(onionHost)) { preferences.setRemoteAccessOnion(onionHost.trim()); ((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ONION)).setText(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT); if (checkValidString(preferences.getRemoteAccessOnion())) { findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT); } else { findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(R.string.remote_access_hint); } } } }
private void setPhoneNumber() { boolean smsActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked(); String phoneNumber = ((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).getText(); if (smsActive && checkValidString(phoneNumber)) { preferences.activateSms(true); } else { preferences.activateSms(false); } if (checkValidString(phoneNumber)) { preferences.setSmsNumber(phoneNumber.trim()); findPreference(PreferenceManager.SMS_NUMBER).setSummary(phoneNumber.trim()); } else { preferences.setSmsNumber(""); findPreference(PreferenceManager.SMS_NUMBER).setSummary(R.string.sms_dialog_message); } }
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.settings_preferences); if(getActivity()!=null) { Activity mActivity = getActivity(); final SharedPreferences sharedPref = mActivity.getPreferences(Context.MODE_PRIVATE); final String currentServer = sharedPref.getString(getString(R.string.saved_server_ip), "https://github.com/jboss-outreach"); final EditTextPreference mPreference = (EditTextPreference) findPreference("server_location"); final SwitchPreference mToggleMode = (SwitchPreference) findPreference("dark_theme"); mToggleMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { mActivity.startActivity(new Intent(mActivity, MainActivity.class)); mActivity.finish(); return true; } }); mPreference.setSummary(currentServer); mPreference.setText(currentServer); } }
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { if (preference.getKey().equals(getString(R.string.pref_radius_key))) { preference.setSummary(value + "m"); } else { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); } } }
private void setPreferenceDetails(AccountConfig details) { for (ConfigKey confKey : details.getKeys()) { Preference pref = findPreference(confKey.key()); if (pref == null) { continue; } if (!confKey.isTwoState()) { String val = details.get(confKey); ((EditTextPreference) pref).setText(val); if (pref instanceof PasswordPreference) { StringBuilder tmp = new StringBuilder(); for (int i = 0; i < val.length(); ++i) { tmp.append("*"); } pref.setSummary(tmp.toString()); } else { pref.setSummary(val); } } else { ((TwoStatePreference) pref).setChecked(details.getBool(confKey)); } } }
public static void initializeAccurateTaking(EditTextPreference accurateMaxCount) { accurateMaxCount.setSummary(accurateMaxCount.getText()); accurateMaxCount.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange( Preference preference, Object newValue) { preference.setSummary((CharSequence) newValue); return true; } }); }
private void setPreferenceSummary(android.support.v7.preference.Preference preference, String value) { if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); } }
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { // For EditTextPreferences, set the summary to the value's simple string representation. preference.setSummary(value); } }
/** * Updates the summary for the preference * * @param preference The preference to be updated * @param value The value that the preference was updated to */ private void setPreferenceSummary(Preference preference, String value) { // COMPLETED (3) Don't forget to add code here to properly set the summary for an EditTextPreference if (preference instanceof ListPreference) { // For list preferences, figure out the label of the selected value ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(value); if (prefIndex >= 0) { // Set the summary to that label listPreference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { preference.setSummary(value); } }
private void checkSignalUsername() { if (checkValidString(preferences.getSignalUsername())) { findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(preferences.getSignalUsername().trim()); ((EditTextPreference) findPreference(PreferenceManager.REGISTER_SIGNAL)).setText(preferences.getSignalUsername().trim()); } else { findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(R.string.signal_dialog_summary); } }
private void updatePreferenceSummary(Preference preference) { if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; preference.setSummary(listPreference.getEntry()); } else if (preference instanceof EditTextPreference) { EditTextPreference editTextPreference = (EditTextPreference) preference; if (editTextPreference.getText() != null && !editTextPreference.getText().isEmpty()) { preference.setSummary(editTextPreference.getText()); } } }
@Override public void onCreatePreferences(Bundle bundle, String s) { addPreferencesFromResource(R.xml.settings_general); // initial day and night mode ListPreference dayNightPref = (ListPreference) findPreference(DAY_NIGHT); Observable.just(PrefsUtil.getPrefDayNightMode(getActivity())) .map(Constant.dayNightSummary::get) .subscribe(dayNightPref::setSummary); dayNightPref.setOnPreferenceChangeListener(listener); // initial image size ListPreference imageSizePref = (ListPreference) findPreference(IMAGE_SIZE); imageSizePref.setSummary(PrefsUtil.getPrefImageSize(getActivity())); Observable.just(PrefsUtil.getPrefImageSize(getActivity())) .map(Constant.imageSizeSummary::get) .subscribe(imageSizePref::setSummary); imageSizePref.setOnPreferenceChangeListener(listener); // initial nickname and summary EditTextPreference namePref = (EditTextPreference) findPreference(NICKNAME); namePref.setSummary(PrefsUtil.getPrefNickname(getActivity())); namePref.setOnPreferenceChangeListener(listener); // initial signature and summary EditTextPreference signPref = (EditTextPreference) findPreference(SIGNATURE); signPref.setSummary(PrefsUtil.getPrefSignature(getActivity())); signPref.setOnPreferenceChangeListener(listener); }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_discount")) { Preference preference = findPreference(key); EditTextPreference editTextPreference = (EditTextPreference) preference; editTextPreference.setSummary(sharedPreferences.getString(key, String.valueOf(editTextPreference.getSummary()))); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_service")) { Preference preference = findPreference(key); EditTextPreference editTextPreference = (EditTextPreference) preference; editTextPreference.setSummary(sharedPreferences.getString(key, String.valueOf(editTextPreference.getSummary()))); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_tax")) { Preference preference = findPreference(key); EditTextPreference editTextPreference = (EditTextPreference) preference; editTextPreference.setSummary(sharedPreferences.getString(key, String.valueOf(editTextPreference.getSummary()))); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference preference = findPreference(key); if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; int prefIndex = listPreference.findIndexOfValue(sharedPreferences.getString(key, "")); if (prefIndex >= 0) { preference.setSummary(listPreference.getEntries()[prefIndex]); } } else if (preference instanceof EditTextPreference) { preference.setSummary(sharedPreferences.getString(key, "")); } else { preference.setSummary(sharedPreferences.getString(key, "")); } }
private void onCreateEditTextPreference(int resId) { EditTextPreference pref = (EditTextPreference)getPreferenceManager().findPreference(getString(resId)); pref.setSummary(pref.getText()); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { preference.setSummary(newValue.toString()); return true; } }); }
@Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.preferences); remindersDaysEditTextPreference = (EditTextPreference) findPreference(getString(R.string.pref_reminders_days_key)); Preference openCalendar = findPreference(getString(R.string.pref_open_calendar_key)); openCalendar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @SuppressLint("NewApi") @Override public boolean onPreferenceClick(Preference preference) { IntentCall.openCalendarAt(getContext(), new Date()); return true; } }); accountResolver = CalendarAccount.getAccount(getContext()); preferenceCreateCalendar = (TwoStatePreference) findPreference(getString(R.string.pref_create_calendar_key)); preferenceCreateCalendar.setDefaultValue(false); preferenceCreateCalendar.setOnPreferenceClickListener(onPreferenceCalendarClick); preferenceSpecial = (TwoStatePreference) findPreference(getString(R.string.pref_special_service_key)); preferenceSpecial.setDefaultValue(false); if (!BuildConfig.FULL_VERSION) { // Disable switch and show pro dialog if free version preferenceSpecial.setOnPreferenceClickListener(onPreferenceProFeatureClick); } else { preferenceSpecial.setOnPreferenceClickListener(onPreferenceSendSmsClick); } TwoStatePreference preferenceHideInactive = (TwoStatePreference) findPreference(getString(R.string.pref_hide_inactive_features_key)); if (!BuildConfig.FULL_VERSION) { preferenceHideInactive.setOnPreferenceClickListener(onPreferenceProFeatureClick); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { android.preference.Preference pref = findPreference(key); if (pref instanceof android.preference.ListPreference) { android.preference.ListPreference listPref = (android.preference.ListPreference) pref; listPref.setSummary(listPref.getEntry()); } else if (pref instanceof android.preference.EditTextPreference) { android.preference.EditTextPreference editTextPref = (android.preference.EditTextPreference) pref; editTextPref.setSummary(editTextPref.getText()); } }
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); if (pref instanceof ListPreference) { ListPreference listPref = (ListPreference) pref; listPref.setSummary(listPref.getEntry()); } else if (pref instanceof EditTextPreference) { EditTextPreference editTextPref = (EditTextPreference) pref; editTextPref.setSummary(editTextPref.getText()); } }
private void setMessageText(String newValue) { EditTextPreference msg_name = (EditTextPreference) findPreference("bn_notification_action_message"); if (newValue != null && !newValue.isEmpty()) { msg_name.setSummary(newValue); mActionBeacon.getNotification().setMessage(newValue); } else { msg_name.setSummary(getString(R.string.pref_bn_default_notification_action_message)); mActionBeacon.getNotification().setMessage(getString(R.string.pref_bn_default_notification_action_message)); } }
private void setActionParam1(String newValue) { EditTextPreference param_name = (EditTextPreference) findPreference("ba_action_param1"); if (newValue != null && !newValue.isEmpty()) { param_name.setSummary(newValue); mActionBeacon.setActionParam(newValue); } else { param_name.setSummary(""); mActionBeacon.setActionParam(""); } }
private void setNameText(String newValue) { EditTextPreference name = (EditTextPreference) findPreference("bd_name_info"); if (newValue != null && !newValue.isEmpty()) { name.setSummary(newValue); mActionBeacon.setName(newValue); } else { name.setSummary(getString(R.string.pref_bd_default_name)); mActionBeacon.setName(getString(R.string.pref_bd_default_name)); } }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String correctURL = fixURL((String) newValue); SharedPreferences.Editor editor = preference.getSharedPreferences().edit(); PreferenceManager preferenceManager = preference.getPreferenceManager(); editor.putString("school", correctURL).commit(); ((EditTextPreference) preferenceManager.findPreference("school")).setText(correctURL); preferenceManager.findPreference("school").setSummary(correctURL); return false; }
/** * Set an initial value. Updates the summary to match. */ private void setup(String key, Object adminSetting) { final Preference pref = findPreference(key); final DpcPreferenceBase dpcPref = (DpcPreferenceBase) pref; // Disable preferences that don't apply to the parent profile dpcPref.setCustomConstraint( () -> Keys.NOT_APPLICABLE_TO_PARENT.contains(key) && isParentProfileInstance() ? R.string.not_for_parent_profile : NO_CUSTOM_CONSTRIANT ); // We do not allow user to add trust agent config in pre-N devices in managed profile. if (!BuildCompat.isAtLeastN() && key.equals(Keys.SET_TRUST_AGENT_CONFIG)) { dpcPref.setAdminConstraint(DpcPreferenceHelper.ADMIN_DEVICE_OWNER); return; } // Set up initial state and possibly a descriptive summary of said state. if (pref instanceof EditTextPreference) { String stringValue = (adminSetting != null ? adminSetting.toString() : null); if (adminSetting instanceof Number && "0".equals(stringValue)) { stringValue = null; } ((EditTextPreference) pref).setText(stringValue); pref.setSummary(stringValue); } else if (pref instanceof TwoStatePreference) { ((TwoStatePreference) pref).setChecked((Boolean) adminSetting); } // Start listening for change events. pref.setOnPreferenceChangeListener(this); pref.setOnPreferenceClickListener(this); }
@Override public void onCreatePreferences(Bundle bundle, String s) { //add xml addPreferencesFromResource(R.xml.preferences); sharedPreferences = PreferenceManager.getDefaultSharedPreferences (getActivity()); editor = sharedPreferences.edit(); spChanged = new SharedPreferences.OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals("pref_change_username")) { EditTextPreference newUserName = (EditTextPreference) findPreference(key); String nameChange = newUserName.getText(); //TODO: Add Firebase call to set the UserName change //Clear after text is received newUserName.setText(""); } else if (key.equals("pref_text_size")) { ListPreference textSize = (ListPreference) findPreference (key); String choice = textSize.getValue(); //Returns Small, Medium, Large } } }; sharedPreferences.registerOnSharedPreferenceChangeListener(spChanged); }
private void updatePrefSummary(Preference preference) { if (preference instanceof ListPreference) { final ListPreference listPref = (ListPreference) preference; preference.setSummary(listPref.getEntry()); } if (preference instanceof EditTextPreference) { final EditTextPreference editTextPref = (EditTextPreference) preference; preference.setSummary(editTextPref.getText()); } }
private void setSessionEditText() { if (isSessionSavingEnabled()) { getPreferenceScreen().addPreference(savedSessionEditTextPreference); ((EditTextPreference)savedSessionEditTextPreference).setText(getSavedSessionStateAsString()); } else { if (savedSessionEditTextPreference != null) { getPreferenceScreen().removePreference(savedSessionEditTextPreference); } } }
@Override public void onCreatePreferences(Bundle bundle, String rootKey) { setPreferencesFromResource(R.xml.prefupdate, rootKey); //NOTE the rest of this code in not necessary, used so you can display current value on the summary line. // Get a reference to the preferences, so we can dynamically update the preference screen summary info. mEditTextPreference = (EditTextPreference)getPreferenceScreen().findPreference("textPref"); mListPreference = (ListPreference)getPreferenceScreen().findPreference("list_preference"); }
private void setForumAddress() { mForumAddress = (EditTextPreference) findPreference(GlobalSetting.FORUM_ADDRESS); String forumAddress = GlobalSetting.getForumAddress(); mForumAddress.setSummary(forumAddress); mForumAddress.setText(forumAddress); mForumAddress.setOnPreferenceChangeListener(this); }
private void updatePrefSummary(Preference pref) { if (pref instanceof ListPreference) { final ListPreference list = (ListPreference) pref; pref.setSummary(list.getEntry()); } else if (pref instanceof EditTextPreference) { final EditTextPreference edit = (EditTextPreference) pref; if (!pref.getKey().equalsIgnoreCase("editKey")) pref.setSummary(edit.getText()); } }
@Override public void onPause() { super.onPause(); EditTextPreference preference = (EditTextPreference) findPreference(PreferencesHelper.PREF_WM_HOST_KEY); mPreferenceHelper.setWmHost(preference.getText()); EditTextPreference preference2 = (EditTextPreference) findPreference(PreferencesHelper.PREF_WM_PASSWORD_KEY); mPreferenceHelper.setWmPassword(preference2.getText()); EditTextPreference preference3 = (EditTextPreference) findPreference(PreferencesHelper.PREF_WM_PORT_KEY); mPreferenceHelper.setWmPort(preference3.getText()); //todo rename these to something useful, ugh //todo error checking on url input //todo return an error if host or url is null EditTextPreference preference4 = (EditTextPreference) findPreference(PreferencesHelper.PREF_WM_USER_KEY); mPreferenceHelper.setWmUser(preference4.getText()); ListPreference preference5 = (ListPreference) findPreference(PreferencesHelper.PREF_DEFAULT_DOWNLOAD_KEY); mPreferenceHelper.setDownloadMethod(preference5.getValue()); CheckBoxPreference preference6 = (CheckBoxPreference) findPreference(PreferencesHelper.PREF_LOAD_IMAGES); mPreferenceHelper.setLoadImages(preference6.isChecked()); ListPreference preference7 = (ListPreference) findPreference(PreferencesHelper.PREF_TOP_TORRENT_LIMIT); mPreferenceHelper.setTopTorrentLimit(Integer.parseInt(preference7.getValue())); EditTextPreference preference8 = (EditTextPreference) findPreference(PreferencesHelper.PREF_PYWA_HOST_KEY); mPreferenceHelper.setPywaHost(preference8.getText()); EditTextPreference preference9 = (EditTextPreference) findPreference( PreferencesHelper.PREF_PYWA_PASSWORD_KEY); mPreferenceHelper.setPywaPassword(preference9.getText()); EditTextPreference preference10 = (EditTextPreference) findPreference( PreferencesHelper.PREF_PYWA_PORT_KEY); mPreferenceHelper.setPywaPort(preference10.getText()); }
private String getActionParam1() { EditTextPreference param_name = (EditTextPreference) findPreference("ba_action_param1"); return param_name.getSummary().toString(); }
@Override public void setDetails(AccountConfig config, String[] tlsMethods) { for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) { final Preference current = tlsCategory.getPreference(i); final ConfigKey key = ConfigKey.fromString(current.getKey()); if (current instanceof TwoStatePreference) { ((TwoStatePreference) current).setChecked(config.getBool(key)); } else { if (key == ConfigKey.TLS_CA_LIST_FILE) { File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE)); current.setSummary(crt.getName()); setFeedbackIcon(current); current.setOnPreferenceClickListener(filePickerListener); } else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) { current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName()); current.setOnPreferenceClickListener(filePickerListener); } else if (key == ConfigKey.TLS_CERTIFICATE_FILE) { File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE)); current.setSummary(pem.getName()); setFeedbackIcon(current); checkForRSAKey(); current.setOnPreferenceClickListener(filePickerListener); } else if (key == ConfigKey.TLS_METHOD) { ListPreference listPref = (ListPreference) current; String curVal = config.get(key); listPref.setEntries(tlsMethods); listPref.setEntryValues(tlsMethods); listPref.setValue(curVal); current.setSummary(curVal); } else if (current instanceof EditTextPreference) { String val = config.get(key); ((EditTextPreference) current).setText(val); current.setSummary(val); } else { current.setSummary(config.get(key)); } } current.setOnPreferenceChangeListener(tlsListener); } }
public void SetupPreferences() { ListPreference pUM = (ListPreference) findPreference("prefUM"); ListPreference pUMSpeed = (ListPreference) findPreference("prefUMSpeed"); ListPreference pGPSDistance = (ListPreference) findPreference("prefGPSdistance"); ListPreference pGPSUpdateFrequency = (ListPreference) findPreference("prefGPSupdatefrequency"); ListPreference pKMLAltitudeMode = (ListPreference) findPreference("prefKMLAltitudeMode"); ListPreference pShowTrackStatsType = (ListPreference) findPreference("prefShowTrackStatsType"); ListPreference pShowDirections = (ListPreference) findPreference("prefShowDirections"); EditTextPreference pAltitudeCorrection = (EditTextPreference) findPreference("prefAltitudeCorrectionRaw"); altcorm = Double.valueOf(prefs.getString("prefAltitudeCorrection", "0")); altcor = prefs.getString("prefUM", "0").equals("0") ? altcorm : altcorm * M_TO_FT; if (prefs.getString("prefUM", "0").equals("0")) { // Metric pUMSpeed.setEntries(R.array.UMSpeed_Metric); pGPSDistance.setEntries(R.array.GPSDistance_Metric); pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " m" : getString(R.string.pref_AltitudeCorrection_summary_not_defined)); } if (prefs.getString("prefUM", "0").equals("8")) { // Imperial pUMSpeed.setEntries(R.array.UMSpeed_Imperial); pGPSDistance.setEntries(R.array.GPSDistance_Imperial); pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " ft" : getString(R.string.pref_AltitudeCorrection_summary_not_defined)); } if (prefs.getString("prefUM", "0").equals("16")) { // Aerial / Nautical pUMSpeed.setEntries(R.array.UMSpeed_AerialNautical); pGPSDistance.setEntries(R.array.GPSDistance_Imperial); pAltitudeCorrection.setSummary(altcor != 0 ? getString(R.string.pref_AltitudeCorrection_summary_offset) + " = " + Double.valueOf(Math.round(altcor*1000d)/1000d).toString() + " ft" : getString(R.string.pref_AltitudeCorrection_summary_not_defined)); } Log.w("myApp", "[#] FragmentSettings.java - prefAltitudeCorrectionRaw = " + prefs.getString("prefAltitudeCorrectionRaw", "0")) ; Log.w("myApp", "[#] FragmentSettings.java - prefAltitudeCorrection = " + prefs.getString("prefAltitudeCorrection", "0")) ; // Set all summaries pUMSpeed.setSummary(pUMSpeed.getEntry()); pUM.setSummary(pUM.getEntry()); pGPSDistance.setSummary(pGPSDistance.getEntry()); pGPSUpdateFrequency.setSummary(pGPSUpdateFrequency.getEntry()); pKMLAltitudeMode.setSummary(pKMLAltitudeMode.getEntry()); pShowTrackStatsType.setSummary(pShowTrackStatsType.getEntry()); pShowDirections.setSummary(pShowDirections.getEntry()); }
public boolean onPreferenceClick(Preference preference) { ((EditTextPreference)preference).setText(""); return true; }
@Override protected void createPreferences(PreferenceScreen screen) { switch (mAction) { case SettingsConstantsUI.ACTION_PREFS_GENERAL: addPreferencesFromResource(R.xml.preferences_general); final ListPreference theme = (ListPreference) findPreference(SettingsConstantsUI.KEY_PREF_THEME); initializeTheme(getActivity(), theme); final Preference reset = findPreference(SettingsConstantsUI.KEY_PREF_RESET_SETTINGS); initializeReset(getActivity(), reset); break; case SettingsConstantsUI.ACTION_PREFS_MAP: addPreferencesFromResource(R.xml.preferences_map); final ListPreference showInfoPanel = (ListPreference) findPreference( SettingsConstantsUI.KEY_PREF_SHOW_STATUS_PANEL); initializeShowStatusPanel(showInfoPanel); final ListPreference lpCoordinateFormat = (ListPreference) findPreference(SettingsConstantsUI.KEY_PREF_COORD_FORMAT); final IntEditTextPreference etCoordinateFraction = (IntEditTextPreference) findPreference( SettingsConstantsUI.KEY_PREF_COORD_FRACTION); initializeCoordinates(lpCoordinateFormat, etCoordinateFraction); final SelectMapPathPreference mapPath = (SelectMapPathPreference) findPreference( SettingsConstants.KEY_PREF_MAP_PATH); mapPath.setOnAttachedListener(this); initializeMapPath(getActivity(), mapPath); final ListPreference showCurrentLocation = (ListPreference) findPreference( SettingsConstantsUI.KEY_PREF_SHOW_CURRENT_LOC); initializeShowCurrentLocation(showCurrentLocation); final ListPreference changeMapBG = (ListPreference) findPreference(SettingsConstantsUI.KEY_PREF_MAP_BG); initializeMapBG(changeMapBG); break; case SettingsConstantsUI.ACTION_PREFS_LOCATION: addPreferencesFromResource(R.xml.preferences_location); final ListPreference lpLocationAccuracy = (ListPreference) findPreference(SettingsConstants.KEY_PREF_LOCATION_SOURCE); initializeLocationAccuracy(lpLocationAccuracy, false); final ListPreference minTimeLoc = (ListPreference) findPreference( SettingsConstants.KEY_PREF_LOCATION_MIN_TIME); final ListPreference minDistanceLoc = (ListPreference) findPreference( SettingsConstants.KEY_PREF_LOCATION_MIN_DISTANCE); initializeLocationMins(minTimeLoc, minDistanceLoc, false); final EditTextPreference accurateMaxCount = (EditTextPreference) findPreference( SettingsConstants.KEY_PREF_LOCATION_ACCURATE_COUNT); initializeAccurateTaking(accurateMaxCount); break; case SettingsConstantsUI.ACTION_PREFS_TRACKING: addPreferencesFromResource(R.xml.preferences_tracks); final ListPreference lpTracksAccuracy = (ListPreference) findPreference(SettingsConstants.KEY_PREF_TRACKS_SOURCE); initializeLocationAccuracy(lpTracksAccuracy, true); final ListPreference minTime = (ListPreference) findPreference(SettingsConstants.KEY_PREF_TRACKS_MIN_TIME); final ListPreference minDistance = (ListPreference) findPreference( SettingsConstants.KEY_PREF_TRACKS_MIN_DISTANCE); initializeLocationMins(minTime, minDistance, true); break; } }