From a6887f5fff1bcf9450937dd2d95e458351a8af66 Mon Sep 17 00:00:00 2001 From: at9 Date: Thu, 20 Jun 2019 18:41:51 +0100 Subject: [PATCH] Add custom FileProvider --- cropper/src/main/AndroidManifest.xml | 16 +++++++++++++--- .../theartofdev/edmodo/cropper/CropImage.java | 4 +++- .../edmodo/cropper/ImageCropperFileProvider.java | 10 ++++++++++ cropper/src/main/res/xml/provider_paths.xml | 4 ++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 cropper/src/main/java/com/theartofdev/edmodo/cropper/ImageCropperFileProvider.java create mode 100644 cropper/src/main/res/xml/provider_paths.xml diff --git a/cropper/src/main/AndroidManifest.xml b/cropper/src/main/AndroidManifest.xml index 674ba03a..17ffc46b 100644 --- a/cropper/src/main/AndroidManifest.xml +++ b/cropper/src/main/AndroidManifest.xml @@ -1,4 +1,14 @@ - - + + + + + + diff --git a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java index ba8b807b..0041da7f 100644 --- a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java +++ b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java @@ -44,6 +44,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; +import androidx.core.content.FileProvider; import androidx.fragment.app.Fragment; /** @@ -343,7 +344,8 @@ public static Uri getCaptureImageOutputUri(@NonNull Context context) { Uri outputFileUri = null; File getImage = context.getExternalCacheDir(); if (getImage != null) { - outputFileUri = Uri.fromFile(new File(getImage.getPath(), "pickImageResult.jpeg")); + File pickImageFile = new File(getImage.getPath(), "pickImageResult.jpeg"); + outputFileUri = FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", pickImageFile); } return outputFileUri; } diff --git a/cropper/src/main/java/com/theartofdev/edmodo/cropper/ImageCropperFileProvider.java b/cropper/src/main/java/com/theartofdev/edmodo/cropper/ImageCropperFileProvider.java new file mode 100644 index 00000000..4a739e05 --- /dev/null +++ b/cropper/src/main/java/com/theartofdev/edmodo/cropper/ImageCropperFileProvider.java @@ -0,0 +1,10 @@ +package com.theartofdev.edmodo.cropper; + +import androidx.core.content.FileProvider; + +/** + * Dummy file provider + */ +public class ImageCropperFileProvider extends FileProvider +{ +} diff --git a/cropper/src/main/res/xml/provider_paths.xml b/cropper/src/main/res/xml/provider_paths.xml new file mode 100644 index 00000000..9b94741c --- /dev/null +++ b/cropper/src/main/res/xml/provider_paths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file