(android) remove dependency on support-annotations

This commit is contained in:
Ivan Pusic 2017-10-24 12:05:47 +02:00
parent b47232befa
commit c44ce340e0
6 changed files with 25 additions and 29 deletions

View File

@ -18,5 +18,4 @@ dependencies {
compile 'com.facebook.react:react-native:+' compile 'com.facebook.react:react-native:+'
compile 'com.yalantis:ucrop:2.2.0-native' compile 'com.yalantis:ucrop:2.2.0-native'
compile 'id.zelory:compressor:2.1.0' compile 'id.zelory:compressor:2.1.0'
compile 'com.android.support:support-annotations:26.0.1'
} }

View File

@ -4,22 +4,20 @@ import android.app.Activity;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Environment; import android.os.Environment;
import android.util.Log; import android.util.Log;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import id.zelory.compressor.Compressor;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import id.zelory.compressor.Compressor;
/** /**
* Created by ipusic on 12/27/16. * Created by ipusic on 12/27/16.
*/ */
public class Compression { class Compression {
public File compressImage(final Activity activity, final ReadableMap options, final String originalImagePath) throws IOException { File compressImage(final Activity activity, final ReadableMap options, final String originalImagePath) throws IOException {
Integer maxWidth = options.hasKey("compressImageMaxWidth") ? options.getInt("compressImageMaxWidth") : null; Integer maxWidth = options.hasKey("compressImageMaxWidth") ? options.getInt("compressImageMaxWidth") : null;
Integer maxHeight = options.hasKey("compressImageMaxHeight") ? options.getInt("compressImageMaxHeight") : null; Integer maxHeight = options.hasKey("compressImageMaxHeight") ? options.getInt("compressImageMaxHeight") : null;
Double quality = options.hasKey("compressImageQuality") ? options.getDouble("compressImageQuality") : null; Double quality = options.hasKey("compressImageQuality") ? options.getDouble("compressImageQuality") : null;
@ -65,7 +63,7 @@ public class Compression {
.compressToFile(image, compressedFileName); .compressToFile(image, compressedFileName);
} }
public synchronized void compressVideo(final Activity activity, final ReadableMap options, final String originalVideo, final String compressedVideo, final Promise promise) { synchronized void compressVideo(final Activity activity, final ReadableMap options, final String originalVideo, final String compressedVideo, final Promise promise) {
// todo: video compression // todo: video compression
// failed attempt 1: ffmpeg => slow and licensing issues // failed attempt 1: ffmpeg => slow and licensing issues
promise.resolve(originalVideo); promise.resolve(originalVideo);

View File

@ -13,9 +13,9 @@ import java.util.List;
import static android.media.ExifInterface.*; import static android.media.ExifInterface.*;
public class ExifExtractor { class ExifExtractor {
public static WritableMap extract(String path) throws IOException { static WritableMap extract(String path) throws IOException {
WritableMap exifData = new WritableNativeMap(); WritableMap exifData = new WritableNativeMap();
List<String> attributes = getBasicAttributes(); List<String> attributes = getBasicAttributes();

View File

@ -1,18 +1,18 @@
package com.reactnative.ivpusic.imagepicker; package com.reactnative.ivpusic.imagepicker;
import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract; import android.provider.DocumentsContract;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.content.ContentUris;
import android.os.Environment;
import android.support.annotation.RequiresApi;
import java.io.File; import java.io.File;
public class RealPathUtil { class RealPathUtil {
public static String getRealPathFromURI(final Context context, final Uri uri) { static String getRealPathFromURI(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
@ -101,7 +101,7 @@ public class RealPathUtil {
* @param selectionArgs (Optional) Selection arguments used in the query. * @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path. * @return The value of the _data column, which is typically a file path.
*/ */
public static String getDataColumn(Context context, Uri uri, String selection, private static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) { String[] selectionArgs) {
Cursor cursor = null; Cursor cursor = null;
@ -129,7 +129,7 @@ public class RealPathUtil {
* @param uri The Uri to check. * @param uri The Uri to check.
* @return Whether the Uri authority is ExternalStorageProvider. * @return Whether the Uri authority is ExternalStorageProvider.
*/ */
public static boolean isExternalStorageDocument(Uri uri) { private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority()); return "com.android.externalstorage.documents".equals(uri.getAuthority());
} }
@ -137,7 +137,7 @@ public class RealPathUtil {
* @param uri The Uri to check. * @param uri The Uri to check.
* @return Whether the Uri authority is DownloadsProvider. * @return Whether the Uri authority is DownloadsProvider.
*/ */
public static boolean isDownloadsDocument(Uri uri) { private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority()); return "com.android.providers.downloads.documents".equals(uri.getAuthority());
} }
@ -145,7 +145,7 @@ public class RealPathUtil {
* @param uri The Uri to check. * @param uri The Uri to check.
* @return Whether the Uri authority is MediaProvider. * @return Whether the Uri authority is MediaProvider.
*/ */
public static boolean isMediaDocument(Uri uri) { private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority()); return "com.android.providers.media.documents".equals(uri.getAuthority());
} }
@ -153,12 +153,11 @@ public class RealPathUtil {
* @param uri The Uri to check. * @param uri The Uri to check.
* @return Whether the Uri authority is Google Photos. * @return Whether the Uri authority is Google Photos.
*/ */
public static boolean isGooglePhotosUri(Uri uri) { private static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority()); return "com.google.android.apps.photos.content".equals(uri.getAuthority());
} }
@RequiresApi(Build.VERSION_CODES.KITKAT) private static String getPathToNonPrimaryVolume(Context context, String tag) {
public static String getPathToNonPrimaryVolume(Context context, String tag) {
File[] volumes = context.getExternalCacheDirs(); File[] volumes = context.getExternalCacheDirs();
if (volumes != null) { if (volumes != null) {
for (File volume : volumes) { for (File volume : volumes) {

View File

@ -13,7 +13,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* Created by ipusic on 12/28/16. * Created by ipusic on 12/28/16.
*/ */
public class ResultCollector { class ResultCollector {
private Promise promise; private Promise promise;
private int waitCount; private int waitCount;
private boolean multiple; private boolean multiple;
@ -21,7 +21,7 @@ public class ResultCollector {
private WritableArray arrayResult; private WritableArray arrayResult;
private boolean resultSent = false; private boolean resultSent = false;
public ResultCollector(Promise promise, boolean multiple) { ResultCollector(Promise promise, boolean multiple) {
this.promise = promise; this.promise = promise;
this.multiple = multiple; this.multiple = multiple;
@ -32,12 +32,12 @@ public class ResultCollector {
// if user has provided "multiple" option, we will wait for X number of result to come, // if user has provided "multiple" option, we will wait for X number of result to come,
// and also return result as an array // and also return result as an array
public void setWaitCount(int waitCount) { void setWaitCount(int waitCount) {
this.waitCount = waitCount; this.waitCount = waitCount;
this.waitCounter = new AtomicInteger(0); this.waitCounter = new AtomicInteger(0);
} }
public synchronized void notifySuccess(WritableMap result) { synchronized void notifySuccess(WritableMap result) {
if (resultSent) { if (resultSent) {
Log.w("image-crop-picker", "Skipping result, already sent..."); Log.w("image-crop-picker", "Skipping result, already sent...");
} }
@ -56,7 +56,7 @@ public class ResultCollector {
} }
} }
public synchronized void notifyProblem(String code, String message) { synchronized void notifyProblem(String code, String message) {
if (resultSent) { if (resultSent) {
Log.w("image-crop-picker", "Skipping result, already sent..."); Log.w("image-crop-picker", "Skipping result, already sent...");
} }
@ -66,7 +66,7 @@ public class ResultCollector {
resultSent = true; resultSent = true;
} }
public synchronized void notifyProblem(String code, Throwable throwable) { synchronized void notifyProblem(String code, Throwable throwable) {
if (resultSent) { if (resultSent) {
Log.w("image-crop-picker", "Skipping result, already sent..."); Log.w("image-crop-picker", "Skipping result, already sent...");
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-image-crop-picker", "name": "react-native-image-crop-picker",
"version": "0.18.0", "version": "0.18.1",
"description": "Select single or multiple images, with cropping option", "description": "Select single or multiple images, with cropping option",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {