Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix differentiating between .txt files and text #288

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/SwiftReceiveSharingIntentPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down