mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Implement check for gpsPref
This commit is contained in:
parent
f7c5796d70
commit
5492aa7551
1 changed files with 14 additions and 0 deletions
|
|
@ -2,18 +2,22 @@ package fr.free.nrw.commons.upload;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Criteria;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import fr.free.nrw.commons.SettingsActivity;
|
||||
|
||||
|
||||
public class GPSExtractor {
|
||||
|
||||
|
|
@ -30,6 +34,13 @@ public class GPSExtractor {
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
private boolean gpsPreferenceEnabled() {
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean gpsPref = sharedPref.getBoolean("allowGps", false);
|
||||
Log.d(TAG, "Gps pref set to: " + gpsPref);
|
||||
return gpsPref;
|
||||
}
|
||||
|
||||
//Extract GPS coords of image
|
||||
public String getCoords() {
|
||||
|
||||
|
|
@ -51,6 +62,9 @@ public class GPSExtractor {
|
|||
imageCoordsExists = false;
|
||||
Log.d(TAG, "Picture has no GPS info");
|
||||
|
||||
//Check what user's preference is for automatic location detection
|
||||
boolean gpsPrefEnabled = gpsPreferenceEnabled();
|
||||
|
||||
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
Criteria criteria = new Criteria();
|
||||
String provider = locationManager.getBestProvider(criteria, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue