Search in sources :

Example 71 with EditTextPreference

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();
}
Also used : EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference)

Example 72 with EditTextPreference

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);
}
Also used : SharedPreferences(android.content.SharedPreferences) EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) DateFormat(java.text.DateFormat) EditTextPreference(android.preference.EditTextPreference) Date(java.util.Date)

Example 73 with EditTextPreference

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);
}
Also used : EditTextPreference(android.preference.EditTextPreference) Before(org.junit.Before)

Example 74 with EditTextPreference

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());
}
Also used : EditTextPreference(android.preference.EditTextPreference) Test(org.junit.Test)

Example 75 with EditTextPreference

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;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) CheckBoxPreference(android.preference.CheckBoxPreference) ArrayList(java.util.ArrayList) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) PreferenceCategory(android.preference.PreferenceCategory) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) MsfExploit(org.csploit.android.net.metasploit.MsfExploit) Payload(org.csploit.android.net.metasploit.Payload) Option(org.csploit.android.net.metasploit.Option)

Aggregations

EditTextPreference (android.preference.EditTextPreference)77 ListPreference (android.preference.ListPreference)32 Preference (android.preference.Preference)32 CheckBoxPreference (android.preference.CheckBoxPreference)17 SharedPreferences (android.content.SharedPreferences)11 PreferenceScreen (android.preference.PreferenceScreen)11 Test (org.junit.Test)9 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)8 Intent (android.content.Intent)7 ArrayList (java.util.ArrayList)7 DialogInterface (android.content.DialogInterface)6 Bundle (android.os.Bundle)6 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)5 View (android.view.View)5 SwitchPreference (android.preference.SwitchPreference)4 EditText (android.widget.EditText)4 File (java.io.File)4 Activity (android.app.Activity)3 AlertDialog (android.app.AlertDialog)3