Skip to content

Commit

Permalink
Merge pull request #2 from nicorsm/master
Browse files Browse the repository at this point in the history
iOS 8 Compatibility and "Prefer Text"
  • Loading branch information
sascha committed Oct 19, 2014
2 parents 94bc6b6 + 47fdbb4 commit cd7a2fe
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions SSCWhatsAppActivity/SSCWhatsAppActivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ extern NSString * const SSCActivityTypePostToWhatsApp;

@interface SSCWhatsAppActivity : UIActivity

-(id)initWithPreferText:(BOOL)prefer;

@end
15 changes: 13 additions & 2 deletions SSCWhatsAppActivity/SSCWhatsAppActivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@ @interface SSCWhatsAppActivity () <UIDocumentInteractionControllerDelegate>
@property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;
@property (nonatomic, strong) NSMutableArray *stringsToShare;
@property (nonatomic, strong) UIImage *imageToShare;
@property BOOL preferText;

@end

@implementation SSCWhatsAppActivity

#pragma mark - Accessors

-(id)initWithPreferText:(BOOL)prefer{
self = [super init];
if(self){
self.preferText = prefer;
}
return self;
}

- (NSMutableArray *)stringsToShare {
if (!_stringsToShare) {
_stringsToShare = [NSMutableArray new];
Expand All @@ -43,8 +52,10 @@ - (NSString *)activityTitle {
- (UIImage *)activityImage {
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
return [UIImage imageNamed:@"SSCWhatsAppIcon-iOS6"];
} else {
} else if(floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1){
return [UIImage imageNamed:@"SSCWhatsAppIcon"];
}else {
return [UIImage imageNamed:@"SSCWhatsAppIcon-iOS8"];
}
}

Expand Down Expand Up @@ -88,7 +99,7 @@ - (void)prepareWithActivityItems:(NSArray *)activityItems {
}

- (void)performActivity {
if (self.imageToShare) {
if (self.imageToShare && !self.preferText) {
[self sendImageToDocumentInteractionController:self.imageToShare];
} else {
[self sendStringToWhatsApp:[self.stringsToShare componentsJoinedByString:@" "]];
Expand Down
Binary file added SSCWhatsAppActivity/SSCWhatsAppIcon-iOS8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SSCWhatsAppActivity/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SSCWhatsAppActivity/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions WhatsAppActivityDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
2B1F005D18B1014100242DE9 /* SSCWhatsAppIcon-iOS6.png in Resources */ = {isa = PBXBuildFile; fileRef = 2B1F005B18B1014000242DE9 /* SSCWhatsAppIcon-iOS6.png */; };
2B1F005E18B1014100242DE9 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 2B1F005C18B1014100242DE9 /* [email protected] */; };
2B7A0AD019B3458F008DF6A6 /* shareImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 2B7A0ACF19B3458F008DF6A6 /* shareImage.jpg */; };
7C73500219F01D1300C7F93C /* SSCWhatsAppIcon-iOS8.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C734FFF19F01D1300C7F93C /* SSCWhatsAppIcon-iOS8.png */; };
7C73500319F01D1300C7F93C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 7C73500019F01D1300C7F93C /* [email protected] */; };
7C73500419F01D1300C7F93C /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 7C73500119F01D1300C7F93C /* [email protected] */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -44,6 +47,9 @@
2B1F005B18B1014000242DE9 /* SSCWhatsAppIcon-iOS6.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "SSCWhatsAppIcon-iOS6.png"; path = "SSCWhatsAppActivity/SSCWhatsAppIcon-iOS6.png"; sourceTree = "<group>"; };
2B1F005C18B1014100242DE9 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "SSCWhatsAppActivity/[email protected]"; sourceTree = "<group>"; };
2B7A0ACF19B3458F008DF6A6 /* shareImage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = shareImage.jpg; sourceTree = "<group>"; };
7C734FFF19F01D1300C7F93C /* SSCWhatsAppIcon-iOS8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "SSCWhatsAppIcon-iOS8.png"; path = "SSCWhatsAppActivity/SSCWhatsAppIcon-iOS8.png"; sourceTree = "<group>"; };
7C73500019F01D1300C7F93C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "SSCWhatsAppActivity/[email protected]"; sourceTree = "<group>"; };
7C73500119F01D1300C7F93C /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "[email protected]"; path = "SSCWhatsAppActivity/[email protected]"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -122,6 +128,9 @@
2B1F005818B0FF9500242DE9 /* [email protected] */,
2B1F005B18B1014000242DE9 /* SSCWhatsAppIcon-iOS6.png */,
2B1F005C18B1014100242DE9 /* [email protected] */,
7C734FFF19F01D1300C7F93C /* SSCWhatsAppIcon-iOS8.png */,
7C73500019F01D1300C7F93C /* [email protected] */,
7C73500119F01D1300C7F93C /* [email protected] */,
);
name = SSCWhatsAppActivity;
path = ../../SSCWhatsAppActivity;
Expand Down Expand Up @@ -181,9 +190,12 @@
files = (
2B1F005E18B1014100242DE9 /* [email protected] in Resources */,
2B1F002B18B0FE1C00242DE9 /* InfoPlist.strings in Resources */,
7C73500319F01D1300C7F93C /* [email protected] in Resources */,
2B1F005D18B1014100242DE9 /* SSCWhatsAppIcon-iOS6.png in Resources */,
2B7A0AD019B3458F008DF6A6 /* shareImage.jpg in Resources */,
2B1F005A18B0FF9500242DE9 /* [email protected] in Resources */,
7C73500219F01D1300C7F93C /* SSCWhatsAppIcon-iOS8.png in Resources */,
7C73500419F01D1300C7F93C /* [email protected] in Resources */,
2B1F005918B0FF9500242DE9 /* SSCWhatsAppIcon.png in Resources */,
2B1F003318B0FE1C00242DE9 /* Images.xcassets in Resources */,
);
Expand Down

0 comments on commit cd7a2fe

Please sign in to comment.