use of android.preference.EditTextPreference in project Ushahidi_Android by ushahidi.
the class Settings method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
firstNamePref = new EditTextPreference(this);
lastNamePref = new EditTextPreference(this);
emailAddressPref = new EditTextPreference(this);
phoneNumberPref = new EditTextPreference(this);
photoSizePref = (SeekBarPreference) getPreferenceScreen().findPreference(PHOTO_SIZE_PREFERENCE);
photoSizePref.setMax(Util.getScreenWidth(this));
recentReports = getString(R.string.recent_reports);
totalReportsPref = new ListPreference(this);
mapTileProviderPref = new ListPreference(this);
new ListPreference(this);
setPreferenceScreen(createPreferenceHierarchy());
this.saveSettings();
}
use of android.preference.EditTextPreference in project diary by billthefarmer.
the class SettingsFragment method onCreate.
// On create
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
// Get folder summary
EditTextPreference folder = (EditTextPreference) findPreference(Settings.PREF_FOLDER);
// Set folder in text view
folder.setSummary(preferences.getString(Settings.PREF_FOLDER, Diary.DIARY));
// Get index preference
DatePickerPreference entry = (DatePickerPreference) findPreference(Settings.PREF_INDEX_PAGE);
// Get value
long value = preferences.getLong(Settings.PREF_INDEX_PAGE, DatePickerPreference.DEFAULT_VALUE);
Date date = new Date(value);
// Set summary
DateFormat format = DateFormat.getDateInstance();
String s = format.format(date);
entry.setSummary(s);
// Get template preference
entry = (DatePickerPreference) findPreference(Settings.PREF_TEMPLATE_PAGE);
// Get value
value = preferences.getLong(Settings.PREF_TEMPLATE_PAGE, DatePickerPreference.DEFAULT_VALUE);
date = new Date(value);
// Set summary
s = format.format(date);
entry.setSummary(s);
// Get about summary
Preference about = findPreference(Settings.PREF_ABOUT);
String sum = about.getSummary().toString();
// Set version in text view
s = String.format(sum, BuildConfig.VERSION_NAME);
about.setSummary(s);
}
use of android.preference.EditTextPreference in project robolectric by robolectric.
the class ShadowEditTextPreferenceTest method setup.
@Before
public void setup() {
context = ApplicationProvider.getApplicationContext();
preference = new EditTextPreference(context);
}
use of android.preference.EditTextPreference in project robolectric by robolectric.
the class ShadowEditTextPreferenceTest method testConstructor.
@Test
public void testConstructor() {
preference = new EditTextPreference(context);
assertNotNull(preference.getEditText());
}
use of android.preference.EditTextPreference in project android by cSploit.
the class MsfPreferences method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
// Root
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
String title = null;
PreferenceCategory cat_required = new PreferenceCategory(this);
PreferenceCategory cat_general = new PreferenceCategory(this);
PreferenceCategory cat_advanced = new PreferenceCategory(this);
PreferenceCategory cat_evasion = new PreferenceCategory(this);
ArrayList<Preference> required = new ArrayList<Preference>();
ArrayList<Preference> general = new ArrayList<Preference>();
ArrayList<Preference> advanced = new ArrayList<Preference>();
ArrayList<Preference> evasion = new ArrayList<Preference>();
Payload payload = System.getCurrentPayload();
MsfExploit exploit = (MsfExploit) System.getCurrentExploit();
System.setCurrentPayload(null);
System.setCurrentExploit(null);
if (payload != null) {
options = payload.getOptions();
title = payload.toString();
} else if (exploit != null) {
options = exploit.getOptions();
title = exploit.toString();
}
if (options == null) {
options = new ArrayList<Option>();
title = getString(R.string.error);
String error_message;
if (exploit != null)
error_message = String.format("cannot retrieve options for '%s'", exploit.getName());
else if (payload != null)
error_message = String.format("cannot retrieve options for '%s'", payload.getName());
else
error_message = "called without Payload or MsfExploit";
Logger.error(error_message);
}
setTitle(title + " > " + getString(R.string.menu_settings));
cat_required.setTitle(R.string.required);
cat_general.setTitle(R.string.pref_general);
cat_advanced.setTitle(R.string.pref_advanced);
cat_evasion.setTitle(R.string.evasion);
for (Option opt : options) {
Preference item = null;
int inputType = 0;
switch(opt.getType()) {
case ADDRESS:
case STRING:
case PATH:
case INTEGER:
case PORT:
item = new EditTextPreference(this);
item.setTitle(opt.getName());
((EditTextPreference) item).setDialogTitle(opt.getName());
((EditTextPreference) item).setDialogMessage(opt.getDescription());
item.setSummary(opt.getDescription());
item.setKey(opt.getName());
item.setDefaultValue(opt.getValue());
break;
case BOOLEAN:
item = new CheckBoxPreference(this);
item.setTitle(opt.getName());
item.setKey(opt.getName());
item.setSummary(opt.getDescription());
((CheckBoxPreference) item).setChecked(opt.getValue().equals("true"));
break;
case ENUM:
item = new ListPreference(this);
((ListPreference) item).setEntries(opt.getEnum());
((ListPreference) item).setEntryValues(opt.getEnum());
((ListPreference) item).setDialogTitle(opt.getName());
((ListPreference) item).setValue(opt.getValue());
item.setKey(opt.getName());
item.setTitle(opt.getName());
item.setSummary(opt.getDescription());
break;
}
switch(opt.getType()) {
case ADDRESS:
inputType = InputType.TYPE_CLASS_PHONE;
break;
case PATH:
case STRING:
inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
break;
case PORT:
case INTEGER:
inputType = InputType.TYPE_CLASS_NUMBER;
break;
}
if (inputType != 0)
((EditTextPreference) item).getEditText().setInputType(inputType);
if (opt.isAdvanced())
advanced.add(item);
else if (opt.isRequired())
required.add(item);
else if (opt.isEvasion())
evasion.add(item);
else
general.add(item);
item.setOnPreferenceChangeListener(listener);
}
if (required.size() > 0) {
root.addPreference(cat_required);
for (Preference i : required) cat_required.addPreference(i);
}
if (general.size() > 0) {
root.addPreference(cat_general);
for (Preference i : general) cat_general.addPreference(i);
}
if (advanced.size() > 0) {
root.addPreference(cat_advanced);
for (Preference i : advanced) cat_advanced.addPreference(i);
}
if (evasion.size() > 0) {
root.addPreference(cat_evasion);
for (Preference i : evasion) cat_evasion.addPreference(i);
}
return root;
}
Aggregations