adding google reader import logic to FTUX

This commit is contained in:
Roy Yang 2012-08-11 15:16:35 -07:00
parent 5b64858ef5
commit c8c7ba982a
9 changed files with 1516 additions and 25 deletions

View file

@ -59,7 +59,7 @@
if ([URLString isEqualToString:[NSString stringWithFormat:@"http://%@/", NEWSBLUR_URL]]) { if ([URLString isEqualToString:[NSString stringWithFormat:@"http://%@/", NEWSBLUR_URL]]) {
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
if ([type isEqualToString:@"google"]) { if ([type isEqualToString:@"google"]) {
[appDelegate.firstTimeUserAddSitesViewController selectGoogleReaderButton]; [appDelegate.firstTimeUserAddSitesViewController importFromGoogleReader];
} else if ([type isEqualToString:@"facebook"]) { } else if ([type isEqualToString:@"facebook"]) {
[appDelegate.firstTimeUserAddFriendsViewController selectFacebookButton]; [appDelegate.firstTimeUserAddFriendsViewController selectFacebookButton];
} else if ([type isEqualToString:@"twitter"]) { } else if ([type isEqualToString:@"twitter"]) {

View file

@ -17,12 +17,14 @@
@property (nonatomic) NSMutableArray *categories; @property (nonatomic) NSMutableArray *categories;
@property (nonatomic) IBOutlet UIButton *googleReaderButton; @property (nonatomic) IBOutlet UIButton *googleReaderButton;
@property (nonatomic) IBOutlet UIBarButtonItem *nextButton; @property (nonatomic) IBOutlet UIBarButtonItem *nextButton;
@property (nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (nonatomic) IBOutlet UILabel *instructionLabel;
- (IBAction)tapNextButton; - (IBAction)tapNextButton;
- (IBAction)tapGoogleReaderButton; - (IBAction)tapGoogleReaderButton;
- (IBAction)tapCategoryButton:(id)sender; - (IBAction)tapCategoryButton:(id)sender;
- (void)addCategories; - (void)addCategories;
- (void)selectGoogleReaderButton; - (void)importFromGoogleReader;
- (void)updateSites;
@end @end

View file

@ -6,16 +6,27 @@
// Copyright (c) 2012 NewsBlur. All rights reserved. // Copyright (c) 2012 NewsBlur. All rights reserved.
// //
#import "NewsBlurAppDelegate.h"
#import "FirstTimeUserAddSitesViewController.h" #import "FirstTimeUserAddSitesViewController.h"
#import "FirstTimeUserAddFriendsViewController.h" #import "FirstTimeUserAddFriendsViewController.h"
#import "AuthorizeServicesViewController.h" #import "AuthorizeServicesViewController.h"
#import "NewsBlurViewController.h"
@interface FirstTimeUserAddSitesViewController()
@property (readwrite) int importedFeedCount_;
@end;
@implementation FirstTimeUserAddSitesViewController @implementation FirstTimeUserAddSitesViewController
@synthesize appDelegate; @synthesize appDelegate;
@synthesize googleReaderButton; @synthesize googleReaderButton;
@synthesize nextButton; @synthesize nextButton;
@synthesize activityIndicator;
@synthesize instructionLabel;
@synthesize categories; @synthesize categories;
@synthesize importedFeedCount_;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{ {
@ -35,16 +46,19 @@
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonSystemItemDone target:self action:@selector(tapNextButton)]; UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonSystemItemDone target:self action:@selector(tapNextButton)];
self.nextButton = next; self.nextButton = next;
// self.nextButton.enabled = NO; self.nextButton.enabled = NO;
self.navigationItem.rightBarButtonItem = next; self.navigationItem.rightBarButtonItem = next;
self.navigationItem.title = @"Step 2 of 4"; self.navigationItem.title = @"Step 2 of 4";
self.activityIndicator.hidesWhenStopped = YES;
} }
- (void)viewDidUnload - (void)viewDidUnload
{ {
[self setActivityIndicator:nil];
[self setInstructionLabel:nil];
[super viewDidUnload]; [super viewDidUnload];
// Release any retained subviews of the main view. // Release any retained subviews of the main view.
// e.g. self.myOutlet = nil; // e.g. self.myOutlet = nil;
@ -75,9 +89,46 @@
[appDelegate.ftuxNavigationController pushViewController:service animated:YES]; [appDelegate.ftuxNavigationController pushViewController:service animated:YES];
} }
- (void)selectGoogleReaderButton { - (void)importFromGoogleReader {
self.googleReaderButton.selected = YES; self.nextButton.enabled = YES;
[self.googleReaderButton setTitle:@"Importing..." forState:UIControlStateNormal];
self.googleReaderButton.userInteractionEnabled = NO; self.googleReaderButton.userInteractionEnabled = NO;
self.instructionLabel.text = @"This might take a minute. Feel free to continue and we'll let you know when we finish importing";
[self.activityIndicator startAnimating];
NSString *urlString = [NSString stringWithFormat:@"http://%@/import/import_from_google_reader/",
NEWSBLUR_URL];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"true" forKey:@"auto_active"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(finishImportFromGoogleReader:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request startAsynchronous];
}
- (void)finishImportFromGoogleReader:(ASIHTTPRequest *)request {
NSString *responseString = [request responseString];
NSData *responseData=[responseString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSDictionary *results = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSLog(@"results are %@", results);
self.importedFeedCount_ = [[results objectForKey:@"feed_count"] intValue];
[self performSelector:@selector(updateSites) withObject:nil afterDelay:1];
}
- (void)updateSites {
self.instructionLabel.text = @"And just like that, we're done! Time to see what your friends are sharing.";
[appDelegate.feedsViewController fetchFeedList:NO];
NSString *msg = [NSString stringWithFormat:@"Imported %i site%@",
self.importedFeedCount_,
self.importedFeedCount_ == 1 ? @"" : @"s"];
[self.googleReaderButton setTitle:msg forState:UIControlStateSelected];
self.googleReaderButton.selected = YES;
[self.activityIndicator stopAnimating];
} }
#pragma mark - #pragma mark -

File diff suppressed because it is too large Load diff

View file

@ -284,7 +284,7 @@
[self.passwordInput setText:@""]; [self.passwordInput setText:@""];
[self.signUpPasswordInput setText:@""]; [self.signUpPasswordInput setText:@""];
[appDelegate showFirstTimeUser]; [appDelegate showFirstTimeUser];
// [appDelegate reloadFeedsView:YES]; [appDelegate reloadFeedsView:YES];
[self dismissModalViewControllerAnimated:NO]; [self dismissModalViewControllerAnimated:NO];
} }

View file

@ -133,7 +133,7 @@
[window makeKeyAndVisible]; [window makeKeyAndVisible];
[self.feedsViewController fetchFeedList:YES]; [self.feedsViewController fetchFeedList:YES];
[self showFirstTimeUser]; // [self showFirstTimeUser];
return YES; return YES;
} }

