Search in sources :

Example 1 with Settings

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;
}
Also used : Settings(org.odk.collect.shared.settings.Settings)

Example 2 with Settings

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()));
}
Also used : Settings(org.odk.collect.shared.settings.Settings) Test(org.junit.Test)

Example 3 with Settings

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));
}
Also used : Settings(org.odk.collect.shared.settings.Settings) Test(org.junit.Test)

Example 4 with Settings

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));
}
Also used : Settings(org.odk.collect.shared.settings.Settings) Test(org.junit.Test)

Example 5 with Settings

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"));
}
Also used : Settings(org.odk.collect.shared.settings.Settings) Test(org.junit.Test)

Aggregations

Settings (org.odk.collect.shared.settings.Settings)19 Test (org.junit.Test)8 Context (android.content.Context)3 Nullable (androidx.annotation.Nullable)3 R (org.odk.collect.android.R)3 Bundle (android.os.Bundle)2 View (android.view.View)2 NonNull (androidx.annotation.NonNull)2 Style (com.mapbox.mapboxsdk.maps.Style)2 Inject (javax.inject.Inject)2 DaggerUtils (org.odk.collect.android.injection.DaggerUtils)2 SettingsProvider (org.odk.collect.settings.SettingsProvider)2 Dialog (android.app.Dialog)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 DialogFragment (androidx.fragment.app.DialogFragment)1 Fragment (androidx.fragment.app.Fragment)1 CheckBoxPreference (androidx.preference.CheckBoxPreference)1 ListPreference (androidx.preference.ListPreference)1