Implement check for gpsPref

This commit is contained in:
misaochan 2016-02-05 18:00:10 +13:00
parent f7c5796d70
commit 5492aa7551

View file

@ -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);