Search in sources :

Example 31 with EditTextPreference

use of android.preference.EditTextPreference in project android-uploader by nightscout.

the class SettingsActivityTest method testValidation_RestApi_Valid.

@Test
public void testValidation_RestApi_Valid() {
    EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.API_URIS);
    assertThat(editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "http://example.com"), is(true));
}
Also used : EditTextPreference(android.preference.EditTextPreference) Test(org.junit.Test)

Example 32 with EditTextPreference

use of android.preference.EditTextPreference in project android-uploader by nightscout.

the class SettingsActivityTest method testAlert_Mongo_InvalidShowsDialog.

@Test
public void testAlert_Mongo_InvalidShowsDialog() {
    EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.MONGO_URI);
    editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "invalidMongo");
    ShadowAlertDialog alertDialog = getShadowApplication().getLatestAlertDialog();
    assertThat(alertDialog, is(not(nullValue())));
    assertThat(alertDialog.getMessage().toString(), is(getContext().getString(R.string.illegal_mongo_uri)));
}
Also used : ShadowAlertDialog(org.robolectric.shadows.ShadowAlertDialog) EditTextPreference(android.preference.EditTextPreference) Test(org.junit.Test)

Example 33 with EditTextPreference

use of android.preference.EditTextPreference in project android-uploader by nightscout.

the class SettingsActivityTest method testValidation_RestApi_MultipleValid.

@Test
public void testValidation_RestApi_MultipleValid() {
    EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.API_URIS);
    assertThat(editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "http://example.com validUri.com"), is(true));
}
Also used : EditTextPreference(android.preference.EditTextPreference) Test(org.junit.Test)

Example 34 with EditTextPreference

use of android.preference.EditTextPreference in project Anki-Android by Ramblurr.

the class Preferences method updateEditTextPreference.

private void updateEditTextPreference(String key) {
    EditTextPreference pref = (EditTextPreference) getPreferenceScreen().findPreference(key);
    String entry;
    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);
        }
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference)

Example 35 with EditTextPreference

use of android.preference.EditTextPreference in project Anki-Android by Ramblurr.

the class CramDeckOptions method buildLists.

protected void buildLists() {
    ListPreference newOrderPref = (ListPreference) findPreference("order");
    newOrderPref.setEntries(R.array.cram_deck_conf_order_labels);
    newOrderPref.setEntryValues(R.array.cram_deck_conf_order_values);
    newOrderPref.setValue(mPref.getString("order", "0"));
    if (mPresetSearchSuffix != null) {
        EditTextPreference searchPref = (EditTextPreference) findPreference("search");
        searchPref.setText(mPresetSearchSuffix);
    }
}
Also used : ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference)

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