mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.3 KiB
Matlab
76 lines
2.3 KiB
Matlab
8 years ago
|
//
|
||
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "AttachmentSharing.h"
|
||
|
#import "TSAttachmentStream.h"
|
||
8 years ago
|
#import "UIUtil.h"
|
||
8 years ago
|
#import <SignalServiceKit/AppContext.h>
|
||
8 years ago
|
#import <SignalServiceKit/Threading.h>
|
||
8 years ago
|
|
||
|
@implementation AttachmentSharing
|
||
|
|
||
8 years ago
|
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream
|
||
|
{
|
||
8 years ago
|
OWSAssert(stream);
|
||
|
|
||
8 years ago
|
[self showShareUIForURL:stream.mediaURL];
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
+ (void)showShareUIForURL:(NSURL *)url
|
||
|
{
|
||
8 years ago
|
OWSAssert(url);
|
||
8 years ago
|
|
||
8 years ago
|
[AttachmentSharing showShareUIForActivityItems:@[
|
||
|
url,
|
||
|
]];
|
||
|
}
|
||
|
|
||
8 years ago
|
+ (void)showShareUIForText:(NSString *)text
|
||
|
{
|
||
|
OWSAssert(text);
|
||
8 years ago
|
|
||
8 years ago
|
[AttachmentSharing showShareUIForActivityItems:@[
|
||
8 years ago
|
text,
|
||
|
]];
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
+ (void)showShareUIForActivityItems:(NSArray *)activityItems
|
||
|
{
|
||
|
OWSAssert(activityItems);
|
||
|
|
||
|
DispatchMainThreadSafe(^{
|
||
|
UIActivityViewController *activityViewController =
|
||
|
[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:@[]];
|
||
|
|
||
|
[activityViewController setCompletionWithItemsHandler:^(UIActivityType __nullable activityType,
|
||
|
BOOL completed,
|
||
|
NSArray *__nullable returnedItems,
|
||
|
NSError *__nullable activityError) {
|
||
8 years ago
|
|
||
8 years ago
|
DDLogDebug(@"%@ applying signal appearence", self.logTag);
|
||
8 years ago
|
[UIUtil applySignalAppearence];
|
||
8 years ago
|
|
||
8 years ago
|
if (activityError) {
|
||
8 years ago
|
DDLogInfo(@"%@ Failed to share with activityError: %@", self.logTag, activityError);
|
||
8 years ago
|
} else if (completed) {
|
||
8 years ago
|
DDLogInfo(@"%@ Did share with activityType: %@", self.logTag, activityType);
|
||
8 years ago
|
}
|
||
|
}];
|
||
8 years ago
|
|
||
8 years ago
|
UIViewController *fromViewController = CurrentAppContext().frontmostViewController;
|
||
8 years ago
|
while (fromViewController.presentedViewController) {
|
||
|
fromViewController = fromViewController.presentedViewController;
|
||
8 years ago
|
}
|
||
8 years ago
|
OWSAssert(fromViewController);
|
||
|
[fromViewController presentViewController:activityViewController
|
||
|
animated:YES
|
||
|
completion:^{
|
||
8 years ago
|
DDLogDebug(@"%@ applying default system appearence", self.logTag);
|
||
8 years ago
|
[UIUtil applyDefaultSystemAppearence];
|
||
|
}];
|
||
|
});
|
||
|
}
|
||
|
|
||
8 years ago
|
@end
|