mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Add module for file picker for camera and gallery uploads (#2375)
* Use easy image for image picker * Do not use harcoded mime type * Use uploadable file for image uploads * Add picker files in filepicker module * Remove redundant checks for file * Make usage of file extensions consistent * Add javadocs * Fix tests * Enable image upload using bookmark activity * Fix multiple uploads * Fix external image uploads * Fix chooser intents * Fix image quality checks * Segregate internal and external upload intents * Invoke all error messages from one place * Minor changes * Fix tests * Add image processing service tests
This commit is contained in:
parent
fb5a40bba5
commit
52ab39381e
39 changed files with 1553 additions and 574 deletions
|
|
@ -10,7 +10,6 @@ import android.net.Uri;
|
|||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.esafirm.imagepicker.model.Image;
|
||||
import com.facebook.common.executors.CallerThreadExecutor;
|
||||
import com.facebook.common.references.CloseableReference;
|
||||
import com.facebook.datasource.DataSource;
|
||||
|
|
@ -24,8 +23,6 @@ import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.location.LatLng;
|
||||
|
|
@ -37,9 +34,9 @@ import timber.log.Timber;
|
|||
|
||||
public class ImageUtils {
|
||||
|
||||
static final int IMAGE_DARK = 1;
|
||||
public static final int IMAGE_DARK = 1;
|
||||
static final int IMAGE_BLURRY = 1 << 1;
|
||||
public static final int IMAGE_DUPLICATE = 1 << 2;
|
||||
public static final int IMAGE_DUPLICATE = 1 << 2; //4
|
||||
public static final int IMAGE_GEOLOCATION_DIFFERENT = 1 << 3;
|
||||
public static final int IMAGE_OK = 0;
|
||||
public static final int IMAGE_KEEP = -1;
|
||||
|
|
@ -251,15 +248,4 @@ public class ImageUtils {
|
|||
|
||||
return errorMessage.toString();
|
||||
}
|
||||
|
||||
public static ArrayList<Uri> getUriListFromImages(List<Image> imageList) {
|
||||
ArrayList<Uri> uriList = new ArrayList<>();
|
||||
for (Image imagePath : imageList) {
|
||||
if (!StringUtils.isNullOrWhiteSpace(imagePath.getPath())) {
|
||||
uriList.add(Uri.parse(imagePath.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
return uriList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.BOOKMARK_CAMERA_UPLOAD_REQUEST_CODE;
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.BOOKMARK_GALLERY_UPLOAD_REQUEST_CODE;
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.CAMERA_UPLOAD_REQUEST_CODE;
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.GALLERY_UPLOAD_REQUEST_CODE;
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.NEARBY_CAMERA_UPLOAD_REQUEST_CODE;
|
||||
import static fr.free.nrw.commons.contributions.ContributionController.NEARBY_GALLERY_UPLOAD_REQUEST_CODE;
|
||||
|
||||
public class IntentUtils {
|
||||
|
||||
/**
|
||||
* Check if the intent should be handled by contributions list fragment
|
||||
*/
|
||||
public static boolean shouldContributionsHandle(int requestCode, int resultCode, Intent data) {
|
||||
return resultCode == Activity.RESULT_OK
|
||||
&& (requestCode == GALLERY_UPLOAD_REQUEST_CODE || requestCode == CAMERA_UPLOAD_REQUEST_CODE
|
||||
|| requestCode == NEARBY_CAMERA_UPLOAD_REQUEST_CODE || requestCode == NEARBY_GALLERY_UPLOAD_REQUEST_CODE)
|
||||
&& data != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the intent should be handled by contributions list fragment
|
||||
*/
|
||||
public static boolean shouldBookmarksHandle(int requestCode, int resultCode, Intent data) {
|
||||
return resultCode == Activity.RESULT_OK
|
||||
&& (requestCode == BOOKMARK_CAMERA_UPLOAD_REQUEST_CODE || requestCode == BOOKMARK_GALLERY_UPLOAD_REQUEST_CODE)
|
||||
&& data != null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue