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")));
}
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));
}
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;
}
});
}
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, ""));
}
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);
}
Aggregations