From 6417a6ebd435cd580a4e43a9fcde7b7463635929 Mon Sep 17 00:00:00 2001 From: Obi1Kennoby Date: Thu, 15 Aug 2019 15:56:20 +0300 Subject: [PATCH] check permission before startCropping. Fix of #957 --- .../ivpusic/imagepicker/PickerModule.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java index 2904cf467..676753991 100644 --- a/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java +++ b/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java @@ -396,8 +396,14 @@ public void openCropper(final ReadableMap options, final Promise promise) { setConfiguration(options); resultCollector.setup(promise, false); - Uri uri = Uri.parse(options.getString("path")); - startCropping(activity, uri); + final Uri uri = Uri.parse(options.getString("path")); + permissionsCheck(activity, promise, Collections.singletonList(Manifest.permission.WRITE_EXTERNAL_STORAGE), new Callable() { + @Override + public Void call() { + startCropping(activity, uri); + return null; + } + }); } private String getBase64StringFromFile(String absoluteFilePath) { @@ -614,7 +620,7 @@ private void configureCropperColors(UCrop.Options options) { } } - private void startCropping(Activity activity, Uri uri) { + private void startCropping(final Activity activity, final Uri uri) { UCrop.Options options = new UCrop.Options(); options.setCompressionFormat(Bitmap.CompressFormat.JPEG); options.setCompressionQuality(100);