Skip to content

Commit a4d7ee2

Browse files
authored
Merge pull request #6904 from grzesiek2010/COLLECT-6882
Merge changes from v2025.1.4
2 parents ada3a13 + 0e174ab commit a4d7ee2

File tree

6 files changed

+25
-115
lines changed

6 files changed

+25
-115
lines changed

geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package org.odk.collect.geo.geopoly;
1616

1717
import static org.odk.collect.geo.Constants.EXTRA_READ_ONLY;
18+
import static org.odk.collect.geo.Constants.EXTRA_RETAIN_MOCK_ACCURACY;
1819
import static org.odk.collect.geo.GeoActivityUtils.requireLocationPermissions;
1920

2021
import android.content.Intent;
@@ -303,6 +304,7 @@ public void initMap(MapFragment newMapFragment) {
303304
map.setLongPressListener(this::onClick);
304305
map.setGpsLocationEnabled(true);
305306
map.setGpsLocationListener(this::onGpsLocation);
307+
map.setRetainMockAccuracy(intent.getBooleanExtra(EXTRA_RETAIN_MOCK_ACCURACY, false));
306308

307309
if (!map.hasCenter()) {
308310
if (!points.isEmpty()) {

geo/src/test/java/org/odk/collect/geo/geopoint/GeoPointMapActivityTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void mapFragmentRetainMockAccuracy_isFalse() {
157157
}
158158

159159
@Test
160-
public void passingRetainMockAccuracyExtra_showSetItOnLocationClient() {
160+
public void passingRetainMockAccuracyExtra_updatesMapFragmentState() {
161161
Intent intent = new Intent(ApplicationProvider.getApplicationContext(), GeoPointMapActivity.class);
162162
intent.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, true);
163163
launcherRule.launch(intent);

geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolyActivityTest.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import org.odk.collect.androidtest.ActivityScenarioExtensions.isFinishing
2727
import org.odk.collect.androidtest.ActivityScenarioLauncherRule
2828
import org.odk.collect.async.Scheduler
2929
import org.odk.collect.geo.Constants
30+
import org.odk.collect.geo.Constants.EXTRA_RETAIN_MOCK_ACCURACY
3031
import org.odk.collect.geo.DaggerGeoDependencyComponent
3132
import org.odk.collect.geo.GeoDependencyModule
3233
import org.odk.collect.geo.R
@@ -283,6 +284,25 @@ class GeoPolyActivityTest {
283284
assertThat(mapFragment.isPolyDraggable(0), equalTo(false))
284285
}
285286

287+
@Test
288+
fun passingRetainMockAccuracyExtra_updatesMapFragmentState() {
289+
val intent = Intent(
290+
ApplicationProvider.getApplicationContext(),
291+
GeoPolyActivity::class.java
292+
)
293+
intent.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, true)
294+
launcherRule.launch<Activity>(intent)
295+
mapFragment.ready()
296+
297+
assertThat(mapFragment.isRetainMockAccuracy(), equalTo(true))
298+
299+
intent.putExtra(EXTRA_RETAIN_MOCK_ACCURACY, false)
300+
launcherRule.launch<Activity>(intent)
301+
mapFragment.ready()
302+
303+
assertThat(mapFragment.isRetainMockAccuracy(), equalTo(false))
304+
}
305+
286306
@Test
287307
fun recreatingTheActivityWithTheLayersDialogDisplayedDoesNotCrashTheApp() {
288308
val scenario = launcherRule.launch(GeoPolyActivity::class.java)

mapbox/src/main/java/org/odk/collect/mapbox/MapboxLocationCallback.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.

mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class MapboxMapFragment :
112112
private var referenceLayerFile: File? = null
113113
private var clientWantsLocationUpdates = false
114114
private var topStyleLayerId: String? = null
115-
private val locationCallback = MapboxLocationCallback(this)
115+
116116
private val _mapViewModel by viewModels<MapViewModel> {
117117
viewModelFactory {
118118
addInitializer(MapViewModel::class) {
@@ -448,7 +448,7 @@ class MapboxMapFragment :
448448
}
449449

450450
override fun setRetainMockAccuracy(retainMockAccuracy: Boolean) {
451-
locationCallback.setRetainMockAccuracy(retainMockAccuracy)
451+
locationClient.setRetainMockAccuracy(retainMockAccuracy)
452452
}
453453

454454
override fun onMapClick(point: Point): Boolean {

mapbox/src/test/java/org/odk/collect/mapbox/MapboxLocationCallbackTest.java

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)