Skip to content
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 @@ -110,6 +110,12 @@ public void setContent(@Nullable String setterArg) {
this.content = setterArg;
}

private @Nullable String subject;
public @Nullable String getSubject() { return subject; }
public void setSubject(@Nullable String setterArg) {
this.subject = setterArg;
}

private @Nullable String speakableGroupName;
public @Nullable String getSpeakableGroupName() { return speakableGroupName; }
public void setSpeakableGroupName(@Nullable String setterArg) {
Expand Down Expand Up @@ -150,6 +156,11 @@ public static final class Builder {
this.content = setterArg;
return this;
}
private @Nullable String subject;
public @NonNull Builder setSubject(@Nullable String setterArg) {
this.subject = setterArg;
return this;
}
private @Nullable String speakableGroupName;
public @NonNull Builder setSpeakableGroupName(@Nullable String setterArg) {
this.speakableGroupName = setterArg;
Expand All @@ -175,6 +186,7 @@ public static final class Builder {
pigeonReturn.setAttachments(attachments);
pigeonReturn.setConversationIdentifier(conversationIdentifier);
pigeonReturn.setContent(content);
pigeonReturn.setSubject(subject);
pigeonReturn.setSpeakableGroupName(speakableGroupName);
pigeonReturn.setServiceName(serviceName);
pigeonReturn.setSenderIdentifier(senderIdentifier);
Expand All @@ -191,6 +203,7 @@ public static final class Builder {
toMapResult.put("attachments", list.isEmpty() ? null : list);
toMapResult.put("conversationIdentifier", conversationIdentifier);
toMapResult.put("content", content);
toMapResult.put("subject", subject);
toMapResult.put("speakableGroupName", speakableGroupName);
toMapResult.put("serviceName", serviceName);
toMapResult.put("senderIdentifier", senderIdentifier);
Expand All @@ -209,6 +222,8 @@ public static final class Builder {
pigeonResult.setConversationIdentifier((String)conversationIdentifier);
Object content = map.get("content");
pigeonResult.setContent((String)content);
Object subject = map.get("subject");
pigeonResult.setSubject((String)subject);
Object speakableGroupName = map.get("speakableGroupName");
pigeonResult.setSpeakableGroupName((String)speakableGroupName);
Object serviceName = map.get("serviceName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ class ShareHandlerPlugin : FlutterPlugin, Messages.ShareHandlerApi, EventChannel
else -> null
}

val subject: String? = when (intent.action) {
Intent.ACTION_SEND, Intent.ACTION_SEND_MULTIPLE -> intent.getStringExtra(Intent.EXTRA_SUBJECT)
else -> null
}

val conversationIdentifier = intent.getStringExtra("android.intent.extra.shortcut.ID")
?: intent.getStringExtra("conversationIdentifier")

if (attachments != null || text != null || conversationIdentifier != null) {
val mediaBuilder = Messages.SharedMedia.Builder()
attachments?.let { mediaBuilder.setAttachments(it) }
text?.let { mediaBuilder.setContent(it) }
subject?.let { mediaBuilder.setSubject(it) }
conversationIdentifier?.let { mediaBuilder.setConversationIdentifier(it) }
val media = mediaBuilder.build()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ open class ShareHandlerIosViewController: UIViewController {

}
}
redirectToHostApp()
redirectToHostApp(content: content)
}
}

Expand Down Expand Up @@ -249,7 +249,7 @@ open class ShareHandlerIosViewController: UIViewController {
extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
}

public func redirectToHostApp() {
public func redirectToHostApp(content: NSExtensionItem) {
// ids may not loaded yet so we need loadIds here too
loadIds();
let url = URL(string: "ShareMedia-\(ShareHandlerIosViewController.hostAppBundleIdentifier)://\(ShareHandlerIosViewController.hostAppBundleIdentifier)?key=\(sharedKey)")
Expand All @@ -262,8 +262,9 @@ open class ShareHandlerIosViewController: UIViewController {
let sender = intent?.sender
let serviceName = intent?.serviceName
let speakableGroupName = intent?.speakableGroupName
let subject = content.userInfo?[NSItemProvider.ItemKey.title] as? String

let sharedMedia = SharedMedia.init(attachments: sharedAttachments, conversationIdentifier: conversationIdentifier, content: sharedText.joined(separator: "\n"), speakableGroupName: speakableGroupName?.spokenPhrase, serviceName: serviceName, senderIdentifier: sender?.contactIdentifier ?? sender?.customIdentifier, imageFilePath: nil)
let sharedMedia = SharedMedia.init(attachments: sharedAttachments, conversationIdentifier: conversationIdentifier, content: sharedText.joined(separator: "\n"), subject: subject, speakableGroupName: speakableGroupName?.spokenPhrase, serviceName: serviceName, senderIdentifier: sender?.contactIdentifier ?? sender?.customIdentifier, imageFilePath: nil)

let json = sharedMedia.toJson()

Expand Down
10 changes: 6 additions & 4 deletions share_handler_ios/ios/Models/Classes/SharedModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ open class SharedMedia: Codable {
public var attachments: [SharedAttachment]?
public var conversationIdentifier: String?
public var content: String?
public var subject: String?
public var speakableGroupName: String?
public var serviceName: String?
public var senderIdentifier: String?
public var imageFilePath: String?

public init(attachments: [SharedAttachment]?, conversationIdentifier: String?, content: String?, speakableGroupName: String?, serviceName: String?, senderIdentifier: String?, imageFilePath: String?) {
public init(attachments: [SharedAttachment]?, conversationIdentifier: String?, content: String?, subject: String?, speakableGroupName: String?, serviceName: String?, senderIdentifier: String?, imageFilePath: String?) {
self.attachments = attachments
self.conversationIdentifier = conversationIdentifier
self.content = content
self.subject = subject
self.speakableGroupName = speakableGroupName
self.serviceName = serviceName
self.senderIdentifier = senderIdentifier
Expand All @@ -48,7 +50,7 @@ open class SharedMedia: Codable {

public class func fromMap(map: Dictionary<String, Any?>?) -> SharedMedia? {
if let _map = map {
return SharedMedia(attachments: (_map["attachments"] as? Array<Dictionary<String,Any>>)?.compactMap{ SharedAttachment.fromMap(map: $0)}, conversationIdentifier: _map["conversationIdentifier"] as? String, content: _map["content"] as? String, speakableGroupName: _map["speakableGroupName"] as? String, serviceName: _map["serviceName"]as? String, senderIdentifier: _map["senderIdentifier"] as? String, imageFilePath: _map["imageFilePath"] as? String)
return SharedMedia(attachments: (_map["attachments"] as? Array<Dictionary<String,Any>>)?.compactMap{ SharedAttachment.fromMap(map: $0)}, conversationIdentifier: _map["conversationIdentifier"] as? String, content: _map["content"] as? String, subject: _map["subject"] as? String, speakableGroupName: _map["speakableGroupName"] as? String, serviceName: _map["serviceName"]as? String, senderIdentifier: _map["senderIdentifier"] as? String, imageFilePath: _map["imageFilePath"] as? String)
} else {
return nil
}
Expand All @@ -58,14 +60,14 @@ open class SharedMedia: Codable {
if let _json = data {
let map = try? JSONSerialization.jsonObject(with: _json) as? Dictionary<String,Any>
if let _map = map {
return SharedMedia(attachments: (_map["attachments"] as? Array<Dictionary<String,Any>>)?.map{ SharedAttachment(path: $0["path"] as! String, type: SharedAttachmentType(rawValue: $0["type"] as! Int? ?? SharedAttachmentType.file.rawValue) ?? SharedAttachmentType.file )}, conversationIdentifier: _map["conversationIdentifier"] as? String, content: _map["content"] as? String, speakableGroupName: _map["speakableGroupName"] as? String, serviceName: _map["serviceName"]as? String, senderIdentifier: _map["senderIdentifier"] as? String, imageFilePath: _map["imageFilePath"] as? String)
return SharedMedia(attachments: (_map["attachments"] as? Array<Dictionary<String,Any>>)?.map{ SharedAttachment(path: $0["path"] as! String, type: SharedAttachmentType(rawValue: $0["type"] as! Int? ?? SharedAttachmentType.file.rawValue) ?? SharedAttachmentType.file )}, conversationIdentifier: _map["conversationIdentifier"] as? String, content: _map["content"] as? String, subject: _map["subject"] as? String, speakableGroupName: _map["speakableGroupName"] as? String, serviceName: _map["serviceName"]as? String, senderIdentifier: _map["senderIdentifier"] as? String, imageFilePath: _map["imageFilePath"] as? String)
}
}
return nil
}

public func toDictionary() -> Dictionary<String, Any?> {
return ["attachments": attachments?.map {$0.toDictionary()}, "conversationIdentifier": conversationIdentifier, "content": content, "speakableGroupName": speakableGroupName, "serviceName": serviceName, "senderIdentifier": senderIdentifier, "imageFilePath": imageFilePath]
return ["attachments": attachments?.map {$0.toDictionary()}, "conversationIdentifier": conversationIdentifier, "content": content, "subject": subject, "speakableGroupName": speakableGroupName, "serviceName": serviceName, "senderIdentifier": senderIdentifier, "imageFilePath": imageFilePath]
}

public func toJson() -> Data {
Expand Down
6 changes: 6 additions & 0 deletions share_handler_platform_interface/lib/src/data/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SharedMedia {
this.recipientIdentifiers,
this.conversationIdentifier,
this.content,
this.subject,
this.speakableGroupName,
this.serviceName,
this.senderIdentifier,
Expand All @@ -68,6 +69,9 @@ class SharedMedia {
/// Text content that was shared if any. Could be a url as well.
String? content;

/// The subject of the shared content.
String? subject;

/// The name of the recipient the content was shared to if specified.
String? speakableGroupName;

Expand All @@ -86,6 +90,7 @@ class SharedMedia {
pigeonMap['recipientIdentifiers'] = recipientIdentifiers;
pigeonMap['conversationIdentifier'] = conversationIdentifier;
pigeonMap['content'] = content;
pigeonMap['subject'] = subject;
pigeonMap['speakableGroupName'] = speakableGroupName;
pigeonMap['serviceName'] = serviceName;
pigeonMap['senderIdentifier'] = senderIdentifier;
Expand All @@ -103,6 +108,7 @@ class SharedMedia {
recipientIdentifiers: (pigeonMap['recipientIdentifiers'] as List<Object?>?)?.cast<String?>(),
conversationIdentifier: pigeonMap['conversationIdentifier'] as String?,
content: pigeonMap['content'] as String?,
subject: pigeonMap['subject'] as String?,
speakableGroupName: pigeonMap['speakableGroupName'] as String?,
serviceName: pigeonMap['serviceName'] as String?,
senderIdentifier: pigeonMap['senderIdentifier'] as String?,
Expand Down