Skip to content

Commit

Permalink
change location to inAppPictureLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
RitikaPahwa4444 committed Jul 4, 2023
1 parent e72be00 commit 74f8c13
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/fr/free/nrw/commons/upload/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ static String getSHA1(InputStream is) {
/**
* Get Geolocation of filePath from input filePath path
*/
static String getGeolocationOfFile(String filePath, LatLng location) {
static String getGeolocationOfFile(String filePath, LatLng inAppPictureLocation) {

try {
ExifInterface exifInterface = new ExifInterface(filePath);
ImageCoordinates imageObj = new ImageCoordinates(exifInterface, location);
ImageCoordinates imageObj = new ImageCoordinates(exifInterface, inAppPictureLocation);
if (imageObj.getDecimalCoords() != null) { // If image has geolocation information in its EXIF
return imageObj.getDecimalCoords();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public FileInputStream getFileInputStream(String filePath) throws FileNotFoundEx
return FileUtils.getFileInputStream(filePath);
}

public String getGeolocationOfFile(String filePath, LatLng location) {
return FileUtils.getGeolocationOfFile(filePath, location);
public String getGeolocationOfFile(String filePath, LatLng inAppPictureLocation) {
return FileUtils.getGeolocationOfFile(filePath, inAppPictureLocation);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ImageCoordinates internal constructor(exif: ExifInterface?, inAppPictureLo
/**
* Construct from a stream.
*/
internal constructor(stream: InputStream, location: LatLng?) : this(ExifInterface(stream), location)
internal constructor(stream: InputStream, inAppPictureLocation: LatLng?) : this(ExifInterface(stream), inAppPictureLocation)
/**
* Construct from the file path of the image.
* @param path file path of the image
*/
@Throws(IOException::class)
internal constructor(path: String, location: LatLng?) : this(ExifInterface(path), location)
internal constructor(path: String, inAppPictureLocation: LatLng?) : this(ExifInterface(path), inAppPictureLocation)

init {
//If image has no EXIF data and user has enabled GPS setting, get user's location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ImageProcessingService(FileUtilsWrapper fileUtilsWrapper,
* Check image quality before upload - checks duplicate image - checks dark image - checks
* geolocation for image - check for valid title
*/
Single<Integer> validateImage(UploadItem uploadItem, LatLng location) {
Single<Integer> validateImage(UploadItem uploadItem, LatLng inAppPictureLocation) {
int currentImageQuality = uploadItem.getImageQuality();
Timber.d("Current image quality is %d", currentImageQuality);
if (currentImageQuality == ImageUtils.IMAGE_KEEP) {
Expand All @@ -58,7 +58,7 @@ Single<Integer> validateImage(UploadItem uploadItem, LatLng location) {

return Single.zip(
checkDuplicateImage(filePath),
checkImageGeoLocation(uploadItem.getPlace(), filePath, location),
checkImageGeoLocation(uploadItem.getPlace(), filePath, inAppPictureLocation),
checkDarkImage(filePath),
validateItemTitle(uploadItem),
checkFBMD(filePath),
Expand Down Expand Up @@ -149,13 +149,13 @@ private Single<Integer> checkDarkImage(String filePath) {
* @param filePath file to be checked
* @return IMAGE_GEOLOCATION_DIFFERENT or IMAGE_OK
*/
private Single<Integer> checkImageGeoLocation(Place place, String filePath, LatLng location) {
private Single<Integer> checkImageGeoLocation(Place place, String filePath, LatLng inAppPictureLocation) {
Timber.d("Checking for image geolocation %s", filePath);
if (place == null || StringUtils.isBlank(place.getWikiDataEntityId())) {
return Single.just(ImageUtils.IMAGE_OK);
}
return Single.fromCallable(() -> filePath)
.flatMap(path -> Single.just(fileUtilsWrapper.getGeolocationOfFile(path, location)))
.flatMap(path -> Single.just(fileUtilsWrapper.getGeolocationOfFile(path, inAppPictureLocation)))
.flatMap(geoLocation -> {
if (StringUtils.isBlank(geoLocation)) {
return Single.just(ImageUtils.IMAGE_OK);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/fr/free/nrw/commons/upload/UploadModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public Observable<UploadItem> preProcessImage(final UploadableFile uploadableFil
createAndAddUploadItem(uploadableFile, place, similarImageInterface, inAppPictureLocation));
}

public Single<Integer> getImageQuality(final UploadItem uploadItem, LatLng location) {
return imageProcessingService.validateImage(uploadItem, location);
public Single<Integer> getImageQuality(final UploadItem uploadItem, LatLng inAppPictureLocation) {
return imageProcessingService.validateImage(uploadItem, inAppPictureLocation);
}

private UploadItem createAndAddUploadItem(final UploadableFile uploadableFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface UserActionListener extends BasePresenter<View> {

void receiveImage(UploadableFile uploadableFile, Place place, LatLng inAppPictureLocation);

void verifyImageQuality(int uploadItemIndex, LatLng location);
void verifyImageQuality(int uploadItemIndex, LatLng inAppPictureLocation);

void copyTitleAndDescriptionToSubsequentMedia(int indexInViewFlipper);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ private void checkNearbyPlaces(final UploadItem uploadItem) {
* @param uploadItemIndex
*/
@Override
public void verifyImageQuality(int uploadItemIndex, LatLng location) {
public void verifyImageQuality(int uploadItemIndex, LatLng inAppPictureLocation) {
final UploadItem uploadItem = repository.getUploads().get(uploadItemIndex);

if (uploadItem.getGpsCoords().getDecimalCoords() == null && location == null) {
if (uploadItem.getGpsCoords().getDecimalCoords() == null && inAppPictureLocation == null) {
final Runnable onSkipClicked = () -> {
view.showProgress(true);
compositeDisposable.add(
repository
.getImageQuality(uploadItem, location)
.getImageQuality(uploadItem, inAppPictureLocation)
.observeOn(mainThreadScheduler)
.subscribe(imageResult -> {
view.showProgress(false);
Expand All @@ -209,7 +209,7 @@ public void verifyImageQuality(int uploadItemIndex, LatLng location) {
view.showProgress(true);
compositeDisposable.add(
repository
.getImageQuality(uploadItem, location)
.getImageQuality(uploadItem, inAppPictureLocation)
.observeOn(mainThreadScheduler)
.subscribe(imageResult -> {
view.showProgress(false);
Expand Down

0 comments on commit 74f8c13

Please sign in to comment.