2023-12-30 06:42:18 +01:00
|
|
|
diff --git a/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/contracts/ImageLibraryContract.kt b/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/contracts/ImageLibraryContract.kt
|
2023-12-30 06:53:17 +01:00
|
|
|
index ff15c91..41aaf12 100644
|
2023-12-30 06:42:18 +01:00
|
|
|
--- a/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/contracts/ImageLibraryContract.kt
|
|
|
|
+++ b/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/contracts/ImageLibraryContract.kt
|
2023-12-30 06:53:17 +01:00
|
|
|
@@ -26,51 +26,26 @@ import java.io.Serializable
|
2023-12-30 06:42:18 +01:00
|
|
|
* @see [androidx.activity.result.contract.ActivityResultContracts.GetMultipleContents]
|
|
|
|
*/
|
|
|
|
internal class ImageLibraryContract(
|
|
|
|
- private val appContextProvider: AppContextProvider
|
|
|
|
+ private val appContextProvider: AppContextProvider,
|
|
|
|
) : AppContextActivityResultContract<ImageLibraryContractOptions, ImagePickerContractResult> {
|
|
|
|
private val contentResolver: ContentResolver
|
|
|
|
get() = appContextProvider.appContext.reactContext?.contentResolver
|
|
|
|
?: throw Exceptions.ReactContextLost()
|
|
|
|
|
|
|
|
override fun createIntent(context: Context, input: ImageLibraryContractOptions): Intent {
|
|
|
|
- val request = PickVisualMediaRequest.Builder()
|
|
|
|
- .setMediaType(
|
|
|
|
- when (input.options.mediaTypes) {
|
|
|
|
- MediaTypes.VIDEOS -> {
|
|
|
|
- PickVisualMedia.VideoOnly
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- MediaTypes.IMAGES -> {
|
|
|
|
- PickVisualMedia.ImageOnly
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- else -> {
|
|
|
|
- PickVisualMedia.ImageAndVideo
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
- .build()
|
|
|
|
+ val intent = Intent(Intent.ACTION_GET_CONTENT)
|
|
|
|
+ .addCategory(Intent.CATEGORY_OPENABLE)
|
|
|
|
+ .setType("image/*")
|
|
|
|
|
|
|
|
if (input.options.allowsMultipleSelection) {
|
2023-12-30 06:53:17 +01:00
|
|
|
- val selectionLimit = input.options.selectionLimit
|
|
|
|
-
|
|
|
|
- if (selectionLimit == 1) {
|
|
|
|
- // If multiple selection is allowed but the limit is 1, we should ignore
|
|
|
|
- // the multiple selection flag and just treat it as a single selection.
|
2023-12-30 06:42:18 +01:00
|
|
|
- return PickVisualMedia().createIntent(context, request)
|
2023-12-30 06:53:17 +01:00
|
|
|
+ if(input.options.selectionLimit == 1) {
|
|
|
|
+ return intent
|
2023-12-30 06:42:18 +01:00
|
|
|
}
|
|
|
|
|
2023-12-30 06:53:17 +01:00
|
|
|
- if (selectionLimit > 1) {
|
2023-12-30 06:42:18 +01:00
|
|
|
- return PickMultipleVisualMedia(selectionLimit).createIntent(context, request)
|
2023-12-30 06:53:17 +01:00
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // If the selection limit is 0, it is the same as unlimited selection.
|
|
|
|
- if (selectionLimit == UNLIMITED_SELECTION) {
|
2023-12-30 06:42:18 +01:00
|
|
|
- return PickMultipleVisualMedia().createIntent(context, request)
|
2023-12-30 06:53:17 +01:00
|
|
|
- }
|
|
|
|
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
2023-12-30 06:42:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- return PickVisualMedia().createIntent(context, request)
|
|
|
|
+ return intent
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun parseResult(input: ImageLibraryContractOptions, resultCode: Int, intent: Intent?) =
|