From 90f10dc691615aa59514bda1a84dd6cc55f6fec1 Mon Sep 17 00:00:00 2001 From: LazyDave76 Date: Thu, 25 Feb 2021 12:39:48 +0000 Subject: [PATCH 1/3] fix: sharing files on ios is broken --- ios/Classes/SwiftReceiveSharingIntentPlugin.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift index b4ccd8fb..c78bfdd2 100644 --- a/ios/Classes/SwiftReceiveSharingIntentPlugin.swift +++ b/ios/Classes/SwiftReceiveSharingIntentPlugin.swift @@ -149,7 +149,8 @@ public class SwiftReceiveSharingIntentPlugin: NSObject, FlutterPlugin, FlutterSt guard let path = getAbsolutePath(for: $0.path) else { return nil } - return SharedMediaFile.init(path: $0.path, thumbnail: nil, duration: nil, type: $0.type) + let pathWithoutPrefix = String($0.path.dropFirst(7))//knock 'file://' off here... + return SharedMediaFile.init(path: pathWithoutPrefix, thumbnail: nil, duration: nil, type: $0.type) } latestMedia = sharedMediaFiles if(setInitialData) { From 980c74a1193b48b64c9df8f3260829f2d595cdb2 Mon Sep 17 00:00:00 2001 From: LazyDave76 Date: Tue, 2 Feb 2021 16:53:42 +0000 Subject: [PATCH 2/3] fix kotlin build problem --- .../receive_sharing_intent/ReceiveSharingIntentPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 0d7bfa3a..329b24c6 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 @@ -143,7 +143,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl return when (intent.action) { Intent.ACTION_SEND -> { val uri = intent.getParcelableExtra(Intent.EXTRA_STREAM) - val path = FileDirectory.getAbsolutePath(applicationContext, uri) + val path = FileDirectory.getAbsolutePath(applicationContext, uri!!) if (path != null) { val type = getMediaType(path) val thumbnail = getThumbnail(path, type) @@ -204,7 +204,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl if (type != MediaType.VIDEO) return null // get duration for video only val retriever = MediaMetadataRetriever() retriever.setDataSource(path) - val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION).toLongOrNull() + val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)!!.toLongOrNull() retriever.release() return duration } From ebd6e26ac838675f85585b8c1a484c324713bdb2 Mon Sep 17 00:00:00 2001 From: proninyaroslav Date: Sun, 14 Mar 2021 10:55:32 +0300 Subject: [PATCH 3/3] Use '?' instead of '!!' --- .../receive_sharing_intent/ReceiveSharingIntentPlugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 329b24c6..21d2bbd0 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 @@ -143,7 +143,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl return when (intent.action) { Intent.ACTION_SEND -> { val uri = intent.getParcelableExtra(Intent.EXTRA_STREAM) - val path = FileDirectory.getAbsolutePath(applicationContext, uri!!) + val path = uri?.let{ FileDirectory.getAbsolutePath(applicationContext, it) } if (path != null) { val type = getMediaType(path) val thumbnail = getThumbnail(path, type) @@ -204,7 +204,7 @@ class ReceiveSharingIntentPlugin : FlutterPlugin, ActivityAware, MethodCallHandl if (type != MediaType.VIDEO) return null // get duration for video only val retriever = MediaMetadataRetriever() retriever.setDataSource(path) - val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)!!.toLongOrNull() + val duration = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLongOrNull() retriever.release() return duration }