Search in sources :

Example 66 with EditTextPreference

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

the class SettingsActivityTest method testAlert_RestApi_InvalidShowsDialog.

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

Example 67 with EditTextPreference

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

the class SettingsActivityTest method testValidation_Mongo_Invalid.

@Test
public void testValidation_Mongo_Invalid() {
    EditTextPreference editTextPreference = (EditTextPreference) setUpPreferenceFragment(SettingsActivity.MainPreferenceFragment.class).findPreference(PreferenceKeys.MONGO_URI);
    assertThat(editTextPreference.getOnPreferenceChangeListener().onPreferenceChange(editTextPreference, "invalidMongo"), is(false));
}
Also used : EditTextPreference(android.preference.EditTextPreference) Test(org.junit.Test)

Example 68 with EditTextPreference

use of android.preference.EditTextPreference in project KeepScore by nolanlawson.

the class SettingsActivity method setDynamicSummary.

private void setDynamicSummary(EditTextPreference editTextPreference) {
    // set the summary to be whatever the value is, and change it if
    // necessary
    editTextPreference.setSummary(editTextPreference.getText());
    editTextPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (!IntegerUtil.validInt(newValue.toString()) || Integer.parseInt(newValue.toString()) == 0) {
                ToastHelper.showLong(SettingsActivity.this, R.string.toast_no_zeroes);
                return false;
            }
            preference.setSummary((CharSequence) newValue);
            PreferenceHelper.resetCache();
            return true;
        }
    });
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 69 with EditTextPreference

use of android.preference.EditTextPreference in project apjp by jvansteirteghem.

the class MainUI2 method onSharedPreferenceChanged.

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    EditTextPreference editTextPreference = (EditTextPreference) getPreferenceScreen().findPreference(key);
    editTextPreference.setSummary(sharedPreferences.getString(key, ""));
}
Also used : EditTextPreference(android.preference.EditTextPreference)

Example 70 with EditTextPreference

use of android.preference.EditTextPreference in project scdl by passy.

the class DownloadPreferencesDelegateTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mActivity = Robolectric.buildActivity(Activity.class).create().get();
    TestHelper.overridenInjector(this, new AbstractModule() {

        @Override
        protected void configure() {
            bind(Tracker.class).toInstance(mTracker);
        }
    });
    mPreferenceManager = new FakePreferenceManagerWrapperImpl(mActivity);
    mPreferenceManager.preferences.put(ApplicationPreferences.KEY_STORAGE_CUSTOM_PATH, new EditTextPreference(mActivity));
    mPreferenceManager.preferences.put(ApplicationPreferences.KEY_STORAGE_TYPE, new ListPreference(mActivity));
    mDelegate = mDelegateFactory.create(mPreferenceManager);
}
Also used : Activity(android.app.Activity) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) AbstractModule(com.google.inject.AbstractModule) Before(org.junit.Before)

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