2014-01-06 17:55:14 -08:00
|
|
|
//
|
|
|
|
// OSKCopyToPasteboardActivity.m
|
|
|
|
// Overshare
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Copyright (c) 2013 Overshare Kit. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "OSKCopyToPasteboardActivity.h"
|
|
|
|
|
|
|
|
#import "OSKShareableContentItem.h"
|
|
|
|
|
|
|
|
@interface OSKCopyToPasteboardActivity ()
|
|
|
|
|
|
|
|
@property (strong, nonatomic, readonly) OSKCopyToPasteboardContentItem *pasteboardItem;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation OSKCopyToPasteboardActivity
|
|
|
|
|
|
|
|
- (instancetype)initWithContentItem:(OSKShareableContentItem *)item {
|
|
|
|
self = [super initWithContentItem:item];
|
|
|
|
if (self) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Methods for OSKActivity Subclasses
|
|
|
|
|
|
|
|
+ (NSString *)supportedContentItemType {
|
|
|
|
return OSKShareableContentItemType_CopyToPasteboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (BOOL)isAvailable {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSString *)activityType {
|
|
|
|
return OSKActivityType_iOS_CopyToPasteboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSString *)activityName {
|
|
|
|
return @"Copy";
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (UIImage *)iconForIdiom:(UIUserInterfaceIdiom)idiom {
|
|
|
|
UIImage *image = nil;
|
|
|
|
if (idiom == UIUserInterfaceIdiomPhone) {
|
|
|
|
image = [UIImage imageNamed:@"osk-copyIcon-yellow-60.png"];
|
|
|
|
} else {
|
|
|
|
image = [UIImage imageNamed:@"osk-copyIcon-yellow-76.png"];
|
|
|
|
}
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (OSKAuthenticationMethod)authenticationMethod {
|
|
|
|
return OSKAuthenticationMethod_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (BOOL)requiresApplicationCredential {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2014-02-27 16:54:25 -08:00
|
|
|
+ (OSKPublishingMethod)publishingMethod {
|
|
|
|
return OSKPublishingMethod_None;
|
2014-01-06 17:55:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isReadyToPerform {
|
2014-05-19 13:33:42 -07:00
|
|
|
return (self.pasteboardItem.text.length > 0 || self.pasteboardItem.images.count);
|
2014-01-06 17:55:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performActivity:(OSKActivityCompletionHandler)completion {
|
2014-05-19 13:33:42 -07:00
|
|
|
if (self.pasteboardItem.images.count) {
|
|
|
|
[[UIPasteboard generalPasteboard] setImages:self.pasteboardItem.images];
|
|
|
|
} else {
|
|
|
|
[[UIPasteboard generalPasteboard] setString:self.pasteboardItem.text];
|
|
|
|
}
|
2014-01-06 17:55:14 -08:00
|
|
|
if (completion) {
|
|
|
|
completion(self, YES, nil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (BOOL)canPerformViaOperation {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (OSKActivityOperation *)operationForActivityWithCompletion:(OSKActivityCompletionHandler)completion {
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Convenience
|
|
|
|
|
|
|
|
- (OSKCopyToPasteboardContentItem *)pasteboardItem {
|
|
|
|
return (OSKCopyToPasteboardContentItem *)self.contentItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|