Commit 6d386b34 authored by A. Wilcox's avatar A. Wilcox

Merge branch 'ShareToPinterest'

parents c186452e 64b80c8b
......@@ -45,6 +45,7 @@ extern const char *site_names[3];
#define ACTIONSHEET_ACTIVEITEM 6
#define ACTIONSHEET_CONFIRM_ACT 7
#define ACTIONSHEET_CONFIRM_INA 8
#define ACTIONSHEET_SHARE 9
......@@ -1508,38 +1509,17 @@ extern const char *site_names[3];
}
case 2:
{
[[GANTracker sharedTracker] trackPageview:[NSString stringWithFormat:@"/item/tweet_%s",site_names[site->siteCode()]]
[[GANTracker sharedTracker] trackPageview:[NSString stringWithFormat:@"/item/share_%s",site_names[site->siteCode()]]
withError:nil];
Class<TweetViewControllerMethods> tweetClass = NSClassFromString(@"TWTweetComposeViewController");
if(tweetClass && [tweetClass canSendTweet])
{
UIViewController<TweetViewControllerMethods> *tweetView = [[tweetClass alloc] init];
[tweetView setInitialText:[NSString stringWithFormat:@"Check out this %s auction: %s",site_names[item->parent()->siteCode()],item->title()]];
[tweetView addURL:[NSURL URLWithString:[NSString stringWithFormat:@"%s",item->url()]]];
[self presentModalViewController:tweetView animated:YES];
[tweetView release];
} else {
UIViewController *vc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
vc.navigationItem.title = @"Tweet";
vc.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)] autorelease];
WTBackgroundNavigationController *navi = [[WTBackgroundNavigationController alloc] initWithRootViewController:vc];
[vc release];
char *url = URLEncode([[NSString stringWithFormat:@"Check out this auction on %s: %s", site_names[item->parent()->siteCode()], item->url()] UTF8String]);
UIWebView *descriptView = [[UIWebView alloc] initWithFrame:vc.view.bounds];
descriptView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[descriptView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://twitter.com/intent/tweet?text=%s",url]]]];
[descriptView setScalesPageToFit:YES];
free(url);
[vc.view addSubview:descriptView];
[descriptView release];
[self presentModalViewController:navi animated:YES];
[navi release];
}
return;
UIActionSheet *shareSheet = [[UIActionSheet alloc] initWithTitle:@"Share to…"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Twitter", (item->all_pictures().size() >= 1) ? @"Pinterest" : nil, nil];
[shareSheet setTag:ACTIONSHEET_SHARE];
[shareSheet showFromBarButtonItem:actionButton animated:YES];
[shareSheet release];
break;
}
case 3:
{
......@@ -1738,7 +1718,87 @@ extern const char *site_names[3];
}
}
break;
}
}
case ACTIONSHEET_SHARE:
{
switch(buttonIndex)
{
case 0: // Twitter
{
[[GANTracker sharedTracker] trackPageview:[NSString stringWithFormat:@"/item/share_%s/twitter",site_names[site->siteCode()]]
withError:nil];
Class<TweetViewControllerMethods> tweetClass = NSClassFromString(@"TWTweetComposeViewController");
if(tweetClass && [tweetClass canSendTweet])
{
UIViewController<TweetViewControllerMethods> *tweetView = [[tweetClass alloc] init];
[tweetView setInitialText:[NSString stringWithFormat:@"Check out this %s auction: %s",site_names[item->parent()->siteCode()],item->title()]];
[tweetView addURL:[NSURL URLWithString:[NSString stringWithFormat:@"%s",item->url()]]];
[self presentModalViewController:tweetView animated:YES];
[tweetView release];
} else {
UIViewController *vc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
vc.navigationItem.title = @"Tweet";
vc.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)] autorelease];
WTBackgroundNavigationController *navi = [[WTBackgroundNavigationController alloc] initWithRootViewController:vc];
[vc release];
char *url = URLEncode([[NSString stringWithFormat:@"Check out this auction on %s: %s", site_names[item->parent()->siteCode()], item->url()] UTF8String]);
UIWebView *descriptView = [[UIWebView alloc] initWithFrame:vc.view.bounds];
descriptView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[descriptView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://twitter.com/intent/tweet?text=%s",url]]]];
[descriptView setScalesPageToFit:YES];
free(url);
[vc.view addSubview:descriptView];
[descriptView release];
[self presentModalViewController:navi animated:YES];
[navi release];
}
break;
}
case 1: // Pinterest
{
if(item->all_pictures().size() < 1)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Pin Listing"
message:@"You can only pin listings that have pictures to Pinterest. Add a picture to this listing, and try sharing again." delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
[alert release];
break;
}
[[GANTracker sharedTracker] trackPageview:[NSString stringWithFormat:@"/item/share_%s/pin",site_names[site->siteCode()]]
withError:nil];
UIViewController *vc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
vc.navigationItem.title = @"Pin to Pinterest";
vc.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissModalViewControllerAnimated:)] autorelease];
WTBackgroundNavigationController *navi = [[WTBackgroundNavigationController alloc] initWithRootViewController:vc];
[vc release];
char *url = URLEncode(item->url());
char *pic = URLEncode(item->all_pictures().at(0));
UIWebView *descriptView = [[UIWebView alloc] initWithFrame:vc.view.bounds];
descriptView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[descriptView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://m.pinterest.com/pin/create/button/?url=%s&media=%s",url,pic]]]];
[descriptView setScalesPageToFit:YES];
free(pic);
free(url);
[vc.view addSubview:descriptView];
[descriptView release];
[self presentModalViewController:navi animated:YES];
[navi release];
break;
}
}
break;
}
}
}
......@@ -1775,7 +1835,7 @@ extern const char *site_names[3];
delegate:self
cancelButtonTitle:@"Close"
destructiveButtonTitle:((isMine ? ((site->siteCode() == SITE_EBAY) ? @"End Listing" : @"Delete/Deactivate") : nil))
otherButtonTitles:@"Open in Safari", @"Sell Similar Item", @"Tweet", @"Watch", nil];
otherButtonTitles:@"Open in Safari", @"Sell Similar Item", @"Share", @"Watch", nil];
[itemActions setTag:ACTIONSHEET_ACTIVEITEM];
}
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment