-
Notifications
You must be signed in to change notification settings - Fork 1.3k
replaced icafe with metadata extractor #2546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9df2e99
94a8add
071407d
c7efa4a
9c3b140
3795da6
0e0ba97
9c7b525
72274ef
d3063b0
602daa4
1f517c2
177ae86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package fr.free.nrw.commons.upload; | ||
|
||
import android.content.Context; | ||
import android.net.Uri; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.inject.Inject; | ||
|
@@ -20,7 +23,10 @@ | |
|
||
/** | ||
* Methods for pre-processing images to be uploaded | ||
*/ | ||
*//*if (dataInBytes[0] == 70 && dataInBytes[1] == 66 && dataInBytes[2] == 77 && dataInBytes[3] == 68) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this comment intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was added mistakenly I'll remove it |
||
Timber.d("Contains FBMD"); | ||
return Single.just(ImageUtils.FILE_FBMD); | ||
}*/ | ||
@Singleton | ||
public class ImageProcessingService { | ||
private final FileUtilsWrapper fileUtilsWrapper; | ||
|
@@ -56,11 +62,13 @@ Single<Integer> validateImage(UploadModel.UploadItem uploadItem, boolean checkTi | |
} | ||
Timber.d("Checking the validity of image"); | ||
String filePath = uploadItem.getMediaUri().getPath(); | ||
Uri contentUri=uploadItem.getContentUri(); | ||
Context context=uploadItem.getContext(); | ||
Single<Integer> duplicateImage = checkDuplicateImage(filePath); | ||
Single<Integer> wrongGeoLocation = checkImageGeoLocation(uploadItem.getPlace(), filePath); | ||
Single<Integer> darkImage = checkDarkImage(filePath); | ||
Single<Integer> itemTitle = checkTitle ? validateItemTitle(uploadItem) : Single.just(ImageUtils.IMAGE_OK); | ||
Single<Integer> checkFBMD = checkFBMD(filePath); | ||
Single<Integer> checkFBMD = checkFBMD(context,contentUri); | ||
|
||
Single<Integer> zipResult = Single.zip(duplicateImage, wrongGeoLocation, darkImage, itemTitle, | ||
(duplicate, wrongGeo, dark, title) -> { | ||
|
@@ -84,9 +92,9 @@ Single<Integer> validateImage(UploadModel.UploadItem uploadItem, boolean checkTi | |
* Thus we successfully protect common's from Facebook's copyright violation | ||
*/ | ||
|
||
public Single<Integer> checkFBMD(String filePath) { | ||
public Single<Integer> checkFBMD(Context context,Uri contentUri) { | ||
try { | ||
return readFBMD.processMetadata(filePath); | ||
return readFBMD.processMetadata(context,contentUri); | ||
} catch (IOException e) { | ||
return Single.just(ImageUtils.FILE_FBMD); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package fr.free.nrw.commons.upload; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.ContentValues; | ||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.provider.MediaStore; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
|
||
|
@@ -38,7 +41,7 @@ | |
public class UploadModel { | ||
|
||
private static UploadItem DUMMY = new UploadItem( | ||
Uri.EMPTY, | ||
Uri.EMPTY, Uri.EMPTY, | ||
"", | ||
"", | ||
GPSExtractor.DUMMY, | ||
|
@@ -54,7 +57,7 @@ public class UploadModel { | |
private boolean bottomCardState = true; | ||
private boolean rightCardState = true; | ||
private int currentStepIndex = 0; | ||
private Context context; | ||
public static Context context; | ||
private Disposable badImageSubscription; | ||
|
||
private SessionManager sessionManager; | ||
|
@@ -108,7 +111,7 @@ private UploadItem getUploadItem(UploadableFile uploadableFile, | |
} | ||
Timber.d("File created date is %d", fileCreatedDate); | ||
GPSExtractor gpsExtractor = fileProcessor.processFileCoordinates(similarImageInterface); | ||
return new UploadItem(Uri.parse(uploadableFile.getFilePath()), uploadableFile.getMimeType(context), source, gpsExtractor, place, fileCreatedDate, createdTimestampSource); | ||
return new UploadItem(uploadableFile.getContentUri(), Uri.parse(uploadableFile.getFilePath()), uploadableFile.getMimeType(context), source, gpsExtractor, place, fileCreatedDate, createdTimestampSource); | ||
} | ||
|
||
void onItemsProcessed(Place place, List<UploadItem> uploadItems) { | ||
|
@@ -327,6 +330,7 @@ public List<UploadItem> getItems() { | |
|
||
@SuppressWarnings("WeakerAccess") | ||
static class UploadItem { | ||
private final Uri originalContentUri; | ||
private final Uri mediaUri; | ||
private final String mimeType; | ||
private final String source; | ||
|
@@ -344,10 +348,12 @@ static class UploadItem { | |
private BehaviorSubject<Integer> imageQuality; | ||
|
||
@SuppressLint("CheckResult") | ||
UploadItem(Uri mediaUri, String mimeType, String source, GPSExtractor gpsCoords, | ||
UploadItem(Uri originalContentUri, | ||
Uri mediaUri, String mimeType, String source, GPSExtractor gpsCoords, | ||
@Nullable Place place, | ||
long createdTimestamp, | ||
String createdTimestampSource) { | ||
this.originalContentUri = originalContentUri; | ||
this.createdTimestampSource = createdTimestampSource; | ||
title = new Title(); | ||
descriptions = new ArrayList<>(); | ||
|
@@ -428,6 +434,14 @@ public String getFileName() { | |
public Place getPlace() { | ||
return place; | ||
} | ||
|
||
public Uri getContentUri() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not required. Instead of generating content uri here, simply pass it to |
||
return originalContentUri; | ||
} | ||
|
||
public Context getContext(){ | ||
return UploadModel.context; | ||
} | ||
} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dependency already exists. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry I'll remove it