Fixes Issue #5704: Upload Wizard: "Edit location" shows my location instead of picture's location #5716
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (required)
Fixes #5704. When editing a location on the upload wizard, the map will now center on the picture's location which is retrieved from the picture's metadata. If this location metadata does not exist, the map will center on the device's GPS location.
What changes did you make and why?:
I added a simple check which primarily sees if the cameraPosition object (which contains image location metadata) is not null. If it is not null, the map is centered at the cameraPosition's coordinates.
Prior to this change, code called within setupMapView() (LocationPickerActivity.java:239, right above the new code) would center the map on the image location (if available), then center the map on the device's current or last known GPS location. This change simply attempts centering the map to the image location again.
This change is a simple solution. Code within LocationPickerActivity.java could be refactored to have a more elegant solution, but I don't know if that should be done for this issue or as a new issue.
Tests performed (required)
Tested betaDebug on the Android Studio emulator with API level 34.
Screenshots (for UI changes only)
In the following demonstration, I have set the emulator device location to NYC. I have two pictures on the device to upload. Both pictures are taken in Seattle, WA. The first picture has location metadata, the second does not.
When editing the location on the first picture, the map is correctly centered on the picture's location. When adding the location on the second picture, the map is centered on the device's current location in NYC.
location_bugfix_compressed.webm