From 5492aa7551f473363720442d77b6376fc91794c4 Mon Sep 17 00:00:00 2001 From: misaochan Date: Fri, 5 Feb 2016 18:00:10 +1300 Subject: [PATCH] Implement check for gpsPref --- .../fr/free/nrw/commons/upload/GPSExtractor.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java b/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java index 91c023f82..6528cadb7 100644 --- a/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java +++ b/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java @@ -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);