use of android.preference.EditTextPreference in project Osmand by osmandapp.
the class SettingsBaseActivity method createEditTextPreference.
public EditTextPreference createEditTextPreference(OsmandPreference<String> b, int title, int summary) {
EditTextPreference p = new EditTextPreference(this);
p.setTitle(title);
p.setKey(b.getId());
p.setDialogTitle(title);
p.setSummary(summary);
p.setOnPreferenceChangeListener(this);
screenPreferences.put(b.getId(), p);
editTextPreferences.put(b.getId(), b);
return p;
}
use of android.preference.EditTextPreference in project Zom-Android by zom.
the class SettingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
pm = getPackageManager();
mOtrMode = (ListPreference) findPreference("pref_security_otr_mode");
mOtrMode.setEntries(Preferences.getOtrModeNames());
mOtrMode.setEntryValues(Preferences.getOtrModeValues());
mOtrMode.setDefaultValue(Preferences.DEFAULT_OTR_MODE);
mAllowScreenshot = (CheckBoxPreference) findPreference("prefBlockScreenshots");
mPanicTriggerApp = (ListPreference) findPreference("pref_panic_trigger_app");
mPanicConfig = (Preference) findPreference("pref_panic_config");
mLanguage = (ListPreference) findPreference("pref_language");
// mLinkifyOnTor = (CheckBoxPreference) findPreference("pref_linkify_on_tor");
mHideOfflineContacts = (CheckBoxPreference) findPreference("pref_hide_offline_contacts");
mDeleteUnsecuredMedia = (CheckBoxPreference) findPreference("pref_delete_unsecured_media");
mEnableNotification = (CheckBoxPreference) findPreference("pref_enable_notification");
mNotificationVibrate = (CheckBoxPreference) findPreference("pref_notification_vibrate");
mNotificationSound = (CheckBoxPreference) findPreference("pref_notification_sound");
mNotificationRingtone = findPreference("pref_notification_ringtone");
Languages languages = Languages.get(this);
currentLanguage = getResources().getConfiguration().locale.getLanguage();
mLanguage.setDefaultValue(currentLanguage);
mLanguage.setEntries(languages.getAllNames());
mLanguage.setEntryValues(languages.getSupportedLocales());
mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String language = (String) newValue;
ImApp.resetLanguage(SettingActivity.this, language);
setResult(RESULT_OK);
return true;
}
});
mAllowScreenshot.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
setResult(RESULT_OK);
return true;
}
});
mPanicTriggerApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String packageName = (String) newValue;
PanicResponder.setTriggerPackageName(SettingActivity.this, packageName);
PanicResponder.configTriggerAppListPreference(mPanicTriggerApp, R.string.panic_trigger_app_summary, R.string.panic_app_none_summary);
return true;
}
});
mPanicConfig.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(SettingActivity.this, PanicSetupActivity.class);
startActivity(intent);
return true;
}
});
findPreference("pref_color_reset").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
SharedPreferences.Editor pEdit = settings.edit();
pEdit.remove("themeColorBg");
pEdit.remove("themeColorText");
pEdit.remove("themeColor");
pEdit.commit();
setResult(RESULT_OK);
finish();
return true;
}
});
mNotificationRingtone.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.notification_ringtone_title));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Preferences.getNotificationRingtoneUri());
startActivityForResult(intent, CHOOSE_RINGTONE);
return true;
}
});
mForegroundService = (CheckBoxPreference) findPreference("pref_foreground_enable");
mForegroundService.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
((ImApp) getApplication()).forceStopImService();
return true;
}
});
mHeartbeatInterval = (EditTextPreference) findPreference("pref_heartbeat_interval");
findPreference("prefAdvancedNetworking").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
RemoteImService.installTransports(getApplicationContext());
return true;
}
});
}
use of android.preference.EditTextPreference in project android-garage-opener by bradfitz.
the class SettingsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(Preferences.NAME);
addPreferencesFromResource(R.xml.preferences);
ssidPref = (EditTextPreference) findPreference(Preferences.KEY_SSID);
urlPref = (EditTextPreference) findPreference(Preferences.KEY_URL);
secretPref = (EditTextPreference) findPreference(Preferences.KEY_SECRET);
OnPreferenceChangeListener onChange = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String key = preference.getKey();
Log.v(TAG, "preference change for: " + key);
// yes, persist it.
return true;
}
};
// ssidPref.setOnPreferenceChangeListener(onChange);
// urlPref.setOnPreferenceChangeListener(onChange);
// secretPref.setOnPreferenceChangeListener(onChange);
}
use of android.preference.EditTextPreference in project YalpStore by yeriomin.
the class DownloadDirectory method draw.
@Override
public void draw() {
preference.setSummary(Paths.getYalpPath(activity).getAbsolutePath());
preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
YalpStorePermissionManager permissionManager = new YalpStorePermissionManager(activity);
if (!permissionManager.checkPermission()) {
permissionManager.requestPermission();
}
return true;
}
});
preference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
String newValue = (String) o;
boolean result = checkNewValue(newValue);
if (!result) {
if (ContextUtil.isAlive(activity) && !((EditTextPreference) preference).getText().equals(Paths.FALLBACK_DIRECTORY)) {
getFallbackDialog().show();
} else {
ContextUtil.toast(activity, R.string.error_downloads_directory_not_writable);
}
} else {
try {
preference.setSummary(new File(Paths.getStorageRoot(activity), newValue).getCanonicalPath());
} catch (IOException e) {
Log.i(getClass().getName(), "checkNewValue returned true, but drawing the path \"" + newValue + "\" in the summary failed... strange");
return false;
}
}
return result;
}
private boolean checkNewValue(String newValue) {
try {
File storageRoot = Paths.getStorageRoot(activity);
File newDir = new File(storageRoot, newValue).getCanonicalFile();
if (!newDir.getCanonicalPath().startsWith(storageRoot.getCanonicalPath())) {
return false;
}
if (newDir.exists()) {
return newDir.canWrite();
}
if (activity.checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
return newDir.mkdirs();
}
return true;
} catch (IOException e) {
return false;
}
}
private DialogWrapperAbstract getFallbackDialog() {
return new DialogWrapper(activity).setMessage(activity.getString(R.string.error_downloads_directory_not_writable) + "\n\n" + activity.getString(R.string.pref_message_fallback, Paths.FALLBACK_DIRECTORY)).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
preference.setText(Paths.FALLBACK_DIRECTORY);
preference.getOnPreferenceChangeListener().onPreferenceChange(preference, Paths.FALLBACK_DIRECTORY);
dialog.dismiss();
}
}).create();
}
});
}
use of android.preference.EditTextPreference in project NightSkyGuide by MTBehnke.
the class SettingsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
setHasOptionsMenu(true);
// load the preferences from the XML resource
addPreferencesFromResource(R.xml.preferences);
// locationParent > Edit Locations:
// Parent to Update Locations
updateLocParent = (PreferenceScreen) findPreference("update_location_ref_screen");
update_loc1 = (PreferenceScreen) findPreference("update_loc1");
update_loc2 = (PreferenceScreen) findPreference("update_loc2");
update_loc3 = (PreferenceScreen) findPreference("update_loc3");
update_loc4 = (PreferenceScreen) findPreference("update_loc4");
update_loc5 = (PreferenceScreen) findPreference("update_loc5");
// Update Locations > Location 1-5
locationEditText1 = (EditTextPreference) findPreference("pref_location1");
latEditText1 = (EditTextPreference) findPreference("pref_lat1");
longEditText1 = (EditTextPreference) findPreference("pref_long1");
locationEditText2 = (EditTextPreference) findPreference("pref_location2");
latEditText2 = (EditTextPreference) findPreference("pref_lat2");
longEditText2 = (EditTextPreference) findPreference("pref_long2");
locationEditText3 = (EditTextPreference) findPreference("pref_location3");
latEditText3 = (EditTextPreference) findPreference("pref_lat3");
longEditText3 = (EditTextPreference) findPreference("pref_long3");
locationEditText4 = (EditTextPreference) findPreference("pref_location4");
latEditText4 = (EditTextPreference) findPreference("pref_lat4");
longEditText4 = (EditTextPreference) findPreference("pref_long4");
locationEditText5 = (EditTextPreference) findPreference("pref_location5");
latEditText5 = (EditTextPreference) findPreference("pref_lat5");
longEditText5 = (EditTextPreference) findPreference("pref_long5");
// Viewing Location:
useDeviceLocation = (SwitchPreference) findPreference("use_device_location");
viewingLocation = (ListPreference) findPreference("viewing_location");
// nightMode = (SwitchPreference) findPreference("night_mode");
// Display Options:
// Pref: display previously observed
displayPrevObserved = (SwitchPreference) findPreference("pref_show_observed");
// Pref: display objects below horizon
displayBelowHoriz = (SwitchPreference) findPreference("pref_show_below_horiz");
// Pref: filter out objects of magnitude above <max>
maxMagnitude = (ListPreference) findPreference("pref_max_magnitude");
// Pref: sort list of objects by <list>
sortByPref = (ListPreference) findPreference("pref_sort_by");
// Pref: select object lists to display
displayObjectList = (MultiSelectListPreference) findPreference("multi_pref_object_list");
displayObjectList.setSummary(updateObjectList(displayObjectList.getValues().toString()));
// Pref: select atlas lists to display
displayAtlasList = (MultiSelectListPreference) findPreference("multi_pref_atlas_list");
displayAtlasList.setSummary(updateAtlasList(displayAtlasList.getValues().toString()));
// displayConstList = (MultiSelectListPreference) findPreference("multi_pref_const_month");
// Log.i("Start: ", displayConstList.getValues().toString());
updateLocSummaries();
// setObjectListSummary();
// start location services, including permissions checks, etc.
context = getActivity();
preferences = PreferenceManager.getDefaultSharedPreferences(context);
// set GPS/Network SwitchPreferences
useDeviceLocation.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object useDeviceLoc) {
// Use GPS/Network Location changed to on/off (before preference saved)
Boolean turnGPSOn = (Boolean) useDeviceLoc;
if (turnGPSOn) {
// if user is trying to turn GPS on
((SettingsActivity) getActivity()).useGPS = true;
// if checkPermissions opens dialog box then onChange completes, then onPause due to dialog box. After dialog closed then onResume called.
((SettingsActivity) getActivity()).checkPermissions();
} else {
((SettingsActivity) getActivity()).useGPS = false;
((SettingsActivity) getActivity()).stopLocationUpdates();
}
setLocSummary();
return true;
}
});
viewingLocation.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
updateLocationList();
return true;
}
});
/* Night mode work in progress
nightMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Boolean newNightMode = (Boolean) newValue;
if (newNightMode) { // user turning night mode on
view.setBackgroundColor(getResources().getColor(R.color.nightBackground));
ViewGroup viewGroup = (ViewGroup)view;
redText(viewGroup);
}
else {view.setBackgroundColor(getResources().getColor(R.color.dayBackground));
}
return true;}
}); */
// sets Location 1 - 5 onChangePreferenceListeners
setLocationPrefListeners();
// set Display Options SwitchPreferences
displayPrevObserved.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
return true;
}
});
displayBelowHoriz.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
return true;
}
});
maxMagnitude.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
return true;
}
});
sortByPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
return true;
}
});
displayObjectList.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String selected = newValue.toString();
String objectList = updateObjectList(selected);
if (objectList.equals("None")) {
Toast.makeText(getActivity(), "Must select at least one Object List", Toast.LENGTH_SHORT).show();
return false;
}
displayObjectList.setSummary(objectList);
return true;
}
});
displayAtlasList.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String selected = newValue.toString();
String atlasList = updateAtlasList(selected);
displayAtlasList.setSummary(atlasList);
return true;
}
});
return view;
}
Aggregations