Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Google and OSM GeoPoint activities into one activity using the common MapFragment interface. #2776

Closed

Conversation

zestyping
Copy link
Contributor

@zestyping zestyping commented Jan 10, 2019

Overview

This pull request merges GeoPointMapActivity (which was Google-specific) and GeoPointOsmMapActivity (which is OSM-specific) into a single activity, GeoPointMapActivity, using the common MapFragment interface added in #2465. The MapFragment interface is extended to support point markers, which are used by the activity.

Guidance to reviewers

This PR will probably be easiest to review by going through the commits one by one; most of the commits are straightforward. The biggest change is in c69bf44, which migrates the new activity to use MapFragment instead of GoogleMap. Because MapFragment is a higher-level interface, some of the logic and state in the GeoPointMapActivity got simplified away. If anything in there is confusing, please feel free to reach out to me with any questions—I'm also happy to talk it over with you. Sometimes a short conversation can really help speed up a review.

What has been done to verify that this works as intended?

I've manually tested, in both Google and OSM modes:

  • Zooming to the phone's GPS location
  • Zooming to an existing point
  • Allowing the first GPS fix to determine the point
  • Clearing the point with the "trash" button
  • Placing the point by long-pressing, and confirming that the viewport doesn't move
  • Moving the point by dragging, and confirming that the viewport shifts to center on the new point
  • Placing the point with the "add marker" button, and confirming that the viewport zooms to the point
  • Saving the point
  • Launching with a saved point and confirming that the point cannot be dragged
  • Confirming that dragging and long-pressing is allowed only in "placement-map" mode, not in "map" mode

Why is this the best possible solution? Were any other approaches considered?

There is currently a great deal of code duplicated between GeoPointMapActivity and GeoPointOsmMapActivity, including some vestigial code, member fields that are trivial or unused, and duplicated layouts. This solution eliminates most of that duplication.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

The only user-visible behaviour changes should be:

  • Tapping on the marker in OSM used to pop up an empty text bubble. It doesn't do that anymore.
  • When the activity is launched with a previously saved point, marker dragging and long-press are initially disabled; the user must click the "trash" button to discard the point before adding/long-pressing/dragging a new marker. Previously, the instructions "Long press to place mark to tap add marker button" would be displayed even though the user cannot do these things; now the instructions are not displayed.

Do we need any specific form for testing your changes? If so, please attach one.

Any form that uses the GeoPoint widget with "placement-map" or "map" appearance will do. Here's the one I've been using:
geo-widgets.zip

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from 254d2e9 to 915d30a Compare January 10, 2019 04:43
@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from 915d30a to e2d17f9 Compare January 10, 2019 04:45
@zestyping
Copy link
Contributor Author

Rebased onto master.

@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from a1d0bb7 to c674fe9 Compare January 10, 2019 04:54
@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from c674fe9 to 090bcff Compare January 10, 2019 04:58
@zestyping
Copy link
Contributor Author

@opendatakit-bot label "needs-testing"

@getodk-bot
Copy link
Member

ERROR: Label "needs-testing" does not exist and was thus not added to this pull request.

@zestyping
Copy link
Contributor Author

@opendatakit-bot label "needs testing"

@zestyping
Copy link
Contributor Author

The CircleCI failure looks to me like an intermittent network error:

Could not GET 'https://jcenter.bintray.com/net/sourceforge/saxon/saxon/9.1.0.8/saxon-9.1.0.8.pom'. Received status code 502 from server: Bad Gateway

Is there a way to re-run the checks?

@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from 090bcff to 121257f Compare January 14, 2019 11:20
@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from 121257f to 2ca7710 Compare January 14, 2019 20:10
double sd = 0;
try {
sd = Double.parseDouble(marker.getSubDescription());
} catch (NumberFormatException e) { /* ignore */ }
Copy link
Member

@grzesiek2010 grzesiek2010 Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think logging at least Timber.w would be good here? We usually don't ignore exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay! I also fixed a similar ignored exception in GoogleMapFragment.


@Override public @Nullable MapPoint getMarkerPoint(int featureId) {
MapFeature feature = features.get(featureId);
if (feature instanceof MarkerFeature) {
Copy link
Member

@grzesiek2010 grzesiek2010 Jan 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you like ternary operators? I would prefer it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Sometimes I use them; in this case it didn't occur to me. Fixed.


@Override public @Nullable MapPoint getMarkerPoint(int featureId) {
MapFeature feature = features.get(featureId);
if (feature instanceof MarkerFeature) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same like above, ternary operator would be good here.

@grzesiek2010
Copy link
Member

grzesiek2010 commented Jan 15, 2019

@zestyping

I found only some minor things to improve so I'm going to add needs testing label. Please let me know once you fix them.

EDIT: since #2797 is based on this branch let's test only that pr.

@zestyping
Copy link
Contributor Author

Thanks for the review, @grzesiek2010! I've fixed the things you pointed out.

@zestyping
Copy link
Contributor Author

@kkrawczyk123 @mmarciniak90 Is it helpful to have the old activities still accessible for comparison testing (with the ability to switch between new and old using the volume buttons), or can I remove them so that this PR is in its final state ready for merging?

@zestyping
Copy link
Contributor Author

zestyping commented Jan 16, 2019

@grzesiek2010 Hey, I discovered two bugs—so sorry I missed these before your review!

  1. If there's an existing point, the activity was only using the latitude and longitude and ignoring the other two fields. So simply opening and then re-saving a point would lose information.

  2. The previous activity's behaviour disables long-press when the activity starts with an existing point. The new activity didn't match this behaviour.

I've now fixed these in the recent commits. Could you have another quick look?

@zestyping zestyping force-pushed the ping/geopoint-with-mapfragment branch from 8cbb742 to ee12532 Compare January 16, 2019 10:31
@zestyping
Copy link
Contributor Author

zestyping commented Jan 17, 2019

Found and fixed two more small issues. This'll be the last, I hope!

  1. The onStop() method turns off GPS tracking while the activity is in the background, so there needs to be an onStart() method that reactivates the GPS.

  2. The MapHelper helper field in GeoPointMapActivity shadows the helper field in the base class, BaseGeoMapActivity, and BaseGeoMapActivity.onSaveInstanceState crashes when helper is null.

@yanokwa yanokwa modified the milestones: v1.19, v1.20 Jan 22, 2019
@zestyping
Copy link
Contributor Author

This pull request is now obsolete; it has been rolled into #2865.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants