mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									8ca6348c8c
								
							
						
					
					
						commit
						102fbfbeea
					
				
					 1 changed files with 5 additions and 8 deletions
				
			
		|  | @ -40,12 +40,10 @@ import fr.free.nrw.commons.R; | |||
| import fr.free.nrw.commons.Utils; | ||||
| import fr.free.nrw.commons.auth.SessionManager; | ||||
| import fr.free.nrw.commons.auth.csrf.CsrfTokenClient; | ||||
| import fr.free.nrw.commons.auth.csrf.InvalidLoginTokenException; | ||||
| import fr.free.nrw.commons.coordinates.CoordinateEditHelper; | ||||
| import fr.free.nrw.commons.filepicker.Constants; | ||||
| import fr.free.nrw.commons.kvstore.BasicKvStore; | ||||
| import fr.free.nrw.commons.kvstore.JsonKvStore; | ||||
| import fr.free.nrw.commons.location.LatLng; | ||||
| import fr.free.nrw.commons.location.LocationPermissionsHelper; | ||||
| import fr.free.nrw.commons.location.LocationPermissionsHelper.LocationPermissionCallback; | ||||
| import fr.free.nrw.commons.location.LocationServiceManager; | ||||
|  | @ -606,9 +604,9 @@ public class LocationPickerActivity extends BaseActivity implements | |||
|                 locationManager.requestLocationUpdatesFromProvider( | ||||
|                     LocationManager.NETWORK_PROVIDER); | ||||
|                 locationManager.requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER); | ||||
|                 getLocation(); | ||||
|                 addMarkerAtGPSLocation(); | ||||
|             } else { | ||||
|                 getLocation(); | ||||
|                 addMarkerAtGPSLocation(); | ||||
|                 locationPermissionsHelper.showLocationOffDialog(this, | ||||
|                     R.string.ask_to_turn_location_on_text); | ||||
|             } | ||||
|  | @ -616,16 +614,15 @@ public class LocationPickerActivity extends BaseActivity implements | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Gets new location if locations services are on, else gets last location | ||||
|      * Adds a marker to the map at the most recent GPS location | ||||
|      * (which may be the current GPS location). | ||||
|      */ | ||||
|     private void getLocation() { | ||||
|     private void addMarkerAtGPSLocation() { | ||||
|         fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation(); | ||||
|         if (currLocation != null) { | ||||
|             GeoPoint currLocationGeopoint = new GeoPoint(currLocation.getLatitude(), | ||||
|                 currLocation.getLongitude()); | ||||
|             addLocationMarker(currLocationGeopoint); | ||||
|             mapView.getController().setCenter(currLocationGeopoint); | ||||
|             mapView.getController().animateTo(currLocationGeopoint); | ||||
|             markerImage.setTranslationY(0); | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jason Whitmore
						Jason Whitmore