2012-07-22 14:23:50 -07:00
|
|
|
//
|
|
|
|
// FTUXAddNewsBlurViewController.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Roy Yang on 7/22/12.
|
|
|
|
// Copyright (c) 2012 NewsBlur. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "FirstTimeUserAddNewsBlurViewController.h"
|
2012-08-12 20:19:07 -07:00
|
|
|
#import "NewsBlurViewController.h"
|
2012-07-22 14:23:50 -07:00
|
|
|
|
|
|
|
@implementation FirstTimeUserAddNewsBlurViewController
|
|
|
|
|
|
|
|
@synthesize appDelegate;
|
|
|
|
@synthesize nextButton;
|
2012-08-12 18:50:32 -07:00
|
|
|
@synthesize instructionsLabel;
|
2012-07-22 14:23:50 -07:00
|
|
|
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
|
|
{
|
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
|
|
if (self) {
|
|
|
|
// Custom initialization
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2012-08-12 18:50:32 -07:00
|
|
|
- (void)viewDidLoad {
|
2012-07-22 14:23:50 -07:00
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view from its nib.
|
|
|
|
|
|
|
|
|
2016-10-05 21:03:32 -07:00
|
|
|
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Start reading" style:UIBarButtonItemStyleDone target:self action:@selector(tapNextButton)];
|
2012-07-22 14:23:50 -07:00
|
|
|
self.nextButton = next;
|
|
|
|
self.navigationItem.rightBarButtonItem = next;
|
|
|
|
|
2013-09-12 16:40:23 -07:00
|
|
|
self.navigationItem.title = @"All Done";
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidUnload
|
|
|
|
{
|
|
|
|
[self setNextButton:nil];
|
2012-08-12 18:50:32 -07:00
|
|
|
[self setInstructionsLabel:nil];
|
2012-07-22 14:23:50 -07:00
|
|
|
[super viewDidUnload];
|
|
|
|
// Release any retained subviews of the main view.
|
|
|
|
// e.g. self.myOutlet = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
2014-09-18 11:25:51 -07:00
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2012-08-14 17:20:45 -07:00
|
|
|
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
2014-09-18 11:25:51 -07:00
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
2013-09-12 16:40:23 -07:00
|
|
|
[self addSite:@"http://blog.newsblur.com/rss"];
|
|
|
|
[self addPopular];
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
2012-08-11 18:03:28 -07:00
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
|
|
// Return YES for supported orientations
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
return YES;
|
|
|
|
} else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO;
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (IBAction)tapNextButton {
|
2013-06-17 11:50:13 -07:00
|
|
|
[appDelegate.ftuxNavigationController dismissViewControllerAnimated:YES completion:nil];
|
2012-08-15 13:04:05 -07:00
|
|
|
[appDelegate.feedsViewController fetchFeedList:NO];
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)tapNewsBlurButton:(id)sender {
|
|
|
|
UIButton *button = (UIButton *)sender;
|
|
|
|
button.selected = YES;
|
|
|
|
button.userInteractionEnabled = NO;
|
2012-08-12 20:09:45 -07:00
|
|
|
|
|
|
|
UIImage *checkmark = [UIImage imageNamed:@"258-checkmark"];
|
|
|
|
UIImageView *checkmarkView = [[UIImageView alloc] initWithImage:checkmark];
|
|
|
|
checkmarkView.frame = CGRectMake(button.frame.origin.x + button.frame.size.width - 24,
|
|
|
|
button.frame.origin.y + 8,
|
|
|
|
16,
|
|
|
|
16);
|
|
|
|
[self.view addSubview:checkmarkView];
|
|
|
|
|
2012-08-12 21:46:47 -07:00
|
|
|
[self addSite:@"http://blog.newsblur.com/rss"];
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
2012-08-12 20:09:45 -07:00
|
|
|
- (IBAction)tapPopularButton:(id)sender {
|
|
|
|
UIButton *button = (UIButton *)sender;
|
|
|
|
button.selected = YES;
|
|
|
|
button.userInteractionEnabled = NO;
|
|
|
|
|
|
|
|
UIImage *checkmark = [UIImage imageNamed:@"258-checkmark"];
|
|
|
|
UIImageView *checkmarkView = [[UIImageView alloc] initWithImage:checkmark];
|
|
|
|
checkmarkView.frame = CGRectMake(button.frame.origin.x + button.frame.size.width - 24,
|
|
|
|
button.frame.origin.y + 8,
|
|
|
|
16,
|
|
|
|
16);
|
|
|
|
[self.view addSubview:checkmarkView];
|
|
|
|
[self addPopular];
|
|
|
|
}
|
|
|
|
|
2012-07-22 14:23:50 -07:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Add Site
|
|
|
|
|
2012-08-12 20:09:45 -07:00
|
|
|
- (void)addPopular {
|
2013-06-18 21:23:20 -04:00
|
|
|
NSString *urlString = [NSString stringWithFormat:@"%@/social/follow/",
|
2016-01-21 22:11:37 -08:00
|
|
|
self.appDelegate.url];
|
2017-03-19 18:15:36 -07:00
|
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
2012-08-12 20:09:45 -07:00
|
|
|
|
2017-03-19 12:09:49 -07:00
|
|
|
[params setObject:@"social:popular" forKey:@"user_id"];
|
2017-03-19 18:15:36 -07:00
|
|
|
|
2019-08-22 12:03:39 -07:00
|
|
|
[appDelegate POST:urlString parameters:params target:self success:@selector(finishAddSite:) failure:@selector(informError:)];
|
2012-08-12 20:09:45 -07:00
|
|
|
}
|
|
|
|
|
2012-07-22 14:23:50 -07:00
|
|
|
- (void)addSite:(NSString *)siteUrl {
|
2013-06-18 21:23:20 -04:00
|
|
|
NSString *urlString = [NSString stringWithFormat:@"%@/reader/add_url/",
|
2016-01-21 22:11:37 -08:00
|
|
|
self.appDelegate.url];
|
2017-03-19 18:15:36 -07:00
|
|
|
|
|
|
|
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
2017-03-19 12:09:49 -07:00
|
|
|
[params setObject:siteUrl forKey:@"url"];
|
|
|
|
[params setObject:@"true" forKey:@"auto_active"];
|
|
|
|
[params setObject:@"true" forKey:@"skip_fetch"];
|
2012-07-22 14:23:50 -07:00
|
|
|
|
2019-08-22 12:03:39 -07:00
|
|
|
[appDelegate POST:urlString parameters:params target:self success:@selector(finishAddSite:) failure:@selector(informError:)];
|
2012-08-12 18:50:32 -07:00
|
|
|
}
|
|
|
|
|
2017-03-19 18:15:36 -07:00
|
|
|
- (void)finishAddSite:(NSDictionary *)results {
|
2012-08-12 20:19:07 -07:00
|
|
|
NSLog(@"results are %@", results);
|
2012-07-22 14:23:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|