mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Refactored to put URI conversions in its own class
Instead of lumping it with GPS extraction code
This commit is contained in:
parent
87b23b8494
commit
ac83480915
3 changed files with 11 additions and 52 deletions
|
|
@ -1,56 +1,21 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class ImageProcessing {
|
||||
public class GPSExtractor {
|
||||
|
||||
private Uri uri;
|
||||
private Context context;
|
||||
private String filePath;
|
||||
|
||||
public ImageProcessing(Context context, Uri uri){
|
||||
this.context = context;
|
||||
this.uri = uri;
|
||||
}
|
||||
/**
|
||||
* Gets file path of image from its Uri
|
||||
* May return null
|
||||
*/
|
||||
public String getFilePath(){
|
||||
String filePath ="";
|
||||
// Will return "image:x*"
|
||||
String wholeID = DocumentsContract.getDocumentId(uri);
|
||||
|
||||
// Split at colon, use second item in the array
|
||||
String id = wholeID.split(":")[1];
|
||||
String[] column = { MediaStore.Images.Media.DATA };
|
||||
|
||||
// where id is equal to
|
||||
String sel = MediaStore.Images.Media._ID + "=?";
|
||||
Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
column, sel, new String[]{id}, null);
|
||||
|
||||
int columnIndex = cursor.getColumnIndex(column[0]);
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
filePath = cursor.getString(columnIndex);
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
Log.d("Image", "File path: " + filePath);
|
||||
return filePath;
|
||||
public GPSExtractor(String filePath){
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
//Extract GPS coords of image
|
||||
public String getCoords(String filePath) {
|
||||
public String getCoords() {
|
||||
|
||||
ExifInterface exif;
|
||||
String latitude = "";
|
||||
|
|
@ -1,18 +1,14 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
import android.content.*;
|
||||
import android.media.ExifInterface;
|
||||
import android.os.*;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import android.net.*;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.*;
|
||||
import android.database.Cursor;
|
||||
|
||||
import fr.free.nrw.commons.*;
|
||||
import fr.free.nrw.commons.modifications.CategoryModifier;
|
||||
|
|
@ -25,7 +21,6 @@ import fr.free.nrw.commons.auth.*;
|
|||
import fr.free.nrw.commons.modifications.ModificationsContentProvider;
|
||||
import fr.free.nrw.commons.modifications.ModifierSequence;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
|
|
@ -42,12 +37,9 @@ public class ShareActivity
|
|||
private String source;
|
||||
private String mimeType;
|
||||
private String mediaUriString;
|
||||
private String filePath = "";
|
||||
|
||||
private Uri mediaUri;
|
||||
|
||||
private ExifInterface exif;
|
||||
|
||||
private Contribution contribution;
|
||||
|
||||
private ImageView backgroundImageView;
|
||||
|
|
@ -183,9 +175,11 @@ public class ShareActivity
|
|||
mediaUriString = mediaUri.toString();
|
||||
Log.d("Image", "Uri: " + mediaUriString);
|
||||
|
||||
ImageProcessing imageObj = new ImageProcessing(this, mediaUri);
|
||||
String filePath = imageObj.getFilePath();
|
||||
String coords = imageObj.getCoords(filePath);
|
||||
FilePathConverter uriObj = new FilePathConverter(this, mediaUri);
|
||||
String filePath = uriObj.getFilePath();
|
||||
|
||||
GPSExtractor imageObj = new GPSExtractor(filePath);
|
||||
String coords = imageObj.getCoords();
|
||||
Log.d("Image", "Coords of image: " + coords);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class UploadController {
|
|||
@Override
|
||||
protected void onPostExecute(Contribution contribution) {
|
||||
super.onPostExecute(contribution);
|
||||
uploadService.queue(UploadService.ACTION_UPLOAD_FILE, contribution);
|
||||
//uploadService.queue(UploadService.ACTION_UPLOAD_FILE, contribution);
|
||||
onComplete.onUploadStarted(contribution);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue