Allow up to 10 images in share intent (#11132)
This commit is contained in:
@@ -3,6 +3,7 @@ import AVKit
|
|||||||
|
|
||||||
let IMAGE_EXTENSIONS: [String] = ["png", "jpg", "jpeg", "gif", "heic"]
|
let IMAGE_EXTENSIONS: [String] = ["png", "jpg", "jpeg", "gif", "heic"]
|
||||||
let MOVIE_EXTENSIONS: [String] = ["mov", "mp4", "m4v"]
|
let MOVIE_EXTENSIONS: [String] = ["mov", "mp4", "m4v"]
|
||||||
|
let MAX_IMAGES = 10
|
||||||
|
|
||||||
enum URLType: String, CaseIterable {
|
enum URLType: String, CaseIterable {
|
||||||
case image
|
case image
|
||||||
@@ -71,17 +72,12 @@ class ShareViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func handleImages(items: [NSItemProvider]) async {
|
private func handleImages(items: [NSItemProvider]) async {
|
||||||
let firstFourItems: [NSItemProvider]
|
let itemsToProcess = Array(items.prefix(MAX_IMAGES))
|
||||||
if items.count < 4 {
|
|
||||||
firstFourItems = items
|
|
||||||
} else {
|
|
||||||
firstFourItems = Array(items[0...3])
|
|
||||||
}
|
|
||||||
|
|
||||||
var valid = true
|
var valid = true
|
||||||
var imageUris = ""
|
var imageUris = ""
|
||||||
|
|
||||||
for (index, item) in firstFourItems.enumerated() {
|
for (index, item) in itemsToProcess.enumerated() {
|
||||||
var imageUriInfo: String?
|
var imageUriInfo: String?
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -100,7 +96,7 @@ class ShareViewController: UIViewController {
|
|||||||
|
|
||||||
if let imageUriInfo = imageUriInfo {
|
if let imageUriInfo = imageUriInfo {
|
||||||
imageUris.append(imageUriInfo)
|
imageUris.append(imageUriInfo)
|
||||||
if index < items.count - 1 {
|
if index < itemsToProcess.count - 1 {
|
||||||
imageUris.append(",")
|
imageUris.append(",")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-2
@@ -15,6 +15,7 @@ import java.io.FileOutputStream
|
|||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
|
|
||||||
private const val TAG = "ExpoReceiveAndroidIntents"
|
private const val TAG = "ExpoReceiveAndroidIntents"
|
||||||
|
private const val MAX_IMAGES = 10
|
||||||
|
|
||||||
enum class AttachmentType {
|
enum class AttachmentType {
|
||||||
IMAGE,
|
IMAGE,
|
||||||
@@ -100,12 +101,12 @@ class ExpoReceiveAndroidIntentsModule : Module() {
|
|||||||
intent
|
intent
|
||||||
.getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri::class.java)
|
.getParcelableArrayListExtra(Intent.EXTRA_STREAM, Uri::class.java)
|
||||||
?.filterIsInstance<Uri>()
|
?.filterIsInstance<Uri>()
|
||||||
?.take(4)
|
?.take(MAX_IMAGES)
|
||||||
} else {
|
} else {
|
||||||
intent
|
intent
|
||||||
.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
|
.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
|
||||||
?.filterIsInstance<Uri>()
|
?.filterIsInstance<Uri>()
|
||||||
?.take(4)
|
?.take(MAX_IMAGES)
|
||||||
}
|
}
|
||||||
|
|
||||||
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||||
|
|||||||
Reference in New Issue
Block a user