mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Don't pass Activity into GPSExtractor.
This commit is contained in:
parent
1809475fea
commit
b07432fce2
3 changed files with 8 additions and 9 deletions
|
|
@ -23,7 +23,7 @@ public class FileUtils {
|
||||||
*/
|
*/
|
||||||
// Can be safely suppressed, checks for isKitKat before running isDocumentUri
|
// Can be safely suppressed, checks for isKitKat before running isDocumentUri
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public static String getPath(final Context context, final Uri uri) {
|
public static String getPath(Context context, Uri uri) {
|
||||||
|
|
||||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import fr.free.nrw.commons.CommonsApplication;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -26,15 +27,13 @@ public class GPSExtractor {
|
||||||
private double decLatitude, decLongitude;
|
private double decLatitude, decLongitude;
|
||||||
private Double currentLatitude = null;
|
private Double currentLatitude = null;
|
||||||
private Double currentLongitude = null;
|
private Double currentLongitude = null;
|
||||||
private Context context;
|
|
||||||
public boolean imageCoordsExists;
|
public boolean imageCoordsExists;
|
||||||
private MyLocationListener myLocationListener;
|
private MyLocationListener myLocationListener;
|
||||||
private LocationManager locationManager;
|
private LocationManager locationManager;
|
||||||
|
|
||||||
|
|
||||||
public GPSExtractor(String filePath, Context context){
|
public GPSExtractor(String filePath){
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
this.context = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,7 +41,7 @@ public class GPSExtractor {
|
||||||
* @return true if enabled, false if disabled
|
* @return true if enabled, false if disabled
|
||||||
*/
|
*/
|
||||||
private boolean gpsPreferenceEnabled() {
|
private boolean gpsPreferenceEnabled() {
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(CommonsApplication.getInstance());
|
||||||
boolean gpsPref = sharedPref.getBoolean("allowGps", false);
|
boolean gpsPref = sharedPref.getBoolean("allowGps", false);
|
||||||
Timber.d("Gps pref set to: %b", gpsPref);
|
Timber.d("Gps pref set to: %b", gpsPref);
|
||||||
return gpsPref;
|
return gpsPref;
|
||||||
|
|
@ -52,7 +51,7 @@ public class GPSExtractor {
|
||||||
* Registers a LocationManager to listen for current location
|
* Registers a LocationManager to listen for current location
|
||||||
*/
|
*/
|
||||||
protected void registerLocationManager() {
|
protected void registerLocationManager() {
|
||||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
locationManager = (LocationManager) CommonsApplication.getInstance().getSystemService(Context.LOCATION_SERVICE);
|
||||||
Criteria criteria = new Criteria();
|
Criteria criteria = new Criteria();
|
||||||
String provider = locationManager.getBestProvider(criteria, true);
|
String provider = locationManager.getBestProvider(criteria, true);
|
||||||
myLocationListener = new MyLocationListener();
|
myLocationListener = new MyLocationListener();
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ public class ShareActivity
|
||||||
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
|
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
|
||||||
if(shareView == null && categorizationFragment == null) {
|
if(shareView == null && categorizationFragment == null) {
|
||||||
shareView = new SingleUploadFragment();
|
shareView = new SingleUploadFragment();
|
||||||
this.getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.add(R.id.single_upload_fragment_container, shareView, "shareView")
|
.add(R.id.single_upload_fragment_container, shareView, "shareView")
|
||||||
.commitAllowingStateLoss();
|
.commitAllowingStateLoss();
|
||||||
|
|
@ -373,11 +373,11 @@ public class ShareActivity
|
||||||
* @param gpsEnabled
|
* @param gpsEnabled
|
||||||
*/
|
*/
|
||||||
public void getFileMetadata(boolean gpsEnabled) {
|
public void getFileMetadata(boolean gpsEnabled) {
|
||||||
String filePath = FileUtils.getPath(this, mediaUri);
|
String filePath = FileUtils.getPath(getApplicationContext(), mediaUri);
|
||||||
Timber.d("Filepath: %s", filePath);
|
Timber.d("Filepath: %s", filePath);
|
||||||
Timber.d("Calling GPSExtractor");
|
Timber.d("Calling GPSExtractor");
|
||||||
if(imageObj == null) {
|
if(imageObj == null) {
|
||||||
imageObj = new GPSExtractor(filePath, this);
|
imageObj = new GPSExtractor(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filePath != null && !filePath.equals("")) {
|
if (filePath != null && !filePath.equals("")) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue