use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.
the class PropertyManager method reload.
public PropertyManager reload() {
try {
putProperty(PROPMGR_DEVICE_ID, "", deviceDetailsProvider.getDeviceId());
putProperty(PROPMGR_PHONE_NUMBER, SCHEME_TEL, deviceDetailsProvider.getLine1Number());
} catch (SecurityException e) {
Timber.i(e);
}
// User-defined properties. Will replace any above with the same PROPMGR_ name.
Settings generalSettings = settingsProvider.getUnprotectedSettings();
initUserDefined(generalSettings, KEY_METADATA_USERNAME, PROPMGR_USERNAME, SCHEME_USERNAME);
initUserDefined(generalSettings, KEY_METADATA_PHONENUMBER, PROPMGR_PHONE_NUMBER, SCHEME_TEL);
initUserDefined(generalSettings, KEY_METADATA_EMAIL, PROPMGR_EMAIL, SCHEME_MAILTO);
// Use the server username by default if the metadata username is not defined
if (getSingularProperty(PROPMGR_USERNAME) == null || getSingularProperty(PROPMGR_USERNAME).isEmpty()) {
putProperty(PROPMGR_USERNAME, SCHEME_USERNAME, settingsProvider.getUnprotectedSettings().getString(KEY_USERNAME));
}
return this;
}
use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.
the class AdminPasswordProviderTest method when_adminPassHasNullValue_should_getAdminPasswordReturnNull.
@Test
public void when_adminPassHasNullValue_should_getAdminPasswordReturnNull() {
Settings adminSharedPreferences = mock(Settings.class);
when(adminSharedPreferences.getString(KEY_ADMIN_PW)).thenReturn(null);
AdminPasswordProvider adminPasswordProvider = new AdminPasswordProvider(adminSharedPreferences);
assertThat(adminPasswordProvider.getAdminPassword(), is(nullValue()));
}
use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.
the class AdminPasswordProviderTest method when_adminPassHasNullValue_should_isAdminPasswordSetReturnFalse.
@Test
public void when_adminPassHasNullValue_should_isAdminPasswordSetReturnFalse() {
Settings adminSharedPreferences = mock(Settings.class);
when(adminSharedPreferences.getString(KEY_ADMIN_PW)).thenReturn(null);
AdminPasswordProvider adminPasswordProvider = new AdminPasswordProvider(adminSharedPreferences);
assertThat(adminPasswordProvider.isAdminPasswordSet(), is(false));
}
use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.
the class AdminPasswordProviderTest method when_adminPassHasEmptyValue_should_isAdminPasswordSetReturnFalse.
@Test
public void when_adminPassHasEmptyValue_should_isAdminPasswordSetReturnFalse() {
Settings adminSharedPreferences = mock(Settings.class);
when(adminSharedPreferences.getString(KEY_ADMIN_PW)).thenReturn("");
AdminPasswordProvider adminPasswordProvider = new AdminPasswordProvider(adminSharedPreferences);
assertThat(adminPasswordProvider.isAdminPasswordSet(), is(false));
}
use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.
the class AdminPasswordProviderTest method when_adminPassIsSetProperly_should_getAdminPasswordReturnCorrectValue.
@Test
public void when_adminPassIsSetProperly_should_getAdminPasswordReturnCorrectValue() {
Settings adminSharedPreferences = mock(Settings.class);
when(adminSharedPreferences.getString(KEY_ADMIN_PW)).thenReturn("123");
AdminPasswordProvider adminPasswordProvider = new AdminPasswordProvider(adminSharedPreferences);
assertThat(adminPasswordProvider.getAdminPassword(), is("123"));
}
Aggregations