Skip to content

Commit 4823a97

Browse files
Fix the issure in Android where the photo picker does not support a maxFiles selection limit. (#2147)
Co-authored-by: BruceWang <[email protected]>
1 parent 1b9081e commit 4823a97

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi
104104
private int width = 0;
105105
private int height = 0;
106106

107+
private int maxFiles = 5;
108+
107109
private Uri mCameraCaptureURI;
108110
private String mCurrentMediaPath;
109111
private ResultCollector resultCollector = new ResultCollector();
@@ -135,6 +137,7 @@ private void setConfiguration(final ReadableMap options) {
135137
includeExif = options.hasKey("includeExif") && options.getBoolean("includeExif");
136138
width = options.hasKey("width") ? options.getInt("width") : 0;
137139
height = options.hasKey("height") ? options.getInt("height") : 0;
140+
maxFiles = options.hasKey("maxFiles") ? options.getInt("maxFiles") : 0;
138141
cropping = options.hasKey("cropping") && options.getBoolean("cropping");
139142
cropperActiveWidgetColor = options.hasKey("cropperActiveWidgetColor") ? options.getString("cropperActiveWidgetColor") : null;
140143
cropperStatusBarColor = options.hasKey("cropperStatusBarColor") ? options.getString("cropperStatusBarColor") : null;
@@ -381,7 +384,7 @@ private void initiatePicker(final Activity activity) {
381384

382385
Intent intent;
383386
if (multiple) {
384-
intent = new ActivityResultContracts.PickMultipleVisualMedia().createIntent(activity, builder.build());
387+
intent = new ActivityResultContracts.PickMultipleVisualMedia(maxFiles).createIntent(activity, builder.build());
385388
} else {
386389
intent = new ActivityResultContracts.PickVisualMedia().createIntent(activity, builder.build());
387390
}

0 commit comments

Comments
 (0)