View file

@ -260,7 +260,7 @@
[request setDidFailSelector:@selector(finishedWithError:)]; [request setDidFailSelector:@selector(finishedWithError:)];
[request setTimeOutSeconds:30]; [request setTimeOutSeconds:30];
[request startAsynchronous]; [request startAsynchronous];
NSLog(@"urlFeedList is %@", urlFeedList);
self.lastUpdate = [NSDate date]; self.lastUpdate = [NSDate date];
} }
@ -289,6 +289,7 @@
options:kNilOptions options:kNilOptions
error:&error]; error:&error];
NSLog(@"results are %@", results);
[MBProgressHUD hideHUDForView:self.view animated:YES]; [MBProgressHUD hideHUDForView:self.view animated:YES];
self.stillVisibleFeeds = [NSMutableDictionary dictionary]; self.stillVisibleFeeds = [NSMutableDictionary dictionary];
self.visibleFeeds = [NSMutableDictionary dictionary]; self.visibleFeeds = [NSMutableDictionary dictionary];

View file

@ -15,7 +15,7 @@
// #define BACKGROUND_REFRESH_SECONDS -5 // #define BACKGROUND_REFRESH_SECONDS -5
#define BACKGROUND_REFRESH_SECONDS -10*60 #define BACKGROUND_REFRESH_SECONDS -10*60
#define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.host"] #define NEWSBLUR_URL [NSString stringWithFormat:@"nb.local.com"]
// #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"] // #define NEWSBLUR_URL [NSString stringWithFormat:@"www.newsblur.com"]
#define NEWSBLUR_LINK_COLOR 0x405BA8 #define NEWSBLUR_LINK_COLOR 0x405BA8

View file

@ -46,6 +46,7 @@
<int key="NSvFlags">292</int> <int key="NSvFlags">292</int>
<string key="NSFrameSize">{768, 1024}</string> <string key="NSFrameSize">{768, 1024}</string>
<reference key="NSSuperview"/> <reference key="NSSuperview"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor"> <object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int> <int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes> <bytes key="NSRGB">MSAxIDEAA</bytes>
@ -483,14 +484,6 @@
</object> </object>
<int key="connectionID">273</int> <int key="connectionID">273</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">firstTimeUserAddSitesViewController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="390171581"/>
</object>
<int key="connectionID">274</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection"> <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">firstTimeUserAddFriendsViewController</string> <string key="label">firstTimeUserAddFriendsViewController</string>
@ -507,6 +500,14 @@
</object> </object>
<int key="connectionID">276</int> <int key="connectionID">276</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">firstTimeUserAddSitesViewController</string>
<reference key="source" ref="664661524"/>
<reference key="destination" ref="390171581"/>
</object>
<int key="connectionID">277</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection"> <object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">appDelegate</string> <string key="label">appDelegate</string>
@ -1008,7 +1009,7 @@
<reference key="dict.values" ref="0"/> <reference key="dict.values" ref="0"/>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">276</int> <int key="maxID">277</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"/> <object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int> <int key="IBDocument.localizationMode">0</int>