From aa5d0a1f6bea1f81b3a7089bc0a4e2a6a1ace064 Mon Sep 17 00:00:00 2001 From: Veronika Laskova Date: Fri, 5 Apr 2024 14:51:06 +1300 Subject: [PATCH] fix differentiating between text and text files --- .../receive_sharing_intent/ReceiveSharingIntentPlugin.kt | 5 +++-- ios/Classes/SwiftReceiveSharingIntentPlugin.swift | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt index bea215fd..fd065a28 100644 --- a/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt +++ b/android/src/main/kotlin/com/kasem/receive_sharing_intent/ReceiveSharingIntentPlugin.kt @@ -139,7 +139,8 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl // content can only be uri or string private fun toJsonObject(uri: Uri?, text: String?, mimeType: String?): JSONObject? { val path = uri?.let { FileDirectory.getAbsolutePath(applicationContext, it) } - val mType = mimeType ?: path?.let { URLConnection.guessContentTypeFromName(path) } + val specifiedMimeType = text?.let { "text" } ?: mimeType + val mType = specifiedMimeType ?: path?.let { URLConnection.guessContentTypeFromName(path) } val type = MediaType.fromMimeType(mType) val (thumbnail, duration) = path?.let { getThumbnailAndDuration(path, type) } ?: Pair(null, null) @@ -176,7 +177,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl return when { mimeType?.startsWith("image") == true -> IMAGE mimeType?.startsWith("video") == true -> VIDEO - mimeType?.startsWith("text") == true -> TEXT + mimeType?.equals("text") == true -> TEXT else -> FILE } } diff --git a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift index 318ce2ae..f8bcfeaf 100644 --- a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift +++ b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift @@ -231,9 +231,9 @@ public class SharedMediaFile: Codable { public enum SharedMediaType: String, Codable, CaseIterable { case image case video + case file case text // case audio - case file case url public var toUTTypeIdentifier: String {