mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Get decimal coords to pass into startUpload()
This commit is contained in:
parent
4db5dfb5d8
commit
147367d75f
2 changed files with 16 additions and 10 deletions
|
|
@ -95,13 +95,11 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse{
|
||||||
return filePath;
|
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
|
* Gets coordinates for category suggestions, either from EXIF data or user location
|
||||||
* @param gpsEnabled if true use GPS
|
* @param gpsEnabled if true use GPS
|
||||||
*/
|
*/
|
||||||
GPSExtractor getFileCoordinates(boolean gpsEnabled) {
|
GPSExtractor processFileCoordinates(boolean gpsEnabled) {
|
||||||
Timber.d("Calling GPSExtractor");
|
Timber.d("Calling GPSExtractor");
|
||||||
try {
|
try {
|
||||||
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
|
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
|
||||||
|
|
@ -132,6 +130,10 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse{
|
||||||
return imageObj;
|
return imageObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getDecimalCoords() {
|
||||||
|
return decimalCoords;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find other images around the same location that were taken within the last 20 sec
|
* Find other images around the same location that were taken within the last 20 sec
|
||||||
* @param gpsEnabled True if GPS is enabled
|
* @param gpsEnabled True if GPS is enabled
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ public class ShareActivity
|
||||||
private Uri mediaUri;
|
private Uri mediaUri;
|
||||||
private Contribution contribution;
|
private Contribution contribution;
|
||||||
private boolean cacheFound;
|
private boolean cacheFound;
|
||||||
private GPSExtractor imageObj;
|
private GPSExtractor gpsObj;
|
||||||
private GPSExtractor tempImageObj;
|
private GPSExtractor tempImageObj;
|
||||||
private String decimalCoords;
|
private String decimalCoords;
|
||||||
private FileProcessor fileObj;
|
private FileProcessor fileObj;
|
||||||
|
|
@ -180,7 +180,7 @@ public class ShareActivity
|
||||||
* Gets file metadata for category suggestions, displays toast, caches categories found, calls uploadController
|
* Gets file metadata for category suggestions, displays toast, caches categories found, calls uploadController
|
||||||
*/
|
*/
|
||||||
private void uploadBegins() {
|
private void uploadBegins() {
|
||||||
fileObj.getFileCoordinates(locationPermitted);
|
fileObj.processFileCoordinates(locationPermitted);
|
||||||
|
|
||||||
Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG);
|
Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG);
|
||||||
startingToast.show();
|
startingToast.show();
|
||||||
|
|
@ -191,6 +191,9 @@ public class ShareActivity
|
||||||
Timber.d("Cache the categories found");
|
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 -> {
|
uploadController.startUpload(title, mediaUri, description, mimeType, source, decimalCoords, c -> {
|
||||||
ShareActivity.this.contribution = c;
|
ShareActivity.this.contribution = c;
|
||||||
showPostUpload();
|
showPostUpload();
|
||||||
|
|
@ -306,7 +309,8 @@ public class ShareActivity
|
||||||
ContentResolver contentResolver = this.getContentResolver();
|
ContentResolver contentResolver = this.getContentResolver();
|
||||||
fileObj = new FileProcessor(mediaUri, contentResolver, this);
|
fileObj = new FileProcessor(mediaUri, contentResolver, this);
|
||||||
checkIfFileExists();
|
checkIfFileExists();
|
||||||
imageObj = fileObj.getFileCoordinates(locationPermitted);
|
gpsObj = fileObj.processFileCoordinates(locationPermitted);
|
||||||
|
decimalCoords = fileObj.getDecimalCoords();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -340,7 +344,7 @@ public class ShareActivity
|
||||||
private void showFABMenu() {
|
private void showFABMenu() {
|
||||||
isFABOpen=true;
|
isFABOpen=true;
|
||||||
|
|
||||||
if( imageObj != null && imageObj.imageCoordsExists)
|
if( gpsObj != null && gpsObj.imageCoordsExists)
|
||||||
mapButton.setVisibility(View.VISIBLE);
|
mapButton.setVisibility(View.VISIBLE);
|
||||||
zoomInButton.setVisibility(View.VISIBLE);
|
zoomInButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
@ -468,7 +472,7 @@ public class ShareActivity
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
try {
|
try {
|
||||||
imageObj.unregisterLocationManager();
|
gpsObj.unregisterLocationManager();
|
||||||
Timber.d("Unregistered locationManager");
|
Timber.d("Unregistered locationManager");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Timber.d("locationManager does not exist, not unregistered");
|
Timber.d("locationManager does not exist, not unregistered");
|
||||||
|
|
@ -626,8 +630,8 @@ public class ShareActivity
|
||||||
|
|
||||||
@OnClick(R.id.media_map)
|
@OnClick(R.id.media_map)
|
||||||
public void onFabShowMapsClicked() {
|
public void onFabShowMapsClicked() {
|
||||||
if (imageObj != null && imageObj.imageCoordsExists) {
|
if (gpsObj != null && gpsObj.imageCoordsExists) {
|
||||||
Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + imageObj.getDecLatitude() + "," + imageObj.getDecLongitude());
|
Uri gmmIntentUri = Uri.parse("google.streetview:cbll=" + gpsObj.getDecLatitude() + "," + gpsObj.getDecLongitude());
|
||||||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
||||||
mapIntent.setPackage("com.google.android.apps.maps");
|
mapIntent.setPackage("com.google.android.apps.maps");
|
||||||
startActivity(mapIntent);
|
startActivity(mapIntent);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue