Skip to content

Commit 102fbfb

Browse files
LocationPickerActivity.java: fix bug with permissions menu moving map
Prior to this change, if the menu asking for permissions to access the device's GPS was accepted, the map would automatically move to the most recent or current GPS location, rather than staying at the uploaded image's available EXIF location. After this change, the map will stay centered at the image's available EXIF location, as intended. The relevant method name and javadoc have been changed to more accurately describe the method's behavior.
1 parent 8ca6348 commit 102fbfb

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@
4040
import fr.free.nrw.commons.Utils;
4141
import fr.free.nrw.commons.auth.SessionManager;
4242
import fr.free.nrw.commons.auth.csrf.CsrfTokenClient;
43-
import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException;
4443
import fr.free.nrw.commons.coordinates.CoordinateEditHelper;
4544
import fr.free.nrw.commons.filepicker.Constants;
4645
import fr.free.nrw.commons.kvstore.BasicKvStore;
4746
import fr.free.nrw.commons.kvstore.JsonKvStore;
48-
import fr.free.nrw.commons.location.LatLng;
4947
import fr.free.nrw.commons.location.LocationPermissionsHelper;
5048
import fr.free.nrw.commons.location.LocationPermissionsHelper.LocationPermissionCallback;
5149
import fr.free.nrw.commons.location.LocationServiceManager;
@@ -606,26 +604,25 @@ public void onLocationPermissionGranted() {
606604
locationManager.requestLocationUpdatesFromProvider(
607605
LocationManager.NETWORK_PROVIDER);
608606
locationManager.requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
609-
getLocation();
607+
addMarkerAtGPSLocation();
610608
} else {
611-
getLocation();
609+
addMarkerAtGPSLocation();
612610
locationPermissionsHelper.showLocationOffDialog(this,
613611
R.string.ask_to_turn_location_on_text);
614612
}
615613
}
616614
}
617615

618616
/**
619-
* Gets new location if locations services are on, else gets last location
617+
* Adds a marker to the map at the most recent GPS location
618+
* (which may be the current GPS location).
620619
*/
621-
private void getLocation() {
620+
private void addMarkerAtGPSLocation() {
622621
fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation();
623622
if (currLocation != null) {
624623
GeoPoint currLocationGeopoint = new GeoPoint(currLocation.getLatitude(),
625624
currLocation.getLongitude());
626625
addLocationMarker(currLocationGeopoint);
627-
mapView.getController().setCenter(currLocationGeopoint);
628-
mapView.getController().animateTo(currLocationGeopoint);
629626
markerImage.setTranslationY(0);
630627
}
631628
}

0 commit comments

Comments
 (0)