Search in sources :

Example 6 with Settings

use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.

the class AdminPasswordProviderTest method when_adminPassHasEmptyValue_should_getAdminPasswordReturnEmptyString.

@Test
public void when_adminPassHasEmptyValue_should_getAdminPasswordReturnEmptyString() {
    Settings adminSharedPreferences = mock(Settings.class);
    when(adminSharedPreferences.getString(KEY_ADMIN_PW)).thenReturn("");
    AdminPasswordProvider adminPasswordProvider = new AdminPasswordProvider(adminSharedPreferences);
    assertThat(adminPasswordProvider.getAdminPassword(), is(""));
}
Also used : Settings(org.odk.collect.shared.settings.Settings) Test(org.junit.Test)

Example 7 with Settings

use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.

the class Collect method fixGoogleBug154855417.

// https://issuetracker.google.com/issues/154855417
private void fixGoogleBug154855417() {
    try {
        Settings metaSharedPreferences = settingsProvider.getMetaSettings();
        boolean hasFixedGoogleBug154855417 = metaSharedPreferences.getBoolean(KEY_GOOGLE_BUG_154855417_FIXED);
        if (!hasFixedGoogleBug154855417) {
            File corruptedZoomTables = new File(getFilesDir(), "ZoomTables.data");
            corruptedZoomTables.delete();
            metaSharedPreferences.save(KEY_GOOGLE_BUG_154855417_FIXED, true);
        }
    } catch (Exception ignored) {
    // ignored
    }
}
Also used : File(java.io.File) Settings(org.odk.collect.shared.settings.Settings)

Example 8 with Settings

use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.

the class BackgroundAudioViewModelTest method setup.

@Before
public void setup() {
    clock = mock(Supplier.class);
    Settings generalSettings = TestSettingsProvider.getUnprotectedSettings();
    generalSettings.clear();
    viewModel = new BackgroundAudioViewModel(audioRecorder, generalSettings, recordAudioActionRegistry, permissionsChecker, clock);
}
Also used : Supplier(java.util.function.Supplier) Settings(org.odk.collect.shared.settings.Settings) Before(org.junit.Before)

Example 9 with Settings

use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.

the class MapBoxInitializationFragment method initMapBox.

private void initMapBox(View rootView) {
    Settings metaSharedPreferences = settingsProvider.getMetaSettings();
    if (!metaSharedPreferences.getBoolean(KEY_MAPBOX_INITIALIZED) && connectivityProvider.isDeviceOnline()) {
        // most likely to be available. This is annoyingly needed for offline tiles to work.
        try {
            mapView = new MapView(getContext());
            FrameLayout mapBoxContainer = rootView.findViewById(R.id.map_box_container);
            mapBoxContainer.addView(mapView);
            mapView.getMapAsync(mapBoxMap -> mapBoxMap.setStyle(Style.MAPBOX_STREETS, style -> {
                metaSharedPreferences.save(KEY_MAPBOX_INITIALIZED, true);
            }));
        } catch (Exception | Error ignored) {
        // This will crash on devices where the arch for MapBox is not included
        }
    }
}
Also used : Bundle(android.os.Bundle) SettingsProvider(org.odk.collect.settings.SettingsProvider) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) MapView(com.mapbox.mapboxsdk.maps.MapView) ViewGroup(android.view.ViewGroup) Inject(javax.inject.Inject) KEY_MAPBOX_INITIALIZED(org.odk.collect.settings.keys.MetaKeys.KEY_MAPBOX_INITIALIZED) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) Nullable(androidx.annotation.Nullable) NetworkStateProvider(org.odk.collect.android.network.NetworkStateProvider) Style(com.mapbox.mapboxsdk.maps.Style) Fragment(androidx.fragment.app.Fragment) R(org.odk.collect.android.R) View(android.view.View) Settings(org.odk.collect.shared.settings.Settings) FrameLayout(android.widget.FrameLayout) MapView(com.mapbox.mapboxsdk.maps.MapView) Settings(org.odk.collect.shared.settings.Settings)

Example 10 with Settings

use of org.odk.collect.shared.settings.Settings in project collect by opendatakit.

the class MapProvider method onMapFragmentStop.

void onMapFragmentStop(MapFragment map) {
    Settings.OnSettingChangeListener listener = listenersByMap.get(map);
    if (listener != null) {
        Settings prefs = PrefUtils.getSharedPrefs();
        prefs.unregisterOnSettingChangeListener(listener);
        listenersByMap.remove(map);
    }
}
Also used : Settings(org.odk.collect.shared.settings.Settings)

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