mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixes location issue in upload wizard (#5329)
* Fixes location issue in upload wizard * Fixes blue dot disappearance on first install
This commit is contained in:
parent
8aee7a680d
commit
048b78a03a
2 changed files with 11 additions and 6 deletions
|
|
@ -314,7 +314,7 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
|
|||
/**
|
||||
* Show the location in map app
|
||||
*/
|
||||
public void showInMap(){
|
||||
public void showInMap() {
|
||||
Utils.handleGeoCoordinates(this,
|
||||
new fr.free.nrw.commons.location.LatLng(cameraPosition.target.getLatitude(),
|
||||
cameraPosition.target.getLongitude(), 0.0f));
|
||||
|
|
@ -387,6 +387,8 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
|
|||
});
|
||||
|
||||
|
||||
} else {
|
||||
requestLocationPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -458,13 +460,13 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
|
|||
*/
|
||||
private void addCenterOnGPSButton(){
|
||||
fabCenterOnLocation = findViewById(R.id.center_on_gps);
|
||||
fabCenterOnLocation.setOnClickListener(view -> getCenter());
|
||||
fabCenterOnLocation.setOnClickListener(view -> requestLocationPermissions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Center the map at user's current location
|
||||
*/
|
||||
private void getCenter() {
|
||||
private void requestLocationPermissions() {
|
||||
LocationPermissionsHelper.Dialog locationAccessDialog = new Dialog(
|
||||
R.string.location_permission_title,
|
||||
R.string.upload_map_location_access
|
||||
|
|
@ -539,6 +541,9 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
|
|||
|
||||
@Override
|
||||
public void onLocationPermissionGranted() {
|
||||
if (mapboxMap.getStyle() != null) {
|
||||
enableLocationComponent(mapboxMap.getStyle());
|
||||
}
|
||||
fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation();
|
||||
if (currLocation != null) {
|
||||
final CameraPosition position;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package fr.free.nrw.commons.location;
|
||||
|
||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||
|
||||
import android.Manifest.permission;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
|
@ -9,7 +10,6 @@ import android.location.Location;
|
|||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -59,9 +59,9 @@ public class LocationServiceManager implements LocationListener {
|
|||
for (String provider : providers) {
|
||||
Location l=null;
|
||||
if (ActivityCompat.checkSelfPermission(getApplicationContext(), permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED
|
||||
== PackageManager.PERMISSION_GRANTED
|
||||
&& ActivityCompat.checkSelfPermission(getApplicationContext(), permission.ACCESS_COARSE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
l = locationManager.getLastKnownLocation(provider);
|
||||
}
|
||||
if (l == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue