From 147367d75f40b93690c030a4f0fa42ae31699e1e Mon Sep 17 00:00:00 2001 From: misaochan Date: Mon, 4 Jun 2018 19:25:29 +1000 Subject: [PATCH] Get decimal coords to pass into startUpload() --- .../free/nrw/commons/upload/FileProcessor.java | 8 +++++--- .../free/nrw/commons/upload/ShareActivity.java | 18 +++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.java b/app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.java index 88e1c426d..5cddaaade 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/FileProcessor.java @@ -95,13 +95,11 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse{ return filePath; } - //TODO: Figure out why coords are not sent to location template, use LocationServiceManager - /** * Gets coordinates for category suggestions, either from EXIF data or user location * @param gpsEnabled if true use GPS */ - GPSExtractor getFileCoordinates(boolean gpsEnabled) { + GPSExtractor processFileCoordinates(boolean gpsEnabled) { Timber.d("Calling GPSExtractor"); try { ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r"); @@ -132,6 +130,10 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse{ return imageObj; } + String getDecimalCoords() { + return decimalCoords; + } + /** * Find other images around the same location that were taken within the last 20 sec * @param gpsEnabled True if GPS is enabled diff --git a/app/src/main/java/fr/free/nrw/commons/upload/ShareActivity.java b/app/src/main/java/fr/free/nrw/commons/upload/ShareActivity.java index ffb33f545..7a59e336a 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/ShareActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/ShareActivity.java @@ -124,7 +124,7 @@ public class ShareActivity private Uri mediaUri; private Contribution contribution; private boolean cacheFound; - private GPSExtractor imageObj; + private GPSExtractor gpsObj; private GPSExtractor tempImageObj; private String decimalCoords; private FileProcessor fileObj; @@ -180,7 +180,7 @@ public class ShareActivity * Gets file metadata for category suggestions, displays toast, caches categories found, calls uploadController */ private void uploadBegins() { - fileObj.getFileCoordinates(locationPermitted); + fileObj.processFileCoordinates(locationPermitted); Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG); startingToast.show(); @@ -191,6 +191,9 @@ public class ShareActivity Timber.d("Cache the categories found"); } + + //TODO: Figure out why coords are not sent to location template, use LocationServiceManager + uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, c -> { ShareActivity.this.contribution = c; showPostUpload(); @@ -306,7 +309,8 @@ public class ShareActivity ContentResolver contentResolver = this.getContentResolver(); fileObj = new FileProcessor(mediaUri, contentResolver, this); checkIfFileExists(); - imageObj = fileObj.getFileCoordinates(locationPermitted); + gpsObj = fileObj.processFileCoordinates(locationPermitted); + decimalCoords = fileObj.getDecimalCoords(); } /** @@ -340,7 +344,7 @@ public class ShareActivity private void showFABMenu() { isFABOpen=true; - if( imageObj != null && imageObj.imageCoordsExists) + if( gpsObj != null && gpsObj.imageCoordsExists) mapButton.setVisibility(View.VISIBLE); zoomInButton.setVisibility(View.VISIBLE); @@ -468,7 +472,7 @@ public class ShareActivity public void onPause() { super.onPause(); try { - imageObj.unregisterLocationManager(); + gpsObj.unregisterLocationManager(); Timber.d("Unregistered locationManager"); } catch (NullPointerException e) { Timber.d("locationManager does not exist, not unregistered"); @@ -626,8 +630,8 @@ public class ShareActivity @OnClick(R.id.media_map) public void onFabShowMapsClicked() { - if (imageObj != null && imageObj.imageCoordsExists) { - Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + imageObj.getDecLatitude() + "," + imageObj.getDecLongitude()); + if (gpsObj != null && gpsObj.imageCoordsExists) { + Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + gpsObj.getDecLatitude() + "," + gpsObj.getDecLongitude()); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent);