Skip to content
This repository has been archived by the owner on Jul 27, 2020. It is now read-only.

Commit

Permalink
added localization support
Browse files Browse the repository at this point in the history
  • Loading branch information
iDay committed Jan 26, 2014
1 parent 2be8022 commit cbabcde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 81 deletions.
11 changes: 4 additions & 7 deletions WeixinActivity/WeixinActivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
// Copyright (c) 2014年 Johnny iDay. All rights reserved.
//

#ifndef WeixinActivity_WeixinActivity_h
#define WeixinActivity_WeixinActivity_h
#import <Foundation/Foundation.h>

#include "WeixinTimelineActivity.h"
#include "WeixinSessionActivity.h"

#endif
#import "WeixinTimelineActivity.h"
#import "WeixinSessionActivity.h"

@interface WeixinActivity : NSObject

@end
@end
76 changes: 2 additions & 74 deletions WeixinActivity/WeixinActivity.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,12 @@
// WeixinActivity.m
// WeixinActivity
//
// Created by Johnny iDay on 13-12-2.
// Copyright (c) 2013年 Johnny iDay. All rights reserved.
// Created by Johnny iDay on 14-1-26.
// Copyright (c) 2014年 Johnny iDay. All rights reserved.
//

#import "WeixinActivity.h"

@implementation WeixinActivity

+ (UIActivityCategory)activityCategory
{
return UIActivityCategoryShare;
}

- (NSString *)activityType
{
return NSStringFromClass([self class]);
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
for (id activityItem in activityItems) {
if ([activityItem isKindOfClass:[UIImage class]]) {
return YES;
}
if ([activityItem isKindOfClass:[NSURL class]]) {
return YES;
}
}
return NO;
}

- (void)prepareWithActivityItems:(NSArray *)activityItems
{
for (id activityItem in activityItems) {
if ([activityItem isKindOfClass:[UIImage class]]) {
image = activityItem;
}
if ([activityItem isKindOfClass:[NSURL class]]) {
url = activityItem;
}
if ([activityItem isKindOfClass:[NSString class]]) {
title = activityItem;
}
}
}

- (void)setThumbImage:(SendMessageToWXReq *)req
{
if (image) {
CGFloat width = 100.0f;
CGFloat height = image.size.height * 100.0f / image.size.width;
UIGraphicsBeginImageContext(CGSizeMake(width, height));
[image drawInRect:CGRectMake(0, 0, width, height)];
UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[req.message setThumbImage:scaledImage];
}
}

- (void)performActivity
{
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
req.scene = scene;
// req.bText = NO;
req.message = WXMediaMessage.message;
req.message.title = title;
[self setThumbImage:req];
if (url) {
WXWebpageObject *webObject = WXWebpageObject.object;
webObject.webpageUrl = [url absoluteString];
req.message.mediaObject = webObject;
} else if (image) {
WXImageObject *imageObject = WXImageObject.object;
imageObject.imageData = UIImageJPEGRepresentation(image, 1);
req.message.mediaObject = imageObject;
}
[WXApi sendReq:req];
[self activityDidFinish:YES];
}

@end

0 comments on commit cbabcde

Please sign in to comment.