-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Define the MapFragment interface; factor its implementation out of both GeoShape activities. #2465
Define the MapFragment interface; factor its implementation out of both GeoShape activities. #2465
Conversation
* listener will be invoked with this MapFragment when the map is ready | ||
* to be used, or with null if there is a problem initializing the map. | ||
*/ | ||
void addTo(@NonNull FragmentActivity activity, int containerId, @Nullable ReadyListener listener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to pass in the context? Can the fragment always call getActivity()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I've fixed this.
@grzesiek2010, it would be great to get your high-level thoughts on this since you've spent the most time in this code recently. Do you see any issues with the I had a chance to have a brief voice conversation about this with @zestyping. I asked him about the use of the @mmarciniak90, when you have a chance, it would be very helpful to get a comprehensive check on whether the behavior between the new and old shape activities is the same. 🙏 |
this.lon = lon; | ||
} | ||
|
||
public MapPoint(Parcel parcel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this constructor should be private so that only the CREATOR
field can access. Am I right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea! Fixed.
The code looks good I think @mmarciniak90 can perform some tests and you can go ahead. |
I have already started some testing. It looks good so far - switching between old and new activities works as described and I didn't recognize any regression with geoshape widget and OpenStreetMap SDK. Unfortunately, I encountered the problem with Google maps as they are not visible for me, I can see a Google logo and empty space and buttons. I think that it might be something wrong with my API configuration, I generated API key on google clouds, add in there package name and SHA-1 certificate fingerprint on restriction section. I have also added API key number AndroidManifest.xml file and then build an app. I tried to figure it out but for now, I didn't succeed. @lognaturel, do you have any ideas what I can be possibly missing in the configuration? This is not connected with this pr as I have the same result on the master branch. I am able to publish submission to google sheet so my configuration must be not that bad. Maybe I am not aware of something which I should do to use it. It looks like I am a bit block with testing this pr right now. |
It sounds like you followed all the instructions linked to from https://github.com/opendatakit/collect#using-apis-for-local-development. I tried to start the process over with a new project to try the full process but it looks like that now requires a billing account? @yanokwa is this something you know about? I was then able to grab a key I had previously created at https://console.cloud.google.com/google/maps-apis/apis/maps-android-backend.googleapis.com. I first tried it restricted and it doesn't work. Then I went through the restriction process with the SHA1 and it still didn't work. The docs say it could take some time to propagate so I tried again after 10 minutes but still no map. @zestyping How did you get your key working? |
faae3c4
to
76cd7f8
Compare
4a08500
to
a1c8ff0
Compare
I've made some more progress and updated this pull request. This now includes a new implementation for the OSM activity as well as the Google Map activity, so we are extremely close to having a single GeoShape activity now. @mmarciniak90 @kkrawczyk123 Thanks for starting to test this! I'm sorry that I don't know how to solve your API key problem, but to make testing possible, I'm attaching my own build of the APK here. This is a debug build that uses my personal Google Maps API key, so it should work for you. We're ready now for you to test this and verify that:
You can use the volume buttons to put the phone in silent / non-silent mode to switch between the new / old activities, respectively. The bar on top will tell you which activity you're getting. Here's that APK: GitHub wouldn't let me upload an |
@zestyping @lognaturel I was able to test it with attached apk but I couldn't on my own build. In a meantime, I noticed an issue which occurs on master too so reported it as a separate one in #2492. I have noticed a few issues connected with the new version of the geoshape widget:
@opendatakit-bot unlabel "needs testing" |
Thank you @zestyping for posting the APK and @kkrawczyk123 for your careful testing! The first two bullets look like bugs in the new implementation.
Good catch, this is a subtle difference! I think this comes from a difference in when the constraint that requires 3 points is evaluated. The old version seems to still save the polygon even if it's invalid. The new version does not save an invalid polygon. Overall, I find the new version more correct. For example, it means you can't save a 2-point polygon whereas in the old version you can. The clearing case is kind of annoying, though. It's true that the user could long-press on the question to clear it (same as with any other question) but that's not so discoverable and not everyone knows about it. I think maybe we should allow a 0-point polygon or polyline, just not a 1-point line or 1 or 2 point polygon. @zestyping, what do you think? 0-point seems like it should be valid (to be clear, this is an issue with the validations as they exist, not with any new code but I think it would be ok to make the change here, ideally in its own commit).
The old version makes no check before letting the user back out of a shape collection. That's bad because a user could have collected a very careful shape and then lose it all! So I think the check on back button is a very good one. It's true that there are two cases -- one where changes were actually made and one where none were. @zestyping what do you think of adding state to keep track of whether any changes were made and only prompting if there was a change? |
Thank you @kkrawczyk123 for catching these issues!
The commits I've just pushed include the fixes for items 2, 3, and 4 above, and also complete the merge into a single activity, Here's a new APK of this build with my key, in case anyone wants to try it out. Note that the zoom-to-location issue is still not addressed yet, though. |
Oh, I just hadn't considered that for some reason. I agree it's better than a flag. 👍 Once you have a chance to look into the zoom issue and fix pmd problems breaking the build, we can do QA and review pass in preparation for merge. 🎉 |
With these latest commits, all the various linter complaints are addressed (or suppressed with good reason), and the Google Map zoom issue is fixed. The cause of the zoom problem was that the activity did an animated Note also one small behaviour change: the old Google activity would zoom to the current location at zoom level 17, whereas the old OSM activity would zoom to the current location at zoom level 15. The new activity splits the difference and zooms to the current location at zoom level 16. This is an APK build with the zoom issue fixed, and with the old activities still available in case we need to do any further comparison testing: This is a candidate final APK build with the old activities removed, with the code in a state ready for merging to master: |
Hi @zestyping! I looked on your fix.
Unfortunately, I noticed also a few cases which do not work as expected:
|
@opendatakit-bot unlabel "needs testing" |
Thank you very much @mmarciniak90! I will investigate the issues you found. |
Hi, I'm back from Tanzania and have pushed new commits to address the issues that @mmarciniak90 found in her last round of testing. Specifically:
As usual, I've made an APK that contains my Google API key so you can test these changes. Here it is: |
My apologies—these changes broke the tests that rely on the GoogleMap. Unfortunately, it looks like Google Play Services is unavailable during Robolectric testing, which means there's no GoogleMap at all during tests. To get around this, I had to stub out more of the implementation during testing. This is kind of messy and I don't like it, but I haven't found another solution; at least these are all checks for Here's the fix, again with a new APK: |
😬I always find these kinds of things tough. I agree with you that all those decimal digits are a bit silly. I tend to be pretty conservative about those kinds of changes now, though, and wouldn't be surprised if some folks somehow rely on the specific number of digits for their analysis. I've been burned by this kind of seemingly trivial change enough times that I would tend to leave it as-is unless there's a strong argument against. If we do make the change, it should at least be consistent between all the geo types. |
@zestyping, thanks for the update. @lognaturel, so results should have high precision, as before. Am I right? @opendatakit-bot unlabel "needs testing" |
I can also consistently reproduce the crash:
Yes but @zestyping will need to build a new APK for that. |
Had a quick conversation with @zestyping about this and he can reproduce. In looking at this, we realized that the version of |
Hi @lognaturel, I investigated more closely and it turns out that it actually was the problem I previously identified—setting the center before setting the zoom level. My error was that I had fixed it in a different branch (the prospective work that I was doing on GeoTrace), and not in this branch. Doing the operations in the other order—setting the zoom level first, then setting the center—fixes the problem. Since this is a much smaller change than upgrading to the next version of My plan is to follow up by rebasing this branch as we discussed previously so it's ready for merging, and then produce another (hopefully final!) APK for testing this PR. |
Sounds great!
I'm glad we've noticed this now. Would be good to do as part of this overall work but I agree that if we can bump it, that's a good idea. |
cb47762
to
0ad7052
Compare
@lognaturel @mmarciniak90 Okay, this is fixed, and ready for testing. I have also cleaned up the commits in this branch so that if it passes QA, then it is ready for merging. This is an APK built from commit 0ad7052 plus my Google API key: |
Looks good and I have marked as |
(Defines the MapFragment interface and moves Google-specific and OSM-specific implementations into GoogleMapFragment and OsmMapFragment.)
(Replaces setCenter() with zoomToPoint() in the MapFragment interface.)
(Makes GoogleMapFragment tolerate a null "map" field, which can occur when Google Play Services is unavailable during tests; allows each MapFragment implementation to define its own default view center and default zoom level; removes some unused methods.)
0ad7052
to
6991ba6
Compare
Added license headers and fixed commit messages. New commit is New APK built at |
@zestyping inside that zip you attached above there is a build collect-9917329-ping-key.apk from the 5th of September. |
@zestyping, I have to ask if switching between new and old version of the widget by volume button has been turned off intentionally? as there is no new/old GeoShapeActivity title above map as it used to be before and behaviors are consistent. |
@kkrawczyk123 Sorry! I don't know how that happened. You are correct, the zip file in the comment above contained the wrong APK. Here is a zip file 6991ba6 containing the latest build, 6991ba6 with my Google API key. Which APK is the one that you tested? |
As of the latest commit, |
Let's wait to hear the final word from @kkrawczyk123 but I think she may actually have a gmaps key that she was able to try things out with. @mmarciniak90 and I are the ones who didn't have functional keys. I finally took the time to review the current API key process and now do have a working key. I've also issued a PR to update the instructions: #2611. @kkrawczyk123, @mmarciniak90, it's an unrestricted key so I can share it with you privately if you can't set up a billing account. Barring anything unexpected from @kkrawczyk123, I do think it's ready to merge! History is beautiful and the quick spin I took it on didn't show any behavior problems. |
@lognaturel my key didn't work, so I wanted to use attached apk but it was outdated. I thought "ooops" and I asked @mmarciniak90 if her key worked, and it did so she built an apk for me. I tested built with the newest commits and I also compared to old one - this is why I was asking about volume button as it changed but I didn't find any information about it in comments so I wasn't sure if it was intentional. |
🎉 🎉🎉🎉🎉 |
Wonderful! |
This pull request factors out a common interface between the Google Map SDK and the OSMDroid Map SDK, moving us close to the goal of having a single GeoShapeActivity that supports both map SDKs.
The new interface is
MapFragment
.GeoShapeGoogleMapActivity
is now an activity with noGoogleMap
dependencies; instead it callsGoogleMapFragment
, a Google-specific implementation ofMapFragment
.GeoShapeOsmMapActivity
is now an activity with noosmdroid
dependencies; instead it callsOsmMapFragment
, an OSM-specific implementation ofMapFragment
.GeoShapeGoogleMapActivity
andGeoShapeOsmMapActivity
are almost identical; the final step is to make them identical, rename them toGeoShapeActivity
, and celebrate!Before we can do that, we need to verify that the new activities work and have the same behaviour as before. To facilitate comparison testing, the original
GeoShapeGoogleMapActivity
andGeoShapeOsmMapActivity
are still present and available in the app (but renamed asGeoShapeOldGoogleMapActivity
andGeoShapeOldOsmMapActivity
). In both cases, the old activity is started whenever the ringer is on, and the new activity is started when the ringer is off. That way, you can easily test behaviour in the app, and switch between the two activities to compare them just by pressing the volume buttons to put the phone in silent or ringing mode. The text label at the top of the screen shows you whether you're using the old activity or the new one.Guidance to reviewers
I recommend starting with MapFragment first, as most of the interesting design decisions are there.
The next step would be looking at how GeoShapeGoogleMapActivity has changed to use MapFragment, and then finally the implementation classes, GoogleMapFragment and OsmMapFragment.
Guidance to testers
This change affects the GeoShape widget (both in Google mode and OSM mode).
To bring up the old activity, make sure your ringer is on (volume up) and then open the GeoShape widget. To bring up the new activity, make sure your ringer is off (volume down until silent), and then open the GeoShape widget. You can use the volume buttons to flip between the old and the new activity to make quick comparisons (close the widget with the "Save" button or the back button, press the volume buttons to turn silent mode on or off, then open the widget again).
What we want to verify: The new activity should behave exactly the same as the old activity, in both Google mode and OSM mode, with only the following intentional changes: