ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.16k stars 1.56k forks source link

openPicker opens file manager on Xiaomi phones #1732

Open AuroPick opened 2 years ago

AuroPick commented 2 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

Expected behaviour

It should open gallery

Actual behaviour

It opens file manager on xiaomi phones. It used to work but now it doesn't.

I have tried on Xiaomi Redmi Note 10 S and Xiaomi Mi 11 Lite.

Steps to reproduce

  1. Click button

  2. Call openPicker

  3. Opens file manager

Attachments

WhatsApp Image 2022-02-03 at 15 37 55

AuroPick commented 2 years ago

Where is the maintainers?

riorafe commented 2 years ago

I can confirm that I got the same problem too with Xiaomi devices.

ravi-roxiler commented 2 years ago

Facing the same issue is anyone working on this or resolved this issue??

AuroPick commented 2 years ago

No.

ravi-roxiler commented 2 years ago

@AuroPick do you know how to open Gallery view instead of File Explorer on other devices?

AuroPick commented 2 years ago

No I don't know.

frozencap commented 2 years ago

Bump

frozencap commented 2 years ago

@AuroPick @ravi-roxiler @riorafe did you guys manage to fix this ?

fabio-C commented 2 years ago

Same problem here. I have a Redmi Note 10S. Anoyone found a solution?

frozencap commented 2 years ago

Not yet. Pretty massive issue considering Xiaomi is #2 smartphone maker and has like 20% smartphone market share

adityak16 commented 2 years ago

Did anyone find the solution?

Gabotron-ES commented 1 year ago

Baffling that there is no fix for this yet, I'll have to use react-native-image-picker instead

AuroPick commented 1 year ago

Baffling that there is no fix for this yet, I'll have to use react-native-image-picker instead

try this patch

react-native-image-crop-picker+0.37.3.patch

diff --git a/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml b/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
index d9b32ba..c356fde 100644
--- a/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
+++ b/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
@@ -12,13 +12,13 @@
     <application>

         <provider
-            android:name="androidx.core.content.FileProvider"
+            android:name=".IvpusicImagePickerFileProvider"
             android:authorities="${applicationId}.provider"
             android:exported="false"
             android:grantUriPermissions="true">
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
-                android:resource="@xml/provider_paths" />
+                android:resource="@xml/ivpusic_imagepicker_provider_paths" />
         </provider>

         <activity
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java
new file mode 100644
index 0000000..ca3bcf1
--- /dev/null
+++ b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java
@@ -0,0 +1,9 @@
+package com.reactnative.ivpusic.imagepicker;
+
+import androidx.core.content.FileProvider;
+
+/**
+ * A custom {@code FileProvider} prevents manifest {@code <provider>} name collisions.
+ */
+public class IvpusicImagePickerFileProvider extends FileProvider {
+}
\ No newline at end of file
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
index 6335949..aa89952 100644
--- a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
+++ b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
@@ -378,8 +378,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
             galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
             galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);

-            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image");
-            activity.startActivityForResult(chooserIntent, IMAGE_PICKER_REQUEST);
+            // final Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image");
+            activity.startActivityForResult(galleryIntent, IMAGE_PICKER_REQUEST);
         } catch (Exception e) {
             resultCollector.notifyProblem(E_FAILED_TO_SHOW_PICKER, e);
         }
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/res/xml/provider_paths.xml b/node_modules/react-native-image-crop-picker/android/src/main/res/xml/ivpusic_imagepicker_provider_paths.xml
similarity index 100%
rename from node_modules/react-native-image-crop-picker/android/src/main/res/xml/provider_paths.xml
rename to node_modules/react-native-image-crop-picker/android/src/main/res/xml/ivpusic_imagepicker_provider_paths.xml
TimeForRelax commented 1 week ago

Baffling that there is no fix for this yet, I'll have to use react-native-image-picker instead

try this patch

react-native-image-crop-picker+0.37.3.patch

diff --git a/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml b/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
index d9b32ba..c356fde 100644
--- a/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
+++ b/node_modules/react-native-image-crop-picker/android/src/main/AndroidManifest.xml
@@ -12,13 +12,13 @@
     <application>

         <provider
-            android:name="androidx.core.content.FileProvider"
+            android:name=".IvpusicImagePickerFileProvider"
             android:authorities="${applicationId}.provider"
             android:exported="false"
             android:grantUriPermissions="true">
             <meta-data
                 android:name="android.support.FILE_PROVIDER_PATHS"
-                android:resource="@xml/provider_paths" />
+                android:resource="@xml/ivpusic_imagepicker_provider_paths" />
         </provider>

         <activity
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java
new file mode 100644
index 0000000..ca3bcf1
--- /dev/null
+++ b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/IvpusicImagePickerFileProvider.java
@@ -0,0 +1,9 @@
+package com.reactnative.ivpusic.imagepicker;
+
+import androidx.core.content.FileProvider;
+
+/**
+ * A custom {@code FileProvider} prevents manifest {@code <provider>} name collisions.
+ */
+public class IvpusicImagePickerFileProvider extends FileProvider {
+}
\ No newline at end of file
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
index 6335949..aa89952 100644
--- a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
+++ b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java
@@ -378,8 +378,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
             galleryIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
             galleryIntent.addCategory(Intent.CATEGORY_OPENABLE);

-            final Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image");
-            activity.startActivityForResult(chooserIntent, IMAGE_PICKER_REQUEST);
+            // final Intent chooserIntent = Intent.createChooser(galleryIntent, "Pick an image");
+            activity.startActivityForResult(galleryIntent, IMAGE_PICKER_REQUEST);
         } catch (Exception e) {
             resultCollector.notifyProblem(E_FAILED_TO_SHOW_PICKER, e);
         }
diff --git a/node_modules/react-native-image-crop-picker/android/src/main/res/xml/provider_paths.xml b/node_modules/react-native-image-crop-picker/android/src/main/res/xml/ivpusic_imagepicker_provider_paths.xml
similarity index 100%
rename from node_modules/react-native-image-crop-picker/android/src/main/res/xml/provider_paths.xml
rename to node_modules/react-native-image-crop-picker/android/src/main/res/xml/ivpusic_imagepicker_provider_paths.xml

Thanks SOOOOOO much. It's help me with Redmi