use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.
the class FormMapActivityTest method tappingOnEditableInstance_showsSubmissionSummaryWithAppropriateMessage.
@Test
public void tappingOnEditableInstance_showsSubmissionSummaryWithAppropriateMessage() {
Pair<Instance, MapPoint> editableAndFinalized = new Pair<>(testInstances[1], new MapPoint(10.1, 125.6));
Pair<Instance, MapPoint> unfinalized = new Pair<>(testInstances[2], new MapPoint(10.1, 126.6));
Pair<Instance, MapPoint> failedToSend = new Pair<>(testInstances[4], new MapPoint(10.3, 125.6));
activity.onFeatureClicked(map.getFeatureIdFor(editableAndFinalized.second));
assertSubmissionSummaryContent(editableAndFinalized.first.getDisplayName(), editableAndFinalized.first.getStatus(), new Date(editableAndFinalized.first.getLastStatusChangeDate()), OPEN_EDIT);
activity.onFeatureClicked(map.getFeatureIdFor(unfinalized.second));
assertSubmissionSummaryContent(unfinalized.first.getDisplayName(), unfinalized.first.getStatus(), new Date(unfinalized.first.getLastStatusChangeDate()), OPEN_EDIT);
activity.onFeatureClicked(map.getFeatureIdFor(failedToSend.second));
assertSubmissionSummaryContent(failedToSend.first.getDisplayName(), failedToSend.first.getStatus(), new Date(failedToSend.first.getLastStatusChangeDate()), OPEN_READ_ONLY);
}
use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.
the class FormMapActivityTest method tappingOnFailedSubmission_showsSubmissionSummaryWithAppropriateMessage.
@Test
public void tappingOnFailedSubmission_showsSubmissionSummaryWithAppropriateMessage() {
Pair<Instance, MapPoint> submissionFailedCantEditWhenFinalized = new Pair<>(testInstances[6], new MapPoint(10.4, 125.6));
int featureId = map.getFeatureIdFor(submissionFailedCantEditWhenFinalized.second);
activity.onFeatureClicked(featureId);
assertSubmissionSummaryContent(submissionFailedCantEditWhenFinalized.first.getDisplayName(), submissionFailedCantEditWhenFinalized.first.getStatus(), new Date(submissionFailedCantEditWhenFinalized.first.getLastStatusChangeDate()), NOT_VIEWABLE_TOAST);
}
use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.
the class GeoPointMapActivity method restoreFromInstanceState.
protected void restoreFromInstanceState(Bundle state) {
isDragged = state.getBoolean(IS_DRAGGED_KEY, false);
captureLocation = state.getBoolean(CAPTURE_LOCATION_KEY, false);
foundFirstLocation = state.getBoolean(FOUND_FIRST_LOCATION_KEY, false);
setClear = state.getBoolean(SET_CLEAR_KEY, false);
pointFromIntent = state.getBoolean(POINT_FROM_INTENT_KEY, false);
intentReadOnly = state.getBoolean(INTENT_READ_ONLY_KEY, false);
intentDraggable = state.getBoolean(INTENT_DRAGGABLE_KEY, false);
isPointLocked = state.getBoolean(IS_POINT_LOCKED_KEY, false);
// Restore the marker and dialog after the flags, because they use some of them.
MapPoint point = state.getParcelable(POINT_KEY);
if (point != null) {
placeMarker(point);
} else {
clear();
}
// Restore the flags again, because placeMarker() and clear() modify some of them.
isDragged = state.getBoolean(IS_DRAGGED_KEY, false);
captureLocation = state.getBoolean(CAPTURE_LOCATION_KEY, false);
foundFirstLocation = state.getBoolean(FOUND_FIRST_LOCATION_KEY, false);
setClear = state.getBoolean(SET_CLEAR_KEY, false);
pointFromIntent = state.getBoolean(POINT_FROM_INTENT_KEY, false);
intentReadOnly = state.getBoolean(INTENT_READ_ONLY_KEY, false);
intentDraggable = state.getBoolean(INTENT_DRAGGABLE_KEY, false);
isPointLocked = state.getBoolean(IS_POINT_LOCKED_KEY, false);
// Restore the rest of the UI state.
MapPoint mapCenter = state.getParcelable(MAP_CENTER_KEY);
Double mapZoom = state.getDouble(MAP_ZOOM_KEY);
if (mapCenter != null) {
map.zoomToPoint(mapCenter, mapZoom, false);
}
placeMarkerButton.setEnabled(state.getBoolean(PLACE_MARKER_BUTTON_ENABLED_KEY, false));
zoomButton.setEnabled(state.getBoolean(ZOOM_BUTTON_ENABLED_KEY, false));
clearButton.setEnabled(state.getBoolean(CLEAR_BUTTON_ENABLED_KEY, false));
locationInfo.setVisibility(state.getInt(LOCATION_INFO_VISIBILITY_KEY, View.GONE));
locationStatus.setVisibility(state.getInt(LOCATION_STATUS_VISIBILITY_KEY, View.GONE));
}
use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.
the class GeoPointMapActivity method onLocationChanged.
public void onLocationChanged(MapPoint point) {
if (setClear) {
placeMarkerButton.setEnabled(true);
}
MapPoint previousLocation = this.location;
this.location = point;
if (point != null) {
if (previousLocation != null) {
enableZoomButton(true);
if (!captureLocation && !setClear) {
placeMarker(point);
placeMarkerButton.setEnabled(true);
}
if (!foundFirstLocation) {
map.zoomToPoint(map.getGpsLocation(), true);
foundFirstLocation = true;
}
locationStatus.setText(formatLocationStatus(map.getLocationProvider(), point.sd));
}
}
}
use of org.odk.collect.geo.maps.MapPoint in project collect by opendatakit.
the class GeoPointMapActivityTest method shouldReturnPointFromSecondLocationFix.
@Test
public void shouldReturnPointFromSecondLocationFix() {
ActivityScenario<GeoPointMapActivity> scenario = launcherRule.launch(GeoPointMapActivity.class);
// The very first fix is ignored.
mapFragment.setLocationProvider("GPS");
mapFragment.setLocation(new MapPoint(1, 2, 3, 4f));
scenario.onActivity(activity -> {
assertEquals(activity.getString(R.string.please_wait_long), activity.getLocationStatus());
});
// The second fix changes the status message.
mapFragment.setLocation(new MapPoint(5, 6, 7, 8f));
scenario.onActivity(activity -> {
assertEquals(activity.formatLocationStatus("gps", 8f), activity.getLocationStatus());
});
// When the user clicks the "Save" button, the fix location should be returned.
scenario.onActivity(activity -> {
activity.findViewById(R.id.accept_location).performClick();
});
assertThat(scenario.getResult().getResultCode(), is(RESULT_OK));
scenario.onActivity(activity -> {
Intent resultData = scenario.getResult().getResultData();
assertThat(ExternalAppUtils.getReturnedSingleValue(resultData), is(activity.formatResult(new MapPoint(5, 6, 7, 8))));
});
}
Aggregations