2010-06-17 13:10:45 -04:00
|
|
|
//
|
|
|
|
// NewsBlurAppDelegate.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Samuel Clay on 6/16/10.
|
2010-06-21 17:17:26 -04:00
|
|
|
// Copyright NewsBlur 2010. All rights reserved.
|
2010-06-17 13:10:45 -04:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "NewsBlurAppDelegate.h"
|
2012-06-19 11:48:51 -07:00
|
|
|
#import "NewsBlurViewController.h"
|
2010-06-21 17:17:26 -04:00
|
|
|
#import "FeedDetailViewController.h"
|
2012-07-15 15:06:06 -07:00
|
|
|
#import "DashboardViewController.h"
|
2012-06-20 09:32:55 -07:00
|
|
|
#import "FeedDashboardViewController.h"
|
2012-06-19 10:55:46 -07:00
|
|
|
#import "FeedsMenuViewController.h"
|
2010-06-25 18:36:01 -04:00
|
|
|
#import "StoryDetailViewController.h"
|
2012-07-23 15:27:20 -07:00
|
|
|
#import "StoryDetailContainerViewController.h"
|
2012-06-13 18:07:24 -07:00
|
|
|
#import "FirstTimeUserViewController.h"
|
2012-07-01 12:08:30 -07:00
|
|
|
#import "FriendsListViewController.h"
|
2012-06-15 16:35:54 -07:00
|
|
|
#import "GoogleReaderViewController.h"
|
2010-10-31 23:02:13 -04:00
|
|
|
#import "LoginViewController.h"
|
2011-12-02 16:23:00 -08:00
|
|
|
#import "AddSiteViewController.h"
|
|
|
|
#import "MoveSiteViewController.h"
|
2012-06-27 21:28:04 -07:00
|
|
|
#import "MGSplitViewController.h"
|
2010-11-13 18:32:43 -05:00
|
|
|
#import "OriginalStoryViewController.h"
|
2012-06-21 11:53:48 -07:00
|
|
|
#import "ShareViewController.h"
|
2012-07-01 18:26:39 -07:00
|
|
|
#import "UserProfileViewController.h"
|
|
|
|
|
2011-10-27 09:44:58 -07:00
|
|
|
#import "MBProgressHUD.h"
|
2011-10-28 18:29:33 -07:00
|
|
|
#import "Utilities.h"
|
2011-12-04 21:09:16 -08:00
|
|
|
#import "StringHelper.h"
|
2010-06-17 13:10:45 -04:00
|
|
|
|
|
|
|
@implementation NewsBlurAppDelegate
|
|
|
|
|
|
|
|
@synthesize window;
|
2012-06-09 12:54:32 -07:00
|
|
|
|
2012-07-22 14:23:50 -07:00
|
|
|
@synthesize ftuxNavigationController;
|
2012-06-11 12:25:38 -07:00
|
|
|
@synthesize splitStoryController;
|
2010-06-21 17:17:26 -04:00
|
|
|
@synthesize navigationController;
|
2012-07-01 12:08:30 -07:00
|
|
|
@synthesize findFriendsNavigationController;
|
2012-06-11 16:56:38 -07:00
|
|
|
@synthesize splitStoryDetailNavigationController;
|
2012-06-15 16:35:54 -07:00
|
|
|
@synthesize googleReaderViewController;
|
2012-07-10 12:34:58 -07:00
|
|
|
@synthesize dashboardViewController;
|
2010-06-21 17:17:26 -04:00
|
|
|
@synthesize feedsViewController;
|
2012-06-19 10:55:46 -07:00
|
|
|
@synthesize feedsMenuViewController;
|
2010-06-24 12:53:50 -04:00
|
|
|
@synthesize feedDetailViewController;
|
2012-06-20 09:32:55 -07:00
|
|
|
@synthesize feedDashboardViewController;
|
2012-07-01 18:26:39 -07:00
|
|
|
@synthesize friendsListViewController;
|
2012-06-18 14:31:42 -07:00
|
|
|
@synthesize fontSettingsViewController;
|
2010-06-25 18:36:01 -04:00
|
|
|
@synthesize storyDetailViewController;
|
2012-07-23 15:27:20 -07:00
|
|
|
@synthesize storyDetailContainerViewController;
|
2012-06-22 18:01:08 -07:00
|
|
|
@synthesize shareViewController;
|
2010-10-31 23:02:13 -04:00
|
|
|
@synthesize loginViewController;
|
2011-12-02 16:23:00 -08:00
|
|
|
@synthesize addSiteViewController;
|
|
|
|
@synthesize moveSiteViewController;
|
2010-11-13 18:32:43 -05:00
|
|
|
@synthesize originalStoryViewController;
|
2012-07-01 18:26:39 -07:00
|
|
|
@synthesize userProfileViewController;
|
2010-06-17 13:10:45 -04:00
|
|
|
|
2012-07-22 14:23:50 -07:00
|
|
|
@synthesize firstTimeUserViewController;
|
|
|
|
@synthesize firstTimeUserAddSitesViewController;
|
|
|
|
@synthesize firstTimeUserAddFriendsViewController;
|
|
|
|
@synthesize firstTimeUserAddNewsBlurViewController;
|
|
|
|
|
2012-06-20 08:33:16 -07:00
|
|
|
@synthesize feedDetailPortraitYCoordinate;
|
2010-11-13 18:32:43 -05:00
|
|
|
@synthesize activeUsername;
|
2012-07-03 17:54:36 -07:00
|
|
|
@synthesize activeUserProfileId;
|
2011-10-25 09:28:05 -07:00
|
|
|
@synthesize isRiverView;
|
2012-06-26 11:45:42 -07:00
|
|
|
@synthesize isSocialView;
|
2012-06-29 23:48:47 -07:00
|
|
|
@synthesize isShowingShare;
|
2012-07-16 22:35:28 -07:00
|
|
|
@synthesize inFindingStoryMode;
|
2012-07-23 15:27:20 -07:00
|
|
|
@synthesize hasBottomStoryTitles;
|
2012-07-16 19:45:14 -07:00
|
|
|
@synthesize tryFeedStoryId;
|
2012-06-19 15:47:51 -07:00
|
|
|
@synthesize popoverHasFeedView;
|
2012-06-27 14:37:37 -07:00
|
|
|
@synthesize inStoryDetail;
|
2012-06-29 23:25:56 -07:00
|
|
|
@synthesize inFeedDetail;
|
2012-06-25 18:05:25 -07:00
|
|
|
@synthesize activeComment;
|
2010-06-25 18:36:01 -04:00
|
|
|
@synthesize activeFeed;
|
2011-10-20 09:32:39 -07:00
|
|
|
@synthesize activeFolder;
|
2011-10-26 08:40:31 -07:00
|
|
|
@synthesize activeFolderFeeds;
|
2010-06-25 18:36:01 -04:00
|
|
|
@synthesize activeFeedStories;
|
2011-07-29 21:27:37 -07:00
|
|
|
@synthesize activeFeedStoryLocations;
|
2011-08-08 09:58:15 -07:00
|
|
|
@synthesize activeFeedStoryLocationIds;
|
2012-06-22 18:01:08 -07:00
|
|
|
@synthesize activeFeedUserProfiles;
|
2010-06-25 18:36:01 -04:00
|
|
|
@synthesize activeStory;
|
2011-07-24 16:52:24 -07:00
|
|
|
@synthesize storyCount;
|
2011-11-09 09:51:42 -08:00
|
|
|
@synthesize visibleUnreadCount;
|
2011-08-09 17:58:43 -07:00
|
|
|
@synthesize originalStoryCount;
|
2011-07-29 09:06:17 -07:00
|
|
|
@synthesize selectedIntelligence;
|
2010-11-13 18:32:43 -05:00
|
|
|
@synthesize activeOriginalStoryURL;
|
2011-07-24 21:47:58 -07:00
|
|
|
@synthesize recentlyReadStories;
|
2011-11-03 18:08:24 -07:00
|
|
|
@synthesize recentlyReadFeeds;
|
2011-08-22 18:25:33 -07:00
|
|
|
@synthesize readStories;
|
2010-06-17 13:10:45 -04:00
|
|
|
|
2011-10-04 18:01:35 -07:00
|
|
|
@synthesize dictFolders;
|
|
|
|
@synthesize dictFeeds;
|
2012-06-26 16:24:19 -07:00
|
|
|
@synthesize dictActiveFeeds;
|
2012-06-25 15:02:20 -07:00
|
|
|
@synthesize dictSocialFeeds;
|
2012-07-01 18:26:39 -07:00
|
|
|
@synthesize dictUserProfile;
|
2012-07-10 16:48:05 -07:00
|
|
|
@synthesize dictUserInteractions;
|
2012-07-11 20:19:42 -07:00
|
|
|
@synthesize dictUserActivities;
|
2011-10-04 18:01:35 -07:00
|
|
|
@synthesize dictFoldersArray;
|
|
|
|
|
2011-12-03 18:22:14 -08:00
|
|
|
+ (NewsBlurAppDelegate*) sharedAppDelegate {
|
|
|
|
return (NewsBlurAppDelegate*) [UIApplication sharedApplication].delegate;
|
|
|
|
}
|
|
|
|
|
2010-06-17 13:10:45 -04:00
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
|
|
2011-09-07 09:56:54 -07:00
|
|
|
// [TestFlight takeOff:@"101dd20fb90f7355703b131d9af42633_MjQ0NTgyMDExLTA4LTIxIDIzOjU3OjEzLjM5MDcyOA"];
|
2012-06-30 00:02:08 -07:00
|
|
|
|
|
|
|
NSString *currentiPhoneVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
|
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[ASIHTTPRequest setDefaultUserAgentString:[NSString stringWithFormat:@"NewsBlur iPad App v%@",
|
|
|
|
currentiPhoneVersion]];
|
|
|
|
} else {
|
|
|
|
[ASIHTTPRequest setDefaultUserAgentString:[NSString stringWithFormat:@"NewsBlur iPhone App v%@",
|
|
|
|
currentiPhoneVersion]];
|
|
|
|
}
|
2011-08-21 21:39:29 -07:00
|
|
|
|
2012-06-09 12:54:32 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
|
2012-07-10 12:34:58 -07:00
|
|
|
self.navigationController.viewControllers = [NSArray arrayWithObject:feedsViewController];
|
|
|
|
self.splitStoryDetailNavigationController.viewControllers = [NSArray arrayWithObject:self.dashboardViewController];
|
2012-07-01 12:08:30 -07:00
|
|
|
self.splitStoryController.viewControllers = [NSArray arrayWithObjects:navigationController, splitStoryDetailNavigationController, nil];
|
2012-06-09 12:54:32 -07:00
|
|
|
|
2012-07-01 12:08:30 -07:00
|
|
|
[window addSubview:self.splitStoryController.view];
|
2012-06-13 14:11:36 -07:00
|
|
|
self.window.rootViewController = self.splitStoryController;
|
2012-06-09 12:54:32 -07:00
|
|
|
} else {
|
2012-07-01 12:08:30 -07:00
|
|
|
self.navigationController.viewControllers = [NSArray arrayWithObject:self.feedsViewController];
|
|
|
|
[window addSubview:self.navigationController.view];
|
2012-06-09 12:54:32 -07:00
|
|
|
}
|
|
|
|
|
2012-06-24 20:08:39 -07:00
|
|
|
// set default x coordinate for feedDetailY from saved preferences
|
|
|
|
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSInteger savedFeedDetailPortraitYCoordinate = [userPreferences integerForKey:@"feedDetailPortraitYCoordinate"];
|
|
|
|
if (savedFeedDetailPortraitYCoordinate) {
|
|
|
|
self.feedDetailPortraitYCoordinate = savedFeedDetailPortraitYCoordinate;
|
|
|
|
} else {
|
|
|
|
self.feedDetailPortraitYCoordinate = 960;
|
|
|
|
}
|
2012-06-20 08:33:16 -07:00
|
|
|
|
2010-06-17 13:10:45 -04:00
|
|
|
[window makeKeyAndVisible];
|
2012-07-02 11:42:06 -07:00
|
|
|
[self.feedsViewController fetchFeedList:YES refreshFeeds:YES];
|
2012-06-27 21:28:04 -07:00
|
|
|
|
2012-06-20 07:39:49 -07:00
|
|
|
//[self showFirstTimeUser];
|
2010-06-17 13:10:45 -04:00
|
|
|
return YES;
|
|
|
|
}
|
2010-11-11 20:05:53 -05:00
|
|
|
|
2011-07-29 09:06:17 -07:00
|
|
|
- (void)viewDidLoad {
|
2011-11-09 09:51:42 -08:00
|
|
|
self.visibleUnreadCount = 0;
|
2011-08-01 09:43:13 -07:00
|
|
|
[self setRecentlyReadStories:[NSMutableArray array]];
|
2011-07-29 09:06:17 -07:00
|
|
|
}
|
|
|
|
|
2010-06-17 13:10:45 -04:00
|
|
|
|
2010-06-21 17:17:26 -04:00
|
|
|
- (void)hideNavigationBar:(BOOL)animated {
|
|
|
|
[[self navigationController] setNavigationBarHidden:YES animated:animated];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showNavigationBar:(BOOL)animated {
|
|
|
|
[[self navigationController] setNavigationBarHidden:NO animated:animated];
|
2011-08-13 17:08:26 -07:00
|
|
|
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
2010-06-21 17:17:26 -04:00
|
|
|
}
|
2010-06-17 13:10:45 -04:00
|
|
|
|
2012-06-19 10:55:46 -07:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark FeedsView
|
|
|
|
|
|
|
|
- (void)showFeedsMenu {
|
|
|
|
UINavigationController *navController = self.navigationController;
|
2012-06-19 13:51:48 -07:00
|
|
|
[navController presentModalViewController:feedsMenuViewController animated:YES];
|
2012-06-19 10:55:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)hideFeedsMenu {
|
2012-06-19 14:27:35 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[feedsViewController dismissFeedsMenu];
|
|
|
|
} else {
|
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController dismissModalViewControllerAnimated:YES];
|
|
|
|
}
|
2012-06-19 10:55:46 -07:00
|
|
|
}
|
|
|
|
|
2012-07-02 13:10:00 -07:00
|
|
|
- (void)showAddSite {
|
2012-06-19 10:55:46 -07:00
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController dismissModalViewControllerAnimated:NO];
|
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-01 12:08:30 -07:00
|
|
|
addSiteViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
2012-06-19 10:55:46 -07:00
|
|
|
[navController presentModalViewController:addSiteViewController animated:YES];
|
2012-06-22 21:53:45 -07:00
|
|
|
//it's important to do this after presentModalViewController
|
2012-07-02 13:10:00 -07:00
|
|
|
addSiteViewController.view.superview.frame = CGRectMake(0, 0, 320, 460);
|
|
|
|
if ([self isPortrait]) {
|
|
|
|
addSiteViewController.view.superview.center = self.view.center;
|
|
|
|
} else {
|
|
|
|
addSiteViewController.view.superview.center = CGPointMake(self.view.center.y, self.view.center.x);
|
|
|
|
}
|
2012-06-19 10:55:46 -07:00
|
|
|
} else {
|
|
|
|
[navController presentModalViewController:addSiteViewController animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
[addSiteViewController reload];
|
|
|
|
}
|
|
|
|
|
2012-06-29 23:48:47 -07:00
|
|
|
#pragma mark -
|
2012-07-01 12:08:30 -07:00
|
|
|
#pragma mark Social Views
|
|
|
|
|
2012-07-01 21:58:55 -07:00
|
|
|
- (void)showUserProfile {
|
|
|
|
self.findFriendsNavigationController.viewControllers = [NSArray arrayWithObject:userProfileViewController];
|
|
|
|
self.findFriendsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
|
|
|
|
self.findFriendsNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[splitStoryController presentModalViewController:findFriendsNavigationController animated:NO];
|
|
|
|
} else {
|
|
|
|
[navigationController presentModalViewController:findFriendsNavigationController animated:NO];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-12 22:05:23 -07:00
|
|
|
- (void)showUserProfileModal {
|
|
|
|
UserProfileViewController *userProfileView = [[UserProfileViewController alloc] init];
|
|
|
|
self.userProfileViewController = userProfileView;
|
|
|
|
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.userProfileViewController];
|
|
|
|
|
|
|
|
// adding Done button
|
|
|
|
UIBarButtonItem *donebutton = [[UIBarButtonItem alloc]
|
|
|
|
initWithTitle:@"Done"
|
|
|
|
style:UIBarButtonItemStyleDone
|
|
|
|
target:self
|
|
|
|
action:@selector(hideUserProfileModal)];
|
|
|
|
|
|
|
|
self.userProfileViewController.navigationItem.rightBarButtonItem = donebutton;
|
|
|
|
self.userProfileViewController.navigationItem.title = @"Profile";
|
|
|
|
[self.navigationController presentModalViewController:navController animated:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)hideUserProfileModal {
|
|
|
|
[self.navigationController dismissModalViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
|
2012-07-01 12:08:30 -07:00
|
|
|
- (void)showFindFriends {
|
2012-07-01 18:26:39 -07:00
|
|
|
self.findFriendsNavigationController.viewControllers = [NSArray arrayWithObject:friendsListViewController];
|
2012-07-01 12:08:30 -07:00
|
|
|
self.findFriendsNavigationController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
|
|
|
|
self.findFriendsNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[splitStoryController presentModalViewController:findFriendsNavigationController animated:YES];
|
|
|
|
} else {
|
|
|
|
[navigationController presentModalViewController:findFriendsNavigationController animated:YES];
|
|
|
|
}
|
|
|
|
}
|
2012-06-29 23:48:47 -07:00
|
|
|
|
2012-07-19 11:26:17 -07:00
|
|
|
- (void)showFindingStoryHUD {
|
|
|
|
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.splitStoryDetailNavigationController.view animated:YES];
|
|
|
|
HUD.labelText = @"Finding Story...";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)hideFindingStoryHUD {
|
|
|
|
[MBProgressHUD hideHUDForView:self.splitStoryDetailNavigationController.view animated:YES];
|
|
|
|
self.inFindingStoryMode = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)showNoSelectedStoryLabel {
|
|
|
|
self.feedDashboardViewController.storyLabel.hidden = NO;
|
|
|
|
}
|
|
|
|
|
2012-07-20 15:54:10 -07:00
|
|
|
- (void)showShareView:(NSString *)type
|
|
|
|
setUserId:(NSString *)userId
|
|
|
|
setUsername:(NSString *)username
|
|
|
|
setCommentIndex:(NSString *)commentIndex {
|
2012-06-29 23:48:47 -07:00
|
|
|
self.isShowingShare = YES;
|
2012-07-23 16:17:49 -07:00
|
|
|
|
2012-07-12 23:44:14 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
// add shareViewController to storyDetail
|
2012-07-23 16:17:49 -07:00
|
|
|
[self.storyDetailContainerViewController.view addSubview:self.shareViewController.view];
|
2012-07-20 15:54:10 -07:00
|
|
|
[self.shareViewController setSiteInfo:type setUserId:userId setUsername:username setCommentIndex:commentIndex];
|
|
|
|
|
|
|
|
|
2012-07-12 23:44:14 -07:00
|
|
|
self.shareViewController.view.frame = CGRectMake(0,
|
2012-07-23 16:17:49 -07:00
|
|
|
self.storyDetailContainerViewController.view.frame.size.height,
|
|
|
|
self.storyDetailContainerViewController.view.frame.size.width,
|
2012-07-12 23:44:14 -07:00
|
|
|
0);
|
|
|
|
|
2012-07-23 16:17:49 -07:00
|
|
|
int newShareYCoordinate = self.storyDetailContainerViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
|
|
|
int newStoryHeight = self.storyDetailContainerViewController.view.frame.size.height - SHARE_MODAL_HEIGHT + 44;
|
2012-07-19 15:48:35 -07:00
|
|
|
|
2012-07-23 16:17:49 -07:00
|
|
|
[UIView animateWithDuration:0.35 animations:^{
|
2012-07-12 23:44:14 -07:00
|
|
|
self.shareViewController.view.frame = CGRectMake(0,
|
|
|
|
newShareYCoordinate,
|
2012-07-23 16:17:49 -07:00
|
|
|
self.storyDetailContainerViewController.view.frame.size.width,
|
2012-07-12 23:44:14 -07:00
|
|
|
SHARE_MODAL_HEIGHT);
|
2012-07-23 16:17:49 -07:00
|
|
|
self.storyDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
self.storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
newStoryHeight);
|
2012-07-12 23:44:14 -07:00
|
|
|
} completion:^(BOOL finished) {
|
2012-07-23 15:27:20 -07:00
|
|
|
[self.shareViewController.commentField becomeFirstResponder];
|
2012-07-12 23:44:14 -07:00
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
[self.navigationController presentModalViewController:self.shareViewController animated:YES];
|
2012-07-20 18:04:54 -07:00
|
|
|
[self.shareViewController setSiteInfo:type setUserId:userId setUsername:username setCommentIndex:commentIndex];
|
2012-07-12 23:44:14 -07:00
|
|
|
}
|
2012-07-12 13:34:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)adjustShareModal {
|
|
|
|
if (self.isShowingShare) {
|
|
|
|
int newShareYCoordinate = storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
|
|
|
int newStoryHeight = storyDetailViewController.view.frame.size.height - SHARE_MODAL_HEIGHT;
|
|
|
|
shareViewController.view.frame = CGRectMake(0,
|
|
|
|
newShareYCoordinate,
|
|
|
|
storyDetailViewController.view.frame.size.width,
|
|
|
|
SHARE_MODAL_HEIGHT);
|
|
|
|
storyDetailViewController.webView.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
storyDetailViewController.view.frame.size.width,
|
|
|
|
newStoryHeight);
|
|
|
|
}
|
2012-06-29 23:48:47 -07:00
|
|
|
}
|
|
|
|
|
2012-07-12 13:34:41 -07:00
|
|
|
- (void)hideShareView:(BOOL)resetComment {
|
|
|
|
if (resetComment) {
|
|
|
|
self.shareViewController.commentField.text = @"";
|
|
|
|
}
|
|
|
|
|
2012-07-20 00:21:24 -07:00
|
|
|
[self.shareViewController.commentField resignFirstResponder];
|
|
|
|
|
2012-06-29 23:48:47 -07:00
|
|
|
self.isShowingShare = NO;
|
|
|
|
|
2012-07-23 16:17:49 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-12 23:44:14 -07:00
|
|
|
[UIView animateWithDuration:0.35 animations:^{
|
|
|
|
shareViewController.view.frame = CGRectMake(0,
|
2012-07-23 16:17:49 -07:00
|
|
|
storyDetailContainerViewController.view.frame.size.height,
|
|
|
|
storyDetailContainerViewController.view.frame.size.width,
|
2012-07-12 23:44:14 -07:00
|
|
|
0);
|
2012-07-23 16:17:49 -07:00
|
|
|
storyDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
storyDetailContainerViewController.view.frame.size.height);
|
2012-07-12 23:44:14 -07:00
|
|
|
} completion:^(BOOL finished) {
|
2012-07-23 15:27:20 -07:00
|
|
|
[shareViewController.view removeFromSuperview];
|
2012-07-12 23:44:14 -07:00
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
[self.navigationController dismissModalViewControllerAnimated:YES];
|
|
|
|
}
|
2012-06-29 23:48:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)refreshComments {
|
|
|
|
[storyDetailViewController refreshComments];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resetShareComments {
|
|
|
|
[shareViewController clearComments];
|
|
|
|
}
|
|
|
|
|
2010-06-24 00:22:26 -04:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Views
|
|
|
|
|
2010-11-11 23:48:27 -05:00
|
|
|
- (void)showLogin {
|
2012-07-01 23:48:43 -07:00
|
|
|
self.dictFeeds = nil;
|
|
|
|
self.dictSocialFeeds = nil;
|
|
|
|
self.dictFolders = nil;
|
|
|
|
self.dictFoldersArray = nil;
|
|
|
|
|
|
|
|
[self.feedsViewController.feedTitlesTable reloadData];
|
2012-06-13 12:19:35 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-22 14:23:50 -07:00
|
|
|
[self.splitStoryController presentModalViewController:loginViewController animated:NO];
|
2012-06-13 12:19:35 -07:00
|
|
|
} else {
|
2012-06-19 10:55:46 -07:00
|
|
|
[feedsMenuViewController dismissModalViewControllerAnimated:NO];
|
2012-07-22 14:23:50 -07:00
|
|
|
[self.navigationController presentModalViewController:loginViewController animated:NO];
|
2012-06-13 12:19:35 -07:00
|
|
|
}
|
|
|
|
|
2010-11-11 23:48:27 -05:00
|
|
|
}
|
|
|
|
|
2012-06-13 18:07:24 -07:00
|
|
|
- (void)showFirstTimeUser {
|
2012-07-22 14:23:50 -07:00
|
|
|
UINavigationController *ftux = [[UINavigationController alloc] initWithRootViewController:self.firstTimeUserViewController];
|
|
|
|
|
|
|
|
ftux.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
|
|
|
|
self.ftuxNavigationController = ftux;
|
|
|
|
|
2012-06-15 16:45:20 -07:00
|
|
|
[loginViewController dismissModalViewControllerAnimated:NO];
|
2012-06-13 18:07:24 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-22 14:23:50 -07:00
|
|
|
self.ftuxNavigationController.modalPresentationStyle = UIModalPresentationFormSheet;
|
|
|
|
[self.splitStoryController presentModalViewController:self.ftuxNavigationController animated:YES];
|
2012-06-13 18:07:24 -07:00
|
|
|
} else {
|
2012-07-22 14:23:50 -07:00
|
|
|
[self.navigationController presentModalViewController:self.ftuxNavigationController animated:YES];
|
2012-06-13 18:07:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-15 17:24:37 -07:00
|
|
|
- (void)showGoogleReaderAuthentication {
|
|
|
|
googleReaderViewController.modalPresentationStyle = UIModalPresentationFormSheet;
|
|
|
|
[firstTimeUserViewController presentModalViewController:googleReaderViewController animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addedGoogleReader {
|
2012-07-22 14:23:50 -07:00
|
|
|
// [firstTimeUserViewController selectGoogleReaderButton];
|
2012-06-15 17:24:37 -07:00
|
|
|
}
|
|
|
|
|
2011-12-02 16:23:00 -08:00
|
|
|
- (void)showMoveSite {
|
|
|
|
UINavigationController *navController = self.navigationController;
|
2012-06-08 19:36:23 -07:00
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
moveSiteViewController.modalPresentationStyle=UIModalPresentationFormSheet;
|
|
|
|
[navController presentModalViewController:moveSiteViewController animated:YES];
|
2012-06-22 21:53:45 -07:00
|
|
|
//it's important to do this after presentModalViewController
|
|
|
|
moveSiteViewController.view.superview.frame = CGRectMake(0, 0, 320, 440);
|
2012-06-08 19:36:23 -07:00
|
|
|
moveSiteViewController.view.superview.center = self.view.center;
|
|
|
|
} else {
|
|
|
|
[navController presentModalViewController:moveSiteViewController animated:YES];
|
|
|
|
}
|
2011-10-04 18:01:35 -07:00
|
|
|
}
|
|
|
|
|
2011-12-03 18:22:14 -08:00
|
|
|
- (void)reloadFeedsView:(BOOL)showLoader {
|
2012-07-02 11:42:06 -07:00
|
|
|
[feedsViewController fetchFeedList:showLoader refreshFeeds:YES];
|
2010-11-13 13:42:20 -05:00
|
|
|
[loginViewController dismissModalViewControllerAnimated:YES];
|
2011-08-13 17:08:26 -07:00
|
|
|
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
2010-11-11 20:05:53 -05:00
|
|
|
}
|
2011-10-06 10:27:37 -07:00
|
|
|
|
2010-06-25 18:36:01 -04:00
|
|
|
- (void)loadFeedDetailView {
|
2012-06-20 07:39:49 -07:00
|
|
|
[self setStories:nil];
|
2012-06-22 18:01:08 -07:00
|
|
|
[self setFeedUserProfiles:nil];
|
|
|
|
|
2012-06-29 23:25:56 -07:00
|
|
|
self.inFeedDetail = YES;
|
2012-06-27 21:28:04 -07:00
|
|
|
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"All"
|
|
|
|
style: UIBarButtonItemStyleBordered
|
|
|
|
target: nil
|
|
|
|
action: nil];
|
|
|
|
[feedsViewController.navigationItem setBackBarButtonItem: newBackButton];
|
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController pushViewController:feedDetailViewController animated:YES];
|
|
|
|
[self showNavigationBar:YES];
|
|
|
|
navController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
// navController.navigationBar.tintColor = UIColorFromRGB(0x59f6c1);
|
|
|
|
|
|
|
|
popoverHasFeedView = YES;
|
2012-06-19 15:47:51 -07:00
|
|
|
|
2011-09-06 17:51:02 -07:00
|
|
|
[feedDetailViewController resetFeedDetail];
|
2011-09-05 22:06:31 -07:00
|
|
|
[feedDetailViewController fetchFeedDetail:1 withCallback:nil];
|
2012-07-10 12:34:58 -07:00
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.feedDashboardViewController]) {
|
|
|
|
//[self.storyDetailViewController initStory];
|
|
|
|
} else {
|
2012-07-16 22:35:28 -07:00
|
|
|
if (self.inFindingStoryMode) {
|
2012-07-19 11:26:17 -07:00
|
|
|
[self showFindingStoryHUD];
|
2012-07-16 19:45:14 -07:00
|
|
|
[self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:NO];
|
|
|
|
} else {
|
|
|
|
[self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:YES];
|
2012-07-19 11:26:17 -07:00
|
|
|
[self showNoSelectedStoryLabel];
|
2012-07-16 19:45:14 -07:00
|
|
|
}
|
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
}
|
2012-07-20 22:00:30 -07:00
|
|
|
}
|
2012-06-19 15:47:51 -07:00
|
|
|
}
|
|
|
|
|
2012-07-16 22:35:28 -07:00
|
|
|
- (void)loadTryFeedDetailView:(NSString *)feedId withStory:(NSString *)contentId isSocial:(BOOL)social {
|
2012-07-16 19:45:14 -07:00
|
|
|
|
2012-07-16 22:35:28 -07:00
|
|
|
NSDictionary *feed;
|
|
|
|
|
|
|
|
if (social) {
|
|
|
|
feed = [self.dictSocialFeeds objectForKey:feedId];
|
|
|
|
[self setIsSocialView:YES];
|
|
|
|
[self setInFindingStoryMode:YES];
|
|
|
|
} else {
|
|
|
|
feed = [self.dictFeeds objectForKey:feedId];
|
|
|
|
[self setIsSocialView:NO];
|
|
|
|
[self setInFindingStoryMode:NO];
|
|
|
|
}
|
2012-07-16 19:45:14 -07:00
|
|
|
|
2012-07-20 22:00:30 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
|
|
|
|
[self.navigationController popToRootViewControllerAnimated:NO];
|
|
|
|
[self.navigationController dismissModalViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
|
2012-07-16 20:17:24 -07:00
|
|
|
[self setTryFeedStoryId:contentId];
|
2012-07-16 19:45:14 -07:00
|
|
|
[self setActiveFeed:feed];
|
|
|
|
[self setActiveFolder:nil];
|
|
|
|
|
|
|
|
[self loadFeedDetailView];
|
|
|
|
}
|
|
|
|
|
2012-06-27 14:37:37 -07:00
|
|
|
- (void)showDashboard {
|
2012-06-29 23:25:56 -07:00
|
|
|
self.inStoryDetail = NO;
|
|
|
|
self.inFeedDetail = NO;
|
2012-07-15 16:46:46 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-18 12:17:55 -07:00
|
|
|
[self.splitStoryDetailNavigationController popToRootViewControllerAnimated:NO];
|
2012-07-15 16:46:46 -07:00
|
|
|
}
|
2012-06-27 14:37:37 -07:00
|
|
|
}
|
|
|
|
|
2012-06-20 09:32:55 -07:00
|
|
|
|
2012-06-26 12:12:31 -07:00
|
|
|
- (BOOL)isSocialFeed:(NSString *)feedIdStr {
|
|
|
|
if ([feedIdStr length] > 6) {
|
|
|
|
NSString *feedIdSubStr = [feedIdStr substringToIndex:6];
|
|
|
|
if ([feedIdSubStr isEqualToString:@"social"]) {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NO;
|
|
|
|
}
|
2012-06-26 12:29:37 -07:00
|
|
|
|
2012-07-02 13:10:00 -07:00
|
|
|
- (BOOL)isPortrait {
|
|
|
|
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
|
|
|
|
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) {
|
|
|
|
return YES;
|
|
|
|
} else {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-02 11:28:55 -07:00
|
|
|
- (void)confirmLogout {
|
|
|
|
UIAlertView *logoutConfirm = [[UIAlertView alloc] initWithTitle:@"Positive?"
|
|
|
|
message:nil
|
|
|
|
delegate:self
|
|
|
|
cancelButtonTitle:@"Cancel"
|
|
|
|
otherButtonTitles:@"Logout", nil];
|
|
|
|
[logoutConfirm show];
|
|
|
|
[logoutConfirm setTag:1];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
|
|
|
|
if (alertView.tag == 1) { // this is logout
|
|
|
|
if (buttonIndex == 0) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
NSLog(@"Logging out...");
|
|
|
|
NSString *urlS = [NSString stringWithFormat:@"http://%@/reader/logout?api=1",
|
|
|
|
NEWSBLUR_URL];
|
|
|
|
NSURL *url = [NSURL URLWithString:urlS];
|
|
|
|
|
|
|
|
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
|
|
|
|
[request setDelegate:self];
|
|
|
|
[request setResponseEncoding:NSUTF8StringEncoding];
|
|
|
|
[request setDefaultResponseEncoding:NSUTF8StringEncoding];
|
|
|
|
[request setFailedBlock:^(void) {
|
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
|
}];
|
|
|
|
[request setCompletionBlock:^(void) {
|
|
|
|
NSLog(@"Logout successful");
|
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
|
[self showLogin];
|
|
|
|
}];
|
|
|
|
[request setTimeOutSeconds:30];
|
|
|
|
[request startAsynchronous];
|
|
|
|
|
|
|
|
[ASIHTTPRequest setSessionCookies:nil];
|
|
|
|
|
|
|
|
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
|
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
|
HUD.labelText = @"Logging out...";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 07:39:49 -07:00
|
|
|
- (void)loadRiverFeedDetailView {
|
|
|
|
[self setStories:nil];
|
2012-06-22 18:01:08 -07:00
|
|
|
[self setFeedUserProfiles:nil];
|
2012-06-29 23:25:56 -07:00
|
|
|
self.inFeedDetail = YES;
|
2012-06-27 14:37:37 -07:00
|
|
|
|
2012-06-27 21:28:04 -07:00
|
|
|
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle: @"All"
|
|
|
|
style: UIBarButtonItemStyleBordered
|
|
|
|
target: nil
|
|
|
|
action: nil];
|
|
|
|
[feedsViewController.navigationItem setBackBarButtonItem: newBackButton];
|
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController pushViewController:feedDetailViewController animated:YES];
|
|
|
|
[self showNavigationBar:YES];
|
|
|
|
navController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
2012-06-20 07:39:49 -07:00
|
|
|
|
|
|
|
[feedDetailViewController resetFeedDetail];
|
|
|
|
[feedDetailViewController fetchRiverPage:1 withCallback:nil];
|
2012-07-10 12:34:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
if ([[self.splitStoryDetailNavigationController viewControllers] containsObject:self.feedDashboardViewController]) {
|
|
|
|
//[self.storyDetailViewController initStory];
|
|
|
|
} else {
|
|
|
|
[self.splitStoryDetailNavigationController pushViewController:self.feedDashboardViewController animated:YES];
|
|
|
|
}
|
|
|
|
}
|
2012-06-20 07:39:49 -07:00
|
|
|
}
|
|
|
|
|
2012-06-29 21:15:43 -07:00
|
|
|
- (void)adjustStoryDetailWebView {
|
2012-07-12 13:34:41 -07:00
|
|
|
[self adjustShareModal];
|
|
|
|
|
2012-06-29 21:15:43 -07:00
|
|
|
UIImage *slide;
|
|
|
|
if (self.splitStoryController.isShowingMaster) {
|
2012-07-15 15:06:06 -07:00
|
|
|
slide = [UIImage imageNamed: @"slide_left.png"];
|
2012-06-29 21:15:43 -07:00
|
|
|
|
2012-07-23 15:27:20 -07:00
|
|
|
[self.storyDetailContainerViewController.toggleViewButton setImage:slide];
|
2012-06-29 21:15:43 -07:00
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
self.storyDetailViewController.navigationItem.titleView = nil;
|
2012-06-29 21:15:43 -07:00
|
|
|
} else {
|
2012-07-15 15:06:06 -07:00
|
|
|
slide = [UIImage imageNamed: @"slide_right.png"];
|
2012-07-23 15:27:20 -07:00
|
|
|
[self.storyDetailContainerViewController.toggleViewButton setImage:slide];
|
2012-06-29 21:15:43 -07:00
|
|
|
|
|
|
|
UIView *titleLabel = [self makeFeedTitle:self.activeFeed];
|
2012-07-10 12:34:58 -07:00
|
|
|
if (storyDetailViewController.navigationItem){
|
|
|
|
storyDetailViewController.navigationItem.titleView = titleLabel;
|
2012-06-29 21:15:43 -07:00
|
|
|
}
|
|
|
|
}
|
2012-07-12 13:34:41 -07:00
|
|
|
|
|
|
|
// change UIWebView
|
|
|
|
int contentWidth = storyDetailViewController.view.frame.size.width;
|
|
|
|
[storyDetailViewController changeWebViewWidth:contentWidth];
|
2012-07-23 15:27:20 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)slideInStoryTitles {
|
|
|
|
self.hasBottomStoryTitles = YES;
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
// add shareViewController to storyDetail
|
|
|
|
[self.navigationController popViewControllerAnimated:NO];
|
|
|
|
self.feedDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
self.storyDetailViewController.view.frame.size.height,
|
|
|
|
self.storyDetailViewController.view.frame.size.width,
|
|
|
|
0);
|
|
|
|
[self.storyDetailContainerViewController.view addSubview:self.feedDetailViewController.view];
|
|
|
|
|
|
|
|
|
|
|
|
int newShareYCoordinate = self.storyDetailContainerViewController.view.frame.size.height - STORY_TITLES_HEIGHT;
|
|
|
|
int newStoryHeight = self.storyDetailContainerViewController.view.frame.size.height - STORY_TITLES_HEIGHT;
|
|
|
|
[self adjustStoryDetailWebView];
|
|
|
|
[UIView animateWithDuration:0.35 animations:^{
|
|
|
|
|
|
|
|
self.feedDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
newShareYCoordinate,
|
|
|
|
self.storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
STORY_TITLES_HEIGHT);
|
|
|
|
self.storyDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
self.storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
newStoryHeight);
|
|
|
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
|
|
|
[self calibrateStoryTitles];
|
|
|
|
}];
|
|
|
|
}
|
2012-06-27 21:28:04 -07:00
|
|
|
}
|
2012-06-19 15:47:51 -07:00
|
|
|
|
2012-07-23 15:27:20 -07:00
|
|
|
- (void)slideOutStoryTitlesWithAnimation:(BOOL)animated {
|
|
|
|
|
|
|
|
self.hasBottomStoryTitles = NO;
|
|
|
|
|
|
|
|
if (animated) {
|
|
|
|
[UIView animateWithDuration:0.35 animations:^{
|
|
|
|
self.feedDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
storyDetailContainerViewController.view.frame.size.height,
|
|
|
|
storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
0);
|
|
|
|
self.storyDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
storyDetailContainerViewController.view.frame.size.height);
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
[self.navigationController pushViewController:self.feedDetailViewController animated:NO];
|
|
|
|
[self.splitStoryController toggleMasterView:nil];
|
|
|
|
[self performSelector:@selector(adjustStoryDetailWebView) withObject:self afterDelay:.1 ];
|
|
|
|
[self performSelector:@selector(calibrateStoryTitles) withObject:self afterDelay:.1 ];
|
|
|
|
|
|
|
|
}];
|
|
|
|
} else if (![[self.navigationController viewControllers] containsObject:self.feedDetailViewController]) {
|
|
|
|
self.storyDetailViewController.view.frame = CGRectMake(0,
|
|
|
|
0,
|
|
|
|
storyDetailContainerViewController.view.frame.size.width,
|
|
|
|
storyDetailContainerViewController.view.frame.size.height);
|
|
|
|
[self.navigationController pushViewController:self.feedDetailViewController animated:NO];
|
|
|
|
[self.splitStoryController toggleMasterView:nil];
|
|
|
|
[self performSelector:@selector(adjustStoryDetailWebView) withObject:self afterDelay:.1 ];
|
|
|
|
[self performSelector:@selector(calibrateStoryTitles) withObject:self afterDelay:.1 ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)calibrateStoryTitles {
|
|
|
|
[self.feedDetailViewController checkScroll];
|
|
|
|
[self.feedDetailViewController changeActiveFeedDetailRow];
|
|
|
|
|
|
|
|
}
|
2012-07-12 13:34:41 -07:00
|
|
|
|
2012-06-27 21:28:04 -07:00
|
|
|
- (void)animateHidingMasterView {
|
2012-06-29 21:15:43 -07:00
|
|
|
if (!self.splitStoryController.isShowingMaster) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-23 15:27:20 -07:00
|
|
|
|
2012-06-29 21:15:43 -07:00
|
|
|
[self.splitStoryController toggleMasterView:nil];
|
2012-07-23 15:27:20 -07:00
|
|
|
[self performSelector:@selector(slideInStoryTitles) withObject:self afterDelay:.1 ];
|
|
|
|
|
2012-06-27 21:28:04 -07:00
|
|
|
}
|
2012-06-27 14:37:37 -07:00
|
|
|
|
2012-06-27 21:28:04 -07:00
|
|
|
- (void)animateShowingMasterView {
|
2012-06-29 21:15:43 -07:00
|
|
|
if (self.splitStoryController.isShowingMaster) {
|
|
|
|
return;
|
|
|
|
}
|
2012-07-23 15:27:20 -07:00
|
|
|
[self slideOutStoryTitlesWithAnimation:YES];
|
2012-06-19 15:47:51 -07:00
|
|
|
|
2012-06-20 08:33:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dragFeedDetailView:(float)y {
|
2012-06-24 20:08:39 -07:00
|
|
|
NSUserDefaults *userPreferences = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
if (UIInterfaceOrientationIsPortrait(storyDetailViewController.interfaceOrientation)) {
|
2012-06-22 19:15:48 -07:00
|
|
|
y = y + 20;
|
|
|
|
|
|
|
|
if(y > 955) {
|
|
|
|
self.feedDetailPortraitYCoordinate = 960;
|
|
|
|
} else if(y < 950 && y > 200) {
|
2012-06-20 08:33:16 -07:00
|
|
|
self.feedDetailPortraitYCoordinate = y;
|
2012-06-22 19:15:48 -07:00
|
|
|
}
|
|
|
|
|
2012-06-24 20:08:39 -07:00
|
|
|
[userPreferences setInteger:self.feedDetailPortraitYCoordinate forKey:@"feedDetailPortraitYCoordinate"];
|
|
|
|
[userPreferences synchronize];
|
2012-06-29 21:15:43 -07:00
|
|
|
[self adjustStoryDetailWebView];
|
2012-06-20 08:33:16 -07:00
|
|
|
}
|
2011-10-25 09:47:55 -07:00
|
|
|
}
|
|
|
|
|
2012-06-20 19:18:29 -07:00
|
|
|
- (void)changeActiveFeedDetailRow {
|
|
|
|
[feedDetailViewController changeActiveFeedDetailRow];
|
2012-06-18 16:45:36 -07:00
|
|
|
}
|
|
|
|
|
2010-06-25 18:36:01 -04:00
|
|
|
- (void)loadStoryDetailView {
|
2011-10-27 09:44:58 -07:00
|
|
|
NSString *feedTitle;
|
|
|
|
if (self.isRiverView) {
|
|
|
|
feedTitle = self.activeFolder;
|
|
|
|
} else {
|
|
|
|
feedTitle = [activeFeed objectForKey:@"feed_title"];
|
|
|
|
}
|
2012-07-20 19:55:38 -07:00
|
|
|
|
2012-06-09 12:54:32 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-23 15:27:20 -07:00
|
|
|
if (![[self.splitStoryDetailNavigationController viewControllers] containsObject:self.storyDetailContainerViewController]) {
|
|
|
|
[self.splitStoryDetailNavigationController pushViewController:self.storyDetailContainerViewController animated:YES];
|
2012-06-09 12:54:32 -07:00
|
|
|
}
|
|
|
|
} else{
|
|
|
|
UIBarButtonItem *newBackButton = [[UIBarButtonItem alloc] initWithTitle:feedTitle style: UIBarButtonItemStyleBordered target: nil action: nil];
|
|
|
|
[feedDetailViewController.navigationItem setBackBarButtonItem: newBackButton];
|
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController pushViewController:storyDetailViewController animated:YES];
|
2012-07-20 22:00:30 -07:00
|
|
|
//self.storyDetailViewController.navigationItem.titleView = nil;
|
2012-07-15 15:06:06 -07:00
|
|
|
[navController.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:feedTitle style:UIBarButtonItemStyleBordered target:nil action:nil]];
|
2012-06-09 12:54:32 -07:00
|
|
|
navController.navigationItem.hidesBackButton = YES;
|
|
|
|
navController.navigationBar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
}
|
2012-07-20 19:55:38 -07:00
|
|
|
|
|
|
|
[self.storyDetailViewController initStory];
|
2012-06-11 16:56:38 -07:00
|
|
|
}
|
|
|
|
|
2011-08-25 12:09:41 -07:00
|
|
|
- (void)navigationController:(UINavigationController *)navController
|
|
|
|
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
|
|
if (viewController == feedDetailViewController) {
|
|
|
|
UIView *backButtonView = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,35)];
|
2012-07-15 15:06:06 -07:00
|
|
|
UIButton *myBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
2011-08-25 12:09:41 -07:00
|
|
|
[myBackButton setFrame:CGRectMake(0,0,70,35)];
|
|
|
|
[myBackButton setImage:[UIImage imageNamed:@"toolbar_back_button.png"] forState:UIControlStateNormal];
|
|
|
|
[myBackButton setEnabled:YES];
|
|
|
|
[myBackButton addTarget:viewController.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[backButtonView addSubview:myBackButton];
|
|
|
|
UIBarButtonItem* backButton = [[UIBarButtonItem alloc] initWithCustomView:backButtonView];
|
|
|
|
viewController.navigationItem.leftBarButtonItem = backButton;
|
|
|
|
navController.navigationItem.leftBarButtonItem = backButton;
|
|
|
|
viewController.navigationItem.hidesBackButton = YES;
|
|
|
|
navController.navigationItem.hidesBackButton = YES;
|
|
|
|
}
|
2010-06-24 00:22:26 -04:00
|
|
|
}
|
|
|
|
|
2010-11-11 23:48:27 -05:00
|
|
|
- (void)setTitle:(NSString *)title {
|
|
|
|
UILabel *label = [[UILabel alloc] init];
|
|
|
|
[label setFont:[UIFont boldSystemFontOfSize:16.0]];
|
|
|
|
[label setBackgroundColor:[UIColor clearColor]];
|
|
|
|
[label setTextColor:[UIColor whiteColor]];
|
|
|
|
[label setText:title];
|
|
|
|
[label sizeToFit];
|
|
|
|
[navigationController.navigationBar.topItem setTitleView:label];
|
|
|
|
}
|
2010-06-24 00:22:26 -04:00
|
|
|
|
2012-06-14 10:19:36 -07:00
|
|
|
- (void)showOriginalStory:(NSURL *)url {
|
2010-11-13 18:32:43 -05:00
|
|
|
self.activeOriginalStoryURL = url;
|
2012-06-29 10:46:26 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[splitStoryController presentModalViewController:originalStoryViewController animated:YES];
|
|
|
|
} else {
|
|
|
|
UINavigationController *navController = self.navigationController;
|
|
|
|
[navController presentModalViewController:originalStoryViewController animated:YES];
|
|
|
|
}
|
2012-07-10 14:57:00 -07:00
|
|
|
|
2010-11-13 18:32:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)closeOriginalStory {
|
|
|
|
[originalStoryViewController dismissModalViewControllerAnimated:YES];
|
|
|
|
}
|
2010-06-24 00:22:26 -04:00
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
- (void)hideStoryDetailView {
|
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
2012-07-18 12:17:55 -07:00
|
|
|
[self.splitStoryDetailNavigationController popToRootViewControllerAnimated:NO];
|
2012-07-11 18:08:07 -07:00
|
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
} else {
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
2012-07-10 12:34:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-28 15:03:28 -07:00
|
|
|
- (int)indexOfNextUnreadStory {
|
2011-08-08 09:58:15 -07:00
|
|
|
int activeLocation = [self locationOfActiveStory];
|
2011-07-24 21:47:58 -07:00
|
|
|
int readStatus = -1;
|
2011-08-08 09:58:15 -07:00
|
|
|
for (int i=activeLocation+1; i < [self.activeFeedStoryLocations count]; i++) {
|
|
|
|
int location = [[self.activeFeedStoryLocations objectAtIndex:i] intValue];
|
|
|
|
NSDictionary *story = [activeFeedStories objectAtIndex:location];
|
2011-07-24 21:47:58 -07:00
|
|
|
readStatus = [[story objectForKey:@"read_status"] intValue];
|
|
|
|
if (readStatus == 0) {
|
2011-08-08 17:17:32 -07:00
|
|
|
return location;
|
2011-07-24 21:47:58 -07:00
|
|
|
}
|
|
|
|
}
|
2011-08-08 17:17:32 -07:00
|
|
|
if (activeLocation > 0) {
|
|
|
|
for (int i=activeLocation-1; i >= 0; i--) {
|
|
|
|
int location = [[self.activeFeedStoryLocations objectAtIndex:i] intValue];
|
|
|
|
NSDictionary *story = [activeFeedStories objectAtIndex:location];
|
|
|
|
readStatus = [[story objectForKey:@"read_status"] intValue];
|
|
|
|
if (readStatus == 0) {
|
|
|
|
return location;
|
|
|
|
}
|
2011-06-15 11:21:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-06-28 15:03:28 -07:00
|
|
|
- (int)indexOfNextStory {
|
|
|
|
int activeLocation = [self locationOfActiveStory];
|
|
|
|
int nextStoryLocation = activeLocation + 1;
|
|
|
|
if (nextStoryLocation < [self.activeFeedStoryLocations count]) {
|
|
|
|
int location = [[self.activeFeedStoryLocations objectAtIndex:nextStoryLocation] intValue];
|
|
|
|
return location;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-06-15 11:21:55 -04:00
|
|
|
- (int)indexOfPreviousStory {
|
|
|
|
NSInteger activeIndex = [self indexOfActiveStory];
|
2011-07-25 09:08:20 -07:00
|
|
|
return MAX(-1, activeIndex-1);
|
2011-06-15 11:21:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)indexOfActiveStory {
|
2011-07-24 16:52:24 -07:00
|
|
|
for (int i=0; i < self.storyCount; i++) {
|
2011-06-15 11:21:55 -04:00
|
|
|
NSDictionary *story = [activeFeedStories objectAtIndex:i];
|
|
|
|
if ([activeStory objectForKey:@"id"] == [story objectForKey:@"id"]) {
|
|
|
|
return i;
|
2011-06-14 10:35:33 -04:00
|
|
|
}
|
|
|
|
}
|
2011-06-15 11:21:55 -04:00
|
|
|
return -1;
|
2011-06-14 10:35:33 -04:00
|
|
|
}
|
|
|
|
|
2011-08-08 09:58:15 -07:00
|
|
|
- (int)locationOfActiveStory {
|
|
|
|
for (int i=0; i < [activeFeedStoryLocations count]; i++) {
|
|
|
|
if ([activeFeedStoryLocationIds objectAtIndex:i] ==
|
|
|
|
[self.activeStory objectForKey:@"id"]) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-08-22 18:25:33 -07:00
|
|
|
- (void)pushReadStory:(id)storyId {
|
|
|
|
if ([self.readStories lastObject] != storyId) {
|
|
|
|
[self.readStories addObject:storyId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)popReadStory {
|
|
|
|
if (storyCount == 0) {
|
|
|
|
return nil;
|
|
|
|
} else {
|
|
|
|
[self.readStories removeLastObject];
|
|
|
|
id lastStory = [self.readStories lastObject];
|
|
|
|
return lastStory;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)locationOfStoryId:(id)storyId {
|
|
|
|
for (int i=0; i < [activeFeedStoryLocations count]; i++) {
|
|
|
|
if ([activeFeedStoryLocationIds objectAtIndex:i] == storyId) {
|
|
|
|
return [[activeFeedStoryLocations objectAtIndex:i] intValue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-07-26 08:37:10 -07:00
|
|
|
- (int)unreadCount {
|
2011-10-31 10:10:38 -07:00
|
|
|
if (self.isRiverView) {
|
|
|
|
return [self unreadCountForFolder:nil];
|
|
|
|
} else {
|
|
|
|
return [self unreadCountForFeed:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)unreadCountForFeed:(NSString *)feedId {
|
2011-08-09 17:58:43 -07:00
|
|
|
int total = 0;
|
2011-10-31 10:10:38 -07:00
|
|
|
NSDictionary *feed;
|
|
|
|
|
|
|
|
if (feedId) {
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
|
|
|
feed = [self.dictFeeds objectForKey:feedIdStr];
|
|
|
|
} else {
|
|
|
|
feed = self.activeFeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
total += [[feed objectForKey:@"ps"] intValue];
|
2011-08-09 17:58:43 -07:00
|
|
|
if ([self selectedIntelligence] <= 0) {
|
2011-10-31 10:10:38 -07:00
|
|
|
total += [[feed objectForKey:@"nt"] intValue];
|
2011-08-09 17:58:43 -07:00
|
|
|
}
|
|
|
|
if ([self selectedIntelligence] <= -1) {
|
2011-10-31 10:10:38 -07:00
|
|
|
total += [[feed objectForKey:@"ng"] intValue];
|
2011-08-09 17:58:43 -07:00
|
|
|
}
|
2011-10-31 10:10:38 -07:00
|
|
|
|
2011-08-09 17:58:43 -07:00
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2011-10-31 10:10:38 -07:00
|
|
|
- (int)unreadCountForFolder:(NSString *)folderName {
|
|
|
|
int total = 0;
|
|
|
|
NSArray *folder;
|
|
|
|
|
2011-12-01 09:01:18 -08:00
|
|
|
if (!folderName && self.activeFolder == @"Everything") {
|
|
|
|
for (id feedId in self.dictFeeds) {
|
|
|
|
total += [self unreadCountForFeed:feedId];
|
|
|
|
}
|
2011-10-31 10:10:38 -07:00
|
|
|
} else {
|
2011-12-01 09:01:18 -08:00
|
|
|
if (!folderName) {
|
|
|
|
folder = [self.dictFolders objectForKey:self.activeFolder];
|
|
|
|
} else {
|
|
|
|
folder = [self.dictFolders objectForKey:folderName];
|
|
|
|
}
|
2011-10-31 10:10:38 -07:00
|
|
|
|
2011-12-01 09:01:18 -08:00
|
|
|
for (id feedId in folder) {
|
|
|
|
total += [self unreadCountForFeed:feedId];
|
|
|
|
}
|
2011-10-31 10:10:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return total;
|
2011-07-26 08:37:10 -07:00
|
|
|
}
|
|
|
|
|
2011-07-24 16:52:24 -07:00
|
|
|
- (void)addStories:(NSArray *)stories {
|
2011-07-20 22:21:11 -07:00
|
|
|
self.activeFeedStories = [self.activeFeedStories arrayByAddingObjectsFromArray:stories];
|
2011-07-24 16:52:24 -07:00
|
|
|
self.storyCount = [self.activeFeedStories count];
|
2011-07-29 21:27:37 -07:00
|
|
|
[self calculateStoryLocations];
|
2011-07-24 16:52:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setStories:(NSArray *)activeFeedStoriesValue {
|
|
|
|
self.activeFeedStories = activeFeedStoriesValue;
|
|
|
|
self.storyCount = [self.activeFeedStories count];
|
2011-11-03 18:08:24 -07:00
|
|
|
self.recentlyReadStories = [NSMutableArray array];
|
|
|
|
self.recentlyReadFeeds = [NSMutableSet set];
|
2011-07-29 21:27:37 -07:00
|
|
|
[self calculateStoryLocations];
|
2011-07-20 22:21:11 -07:00
|
|
|
}
|
|
|
|
|
2012-06-22 18:01:08 -07:00
|
|
|
- (void)setFeedUserProfiles:(NSArray *)activeFeedUserProfilesValue{
|
|
|
|
self.activeFeedUserProfiles = activeFeedUserProfilesValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addFeedUserProfiles:(NSArray *)activeFeedUserProfilesValue {
|
|
|
|
self.activeFeedUserProfiles = [self.activeFeedUserProfiles arrayByAddingObjectsFromArray:activeFeedUserProfilesValue];
|
|
|
|
}
|
|
|
|
|
2011-07-24 20:34:54 -07:00
|
|
|
- (void)markActiveStoryRead {
|
2011-08-08 09:58:15 -07:00
|
|
|
int activeLocation = [self locationOfActiveStory];
|
|
|
|
if (activeLocation == -1) {
|
|
|
|
return;
|
|
|
|
}
|
2012-06-29 13:48:00 -07:00
|
|
|
|
2011-08-22 18:25:33 -07:00
|
|
|
int activeIndex = [[activeFeedStoryLocations objectAtIndex:activeLocation] intValue];
|
2012-06-29 13:48:00 -07:00
|
|
|
|
2012-06-29 12:54:52 -07:00
|
|
|
NSDictionary *feed;
|
2012-06-29 13:48:00 -07:00
|
|
|
id feedId;;
|
|
|
|
NSString *feedIdStr;
|
2012-06-29 17:37:49 -07:00
|
|
|
NSMutableArray *otherFriendFeeds = [self.activeStory objectForKey:@"shared_by_friends"];
|
2012-06-29 12:54:52 -07:00
|
|
|
|
|
|
|
if (self.isSocialView) {
|
2012-06-29 13:48:00 -07:00
|
|
|
feedId = [self.activeStory objectForKey:@"social_user_id"];
|
|
|
|
feedIdStr = [NSString stringWithFormat:@"social:%@",feedId];
|
|
|
|
feed = [self.dictSocialFeeds objectForKey:feedIdStr];
|
|
|
|
|
|
|
|
[otherFriendFeeds removeObject:feedId];
|
2012-07-20 00:21:24 -07:00
|
|
|
// NSLog(@"otherFriendFeeds is %@", otherFriendFeeds);
|
2012-06-29 13:48:00 -07:00
|
|
|
|
|
|
|
|
2012-06-29 12:54:52 -07:00
|
|
|
} else {
|
2012-06-29 13:48:00 -07:00
|
|
|
feedId = [self.activeStory objectForKey:@"story_feed_id"];
|
|
|
|
feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
2012-06-29 12:54:52 -07:00
|
|
|
feed = [self.dictFeeds objectForKey:feedIdStr];
|
2011-11-15 09:25:50 -08:00
|
|
|
}
|
2012-06-29 13:48:00 -07:00
|
|
|
|
2012-06-29 12:54:52 -07:00
|
|
|
NSDictionary *story = [activeFeedStories objectAtIndex:activeIndex];
|
|
|
|
// if (self.activeFeed != feed) {
|
|
|
|
// self.activeFeed = feed;
|
|
|
|
// }
|
|
|
|
|
2011-11-10 18:28:22 -08:00
|
|
|
[self.recentlyReadStories addObject:[NSNumber numberWithInt:activeLocation]];
|
|
|
|
[self markStoryRead:story feed:feed];
|
2012-06-29 13:48:00 -07:00
|
|
|
|
|
|
|
// decrement all other friend feeds
|
|
|
|
if (self.isSocialView) {
|
|
|
|
for (int i = 0; i < otherFriendFeeds.count; i++) {
|
|
|
|
feedIdStr = [NSString stringWithFormat:@"social:%@",
|
|
|
|
[otherFriendFeeds objectAtIndex:i]];
|
|
|
|
feed = [self.dictSocialFeeds objectForKey:feedIdStr];
|
|
|
|
[self markStoryRead:story feed:feed];
|
|
|
|
}
|
|
|
|
}
|
2012-06-29 17:37:49 -07:00
|
|
|
|
2011-11-10 18:28:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)markVisibleStoriesRead {
|
|
|
|
NSMutableDictionary *feedsStories = [NSMutableDictionary dictionary];
|
|
|
|
for (NSDictionary *story in self.activeFeedStories) {
|
|
|
|
if ([[story objectForKey:@"read_status"] intValue] != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",[story objectForKey:@"story_feed_id"]];
|
|
|
|
NSDictionary *feed = [self.dictFeeds objectForKey:feedIdStr];
|
|
|
|
if (![feedsStories objectForKey:feedIdStr]) {
|
|
|
|
[feedsStories setObject:[NSMutableArray array] forKey:feedIdStr];
|
|
|
|
}
|
|
|
|
NSMutableArray *stories = [feedsStories objectForKey:feedIdStr];
|
|
|
|
[stories addObject:[story objectForKey:@"id"]];
|
|
|
|
[self markStoryRead:story feed:feed];
|
|
|
|
}
|
|
|
|
NSLog(@"feedsStories: %@", feedsStories);
|
|
|
|
return feedsStories;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)markStoryRead:(NSString *)storyId feedId:(id)feedId {
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
|
|
|
NSDictionary *feed = [self.dictFeeds objectForKey:feedIdStr];
|
|
|
|
NSDictionary *story = nil;
|
|
|
|
for (NSDictionary *s in self.activeFeedStories) {
|
|
|
|
if ([[s objectForKey:@"story_guid"] isEqualToString:storyId]) {
|
|
|
|
story = s;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[self markStoryRead:story feed:feed];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)markStoryRead:(NSDictionary *)story feed:(NSDictionary *)feed {
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [feed objectForKey:@"id"]];
|
2011-07-24 22:14:50 -07:00
|
|
|
[story setValue:[NSNumber numberWithInt:1] forKey:@"read_status"];
|
2011-11-09 09:51:42 -08:00
|
|
|
self.visibleUnreadCount -= 1;
|
2011-11-03 18:08:24 -07:00
|
|
|
if (![self.recentlyReadFeeds containsObject:[story objectForKey:@"story_feed_id"]]) {
|
|
|
|
[self.recentlyReadFeeds addObject:[story objectForKey:@"story_feed_id"]];
|
|
|
|
}
|
2011-07-24 22:14:50 -07:00
|
|
|
int score = [NewsBlurAppDelegate computeStoryScore:[story objectForKey:@"intelligence"]];
|
|
|
|
if (score > 0) {
|
2011-10-18 17:44:05 -07:00
|
|
|
int unreads = MAX(0, [[feed objectForKey:@"ps"] intValue] - 1);
|
|
|
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"ps"];
|
2011-07-24 22:14:50 -07:00
|
|
|
} else if (score == 0) {
|
2011-10-18 17:44:05 -07:00
|
|
|
int unreads = MAX(0, [[feed objectForKey:@"nt"] intValue] - 1);
|
|
|
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"nt"];
|
2011-07-24 22:14:50 -07:00
|
|
|
} else if (score < 0) {
|
2011-10-18 17:44:05 -07:00
|
|
|
int unreads = MAX(0, [[feed objectForKey:@"ng"] intValue] - 1);
|
|
|
|
[feed setValue:[NSNumber numberWithInt:unreads] forKey:@"ng"];
|
2011-07-24 22:14:50 -07:00
|
|
|
}
|
2012-06-29 13:48:00 -07:00
|
|
|
|
2011-10-18 17:44:05 -07:00
|
|
|
[self.dictFeeds setValue:feed forKey:feedIdStr];
|
2011-11-10 18:28:22 -08:00
|
|
|
|
2011-07-24 20:34:54 -07:00
|
|
|
}
|
|
|
|
|
2011-07-24 22:23:38 -07:00
|
|
|
- (void)markActiveFeedAllRead {
|
2011-10-18 17:44:05 -07:00
|
|
|
id feedId = [self.activeFeed objectForKey:@"id"];
|
2011-11-10 18:28:22 -08:00
|
|
|
[self markFeedAllRead:feedId];
|
2011-07-24 22:23:38 -07:00
|
|
|
}
|
|
|
|
|
2011-12-01 09:01:18 -08:00
|
|
|
- (void)markActiveFolderAllRead {
|
|
|
|
if (self.activeFolder == @"Everything") {
|
|
|
|
for (NSString *folderName in self.dictFoldersArray) {
|
|
|
|
for (id feedId in [self.dictFolders objectForKey:folderName]) {
|
|
|
|
[self markFeedAllRead:feedId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (id feedId in [self.dictFolders objectForKey:self.activeFolder]) {
|
|
|
|
[self markFeedAllRead:feedId];
|
|
|
|
}
|
2011-11-09 09:51:42 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-10 18:28:22 -08:00
|
|
|
- (void)markFeedAllRead:(id)feedId {
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@",feedId];
|
2012-07-15 17:18:23 -07:00
|
|
|
NSDictionary *feed = self.isSocialView ? [self.dictSocialFeeds objectForKey:feedIdStr] : [self.dictFeeds objectForKey:feedIdStr];
|
2011-11-10 18:28:22 -08:00
|
|
|
|
|
|
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"ps"];
|
|
|
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"nt"];
|
|
|
|
[feed setValue:[NSNumber numberWithInt:0] forKey:@"ng"];
|
2012-07-15 17:18:23 -07:00
|
|
|
if (self.isSocialView) {
|
|
|
|
[self.dictSocialFeeds setValue:feed forKey:feedIdStr];
|
|
|
|
} else {
|
|
|
|
[self.dictFeeds setValue:feed forKey:feedIdStr];
|
|
|
|
}
|
2011-11-10 18:28:22 -08:00
|
|
|
}
|
|
|
|
|
2011-07-29 21:27:37 -07:00
|
|
|
- (void)calculateStoryLocations {
|
2011-11-09 09:51:42 -08:00
|
|
|
self.visibleUnreadCount = 0;
|
2011-08-01 09:43:13 -07:00
|
|
|
self.activeFeedStoryLocations = [NSMutableArray array];
|
2011-08-08 09:58:15 -07:00
|
|
|
self.activeFeedStoryLocationIds = [NSMutableArray array];
|
2011-07-29 21:27:37 -07:00
|
|
|
for (int i=0; i < self.storyCount; i++) {
|
|
|
|
NSDictionary *story = [self.activeFeedStories objectAtIndex:i];
|
|
|
|
int score = [NewsBlurAppDelegate computeStoryScore:[story objectForKey:@"intelligence"]];
|
2011-08-01 09:43:13 -07:00
|
|
|
if (score >= self.selectedIntelligence) {
|
2011-07-29 21:27:37 -07:00
|
|
|
NSNumber *location = [NSNumber numberWithInt:i];
|
|
|
|
[self.activeFeedStoryLocations addObject:location];
|
2011-08-08 09:58:15 -07:00
|
|
|
[self.activeFeedStoryLocationIds addObject:[story objectForKey:@"id"]];
|
2011-11-09 09:51:42 -08:00
|
|
|
if ([[story objectForKey:@"read_status"] intValue] == 0) {
|
|
|
|
self.visibleUnreadCount += 1;
|
|
|
|
}
|
2011-07-29 21:27:37 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-22 10:44:52 -05:00
|
|
|
+ (int)computeStoryScore:(NSDictionary *)intelligence {
|
|
|
|
int score = 0;
|
2011-07-26 08:37:10 -07:00
|
|
|
int title = [[intelligence objectForKey:@"title"] intValue];
|
|
|
|
int author = [[intelligence objectForKey:@"author"] intValue];
|
|
|
|
int tags = [[intelligence objectForKey:@"tags"] intValue];
|
|
|
|
|
|
|
|
int score_max = MAX(title, MAX(author, tags));
|
|
|
|
int score_min = MIN(title, MIN(author, tags));
|
2011-07-24 20:07:38 -07:00
|
|
|
|
|
|
|
if (score_max > 0) score = score_max;
|
|
|
|
else if (score_min < 0) score = score_min;
|
2010-11-22 10:44:52 -05:00
|
|
|
|
2011-07-24 20:07:38 -07:00
|
|
|
if (score == 0) score = [[intelligence objectForKey:@"feed"] integerValue];
|
|
|
|
|
2011-07-29 09:06:17 -07:00
|
|
|
// NSLog(@"%d/%d -- %d: %@", score_max, score_min, score, intelligence);
|
2010-11-22 10:44:52 -05:00
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
2011-12-04 21:09:16 -08:00
|
|
|
|
|
|
|
|
|
|
|
- (NSString *)extractParentFolderName:(NSString *)folderName {
|
|
|
|
if ([folderName containsString:@"Top Level"]) {
|
|
|
|
folderName = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([folderName containsString:@" - "]) {
|
|
|
|
int lastFolderLoc = [folderName rangeOfString:@" - " options:NSBackwardsSearch].location;
|
|
|
|
folderName = [folderName substringToIndex:lastFolderLoc];
|
|
|
|
} else {
|
|
|
|
folderName = @"— Top Level —";
|
|
|
|
}
|
|
|
|
|
|
|
|
return folderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)extractFolderName:(NSString *)folderName {
|
|
|
|
if ([folderName containsString:@"Top Level"]) {
|
|
|
|
folderName = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([folderName containsString:@" - "]) {
|
|
|
|
int folder_loc = [folderName rangeOfString:@" - " options:NSBackwardsSearch].location;
|
|
|
|
folderName = [folderName substringFromIndex:(folder_loc + 3)];
|
|
|
|
}
|
|
|
|
|
|
|
|
return folderName;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Feed Templates
|
|
|
|
|
2011-10-27 19:05:38 -07:00
|
|
|
+ (UIView *)makeGradientView:(CGRect)rect startColor:(NSString *)start endColor:(NSString *)end {
|
2012-07-15 15:06:06 -07:00
|
|
|
UIView *gradientView = [[UIView alloc] initWithFrame:rect];
|
2011-10-27 19:05:38 -07:00
|
|
|
|
|
|
|
CAGradientLayer *gradient = [CAGradientLayer layer];
|
2011-10-30 18:53:10 -07:00
|
|
|
gradient.frame = CGRectMake(0, 1, rect.size.width, rect.size.height-1);
|
2012-06-10 13:21:07 -07:00
|
|
|
gradient.opacity = 0.7;
|
2011-10-27 19:05:38 -07:00
|
|
|
unsigned int color = 0;
|
|
|
|
unsigned int colorFade = 0;
|
|
|
|
if ([start class] == [NSNull class]) {
|
|
|
|
start = @"505050";
|
|
|
|
}
|
|
|
|
if ([end class] == [NSNull class]) {
|
|
|
|
end = @"303030";
|
|
|
|
}
|
|
|
|
NSScanner *scanner = [NSScanner scannerWithString:start];
|
|
|
|
[scanner scanHexInt:&color];
|
|
|
|
NSScanner *scannerFade = [NSScanner scannerWithString:end];
|
|
|
|
[scannerFade scanHexInt:&colorFade];
|
|
|
|
gradient.colors = [NSArray arrayWithObjects:(id)[UIColorFromRGB(color) CGColor], (id)[UIColorFromRGB(colorFade) CGColor], nil];
|
2011-10-28 18:29:33 -07:00
|
|
|
|
|
|
|
CALayer *whiteBackground = [CALayer layer];
|
2011-10-30 18:53:10 -07:00
|
|
|
whiteBackground.frame = CGRectMake(0, 1, rect.size.width, rect.size.height-1);
|
2012-06-10 13:21:07 -07:00
|
|
|
whiteBackground.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.7].CGColor;
|
2011-10-28 18:29:33 -07:00
|
|
|
[gradientView.layer addSublayer:whiteBackground];
|
|
|
|
|
2011-10-27 19:05:38 -07:00
|
|
|
[gradientView.layer addSublayer:gradient];
|
2011-10-28 18:29:33 -07:00
|
|
|
|
|
|
|
CALayer *topBorder = [CALayer layer];
|
2011-10-30 18:53:10 -07:00
|
|
|
topBorder.frame = CGRectMake(0, 1, rect.size.width, 1);
|
2012-06-10 13:21:07 -07:00
|
|
|
topBorder.backgroundColor = [UIColorFromRGB(colorFade) colorWithAlphaComponent:0.7].CGColor;
|
2011-10-30 15:06:25 -07:00
|
|
|
topBorder.opacity = 1;
|
2011-10-28 18:29:33 -07:00
|
|
|
[gradientView.layer addSublayer:topBorder];
|
|
|
|
|
|
|
|
CALayer *bottomBorder = [CALayer layer];
|
|
|
|
bottomBorder.frame = CGRectMake(0, rect.size.height-1, rect.size.width, 1);
|
2012-06-10 13:21:07 -07:00
|
|
|
bottomBorder.backgroundColor = [UIColorFromRGB(colorFade) colorWithAlphaComponent:0.7].CGColor;
|
2011-10-30 15:06:25 -07:00
|
|
|
bottomBorder.opacity = 1;
|
2011-10-28 18:29:33 -07:00
|
|
|
[gradientView.layer addSublayer:bottomBorder];
|
|
|
|
|
|
|
|
return gradientView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIView *)makeFeedTitleGradient:(NSDictionary *)feed withRect:(CGRect)rect {
|
|
|
|
UIView *gradientView;
|
2012-06-26 16:24:19 -07:00
|
|
|
if (self.isRiverView || self.isSocialView) {
|
2011-10-28 18:29:33 -07:00
|
|
|
gradientView = [NewsBlurAppDelegate
|
|
|
|
makeGradientView:rect
|
2012-06-30 21:28:48 -07:00
|
|
|
startColor:[feed objectForKey:@"favicon_fade"]
|
|
|
|
endColor:[feed objectForKey:@"favicon_color"]];
|
2011-10-28 18:29:33 -07:00
|
|
|
|
2012-07-15 15:06:06 -07:00
|
|
|
UILabel *titleLabel = [[UILabel alloc] init];
|
2011-10-28 18:29:33 -07:00
|
|
|
titleLabel.text = [feed objectForKey:@"feed_title"];
|
|
|
|
titleLabel.backgroundColor = [UIColor clearColor];
|
|
|
|
titleLabel.textAlignment = UITextAlignmentLeft;
|
|
|
|
titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
|
2011-12-04 21:09:16 -08:00
|
|
|
titleLabel.numberOfLines = 1;
|
2011-10-28 18:29:33 -07:00
|
|
|
titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:11.0];
|
|
|
|
titleLabel.shadowOffset = CGSizeMake(0, 1);
|
|
|
|
if ([[feed objectForKey:@"favicon_text_color"] class] != [NSNull class]) {
|
2011-11-30 18:46:11 -08:00
|
|
|
titleLabel.textColor = [[feed objectForKey:@"favicon_text_color"]
|
|
|
|
isEqualToString:@"white"] ?
|
2012-06-30 21:28:48 -07:00
|
|
|
[UIColor whiteColor] :
|
|
|
|
[UIColor blackColor];
|
2011-11-30 18:46:11 -08:00
|
|
|
titleLabel.shadowColor = [[feed objectForKey:@"favicon_text_color"]
|
|
|
|
isEqualToString:@"white"] ?
|
2012-06-30 21:28:48 -07:00
|
|
|
UIColorFromRGB(0x202020) :
|
|
|
|
UIColorFromRGB(0xd0d0d0);
|
2011-10-28 18:29:33 -07:00
|
|
|
} else {
|
|
|
|
titleLabel.textColor = [UIColor whiteColor];
|
|
|
|
titleLabel.shadowColor = [UIColor blackColor];
|
|
|
|
}
|
2011-12-04 21:09:16 -08:00
|
|
|
titleLabel.frame = CGRectMake(32, 1, rect.size.width-32, 20);
|
2011-10-28 18:29:33 -07:00
|
|
|
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [feed objectForKey:@"id"]];
|
|
|
|
UIImage *titleImage = [Utilities getImage:feedIdStr];
|
|
|
|
UIImageView *titleImageView = [[UIImageView alloc] initWithImage:titleImage];
|
2011-10-30 18:53:10 -07:00
|
|
|
titleImageView.frame = CGRectMake(8, 3, 16.0, 16.0);
|
2011-10-28 18:29:33 -07:00
|
|
|
[titleLabel addSubview:titleImageView];
|
|
|
|
|
|
|
|
[gradientView addSubview:titleLabel];
|
|
|
|
[gradientView addSubview:titleImageView];
|
|
|
|
} else {
|
|
|
|
gradientView = [NewsBlurAppDelegate
|
2012-06-22 21:53:45 -07:00
|
|
|
makeGradientView:CGRectMake(0, -1, 1024, 10)
|
|
|
|
// hard coding the 1024 as a hack for window.frame.size.width
|
2012-06-30 21:28:48 -07:00
|
|
|
startColor:[feed objectForKey:@"favicon_fade"]
|
|
|
|
endColor:[feed objectForKey:@"favicon_color"]];
|
2011-10-28 18:29:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
gradientView.opaque = YES;
|
|
|
|
|
2011-10-27 19:05:38 -07:00
|
|
|
return gradientView;
|
|
|
|
}
|
2011-08-18 09:56:52 -07:00
|
|
|
|
2011-12-02 16:23:00 -08:00
|
|
|
- (UIView *)makeFeedTitle:(NSDictionary *)feed {
|
2012-07-15 15:06:06 -07:00
|
|
|
UILabel *titleLabel = [[UILabel alloc] init];
|
2011-12-02 16:23:00 -08:00
|
|
|
if (self.isRiverView) {
|
|
|
|
titleLabel.text = [NSString stringWithFormat:@" %@", self.activeFolder];
|
2012-07-12 22:05:23 -07:00
|
|
|
} else if (self.isSocialView) {
|
|
|
|
titleLabel.text = [NSString stringWithFormat:@" %@", [feed objectForKey:@"feed_title"]];
|
2011-12-02 16:23:00 -08:00
|
|
|
} else {
|
|
|
|
titleLabel.text = [NSString stringWithFormat:@" %@", [feed objectForKey:@"feed_title"]];
|
|
|
|
}
|
|
|
|
titleLabel.backgroundColor = [UIColor clearColor];
|
|
|
|
titleLabel.textAlignment = UITextAlignmentLeft;
|
|
|
|
titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0];
|
|
|
|
titleLabel.textColor = [UIColor whiteColor];
|
|
|
|
titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
|
2011-12-04 21:09:16 -08:00
|
|
|
titleLabel.numberOfLines = 1;
|
2011-12-02 16:23:00 -08:00
|
|
|
titleLabel.shadowColor = [UIColor blackColor];
|
|
|
|
titleLabel.shadowOffset = CGSizeMake(0, -1);
|
2012-07-12 22:05:23 -07:00
|
|
|
titleLabel.center = CGPointMake(0, -2);
|
2011-12-02 16:23:00 -08:00
|
|
|
[titleLabel sizeToFit];
|
|
|
|
|
2012-07-12 22:05:23 -07:00
|
|
|
if (!self.isSocialView) {
|
|
|
|
titleLabel.center = CGPointMake(28, -2);
|
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [feed objectForKey:@"id"]];
|
|
|
|
UIImage *titleImage;
|
|
|
|
if (self.isRiverView) {
|
|
|
|
titleImage = [UIImage imageNamed:@"folder.png"];
|
|
|
|
} else {
|
|
|
|
titleImage = [Utilities getImage:feedIdStr];
|
|
|
|
}
|
|
|
|
UIImageView *titleImageView = [[UIImageView alloc] initWithImage:titleImage];
|
|
|
|
titleImageView.frame = CGRectMake(0.0, 2.0, 16.0, 16.0);
|
|
|
|
[titleLabel addSubview:titleImageView];
|
|
|
|
}
|
|
|
|
return titleLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIButton *)makeRightFeedTitle:(NSDictionary *)feed {
|
|
|
|
|
2011-12-02 16:23:00 -08:00
|
|
|
NSString *feedIdStr = [NSString stringWithFormat:@"%@", [feed objectForKey:@"id"]];
|
|
|
|
UIImage *titleImage;
|
|
|
|
if (self.isRiverView) {
|
|
|
|
titleImage = [UIImage imageNamed:@"folder.png"];
|
2012-07-12 22:05:23 -07:00
|
|
|
} else if (self.isRiverView) {
|
|
|
|
titleImage = [Utilities getImage:feedIdStr];
|
2011-12-02 16:23:00 -08:00
|
|
|
} else {
|
|
|
|
titleImage = [Utilities getImage:feedIdStr];
|
|
|
|
}
|
2012-07-12 22:05:23 -07:00
|
|
|
|
2011-12-02 16:23:00 -08:00
|
|
|
|
2012-07-12 22:05:23 -07:00
|
|
|
titleImage = [Utilities roundCorneredImage:titleImage radius:6];
|
|
|
|
|
|
|
|
UIButton *titleImageButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
titleImageButton.bounds = CGRectMake(0, 0, 32, 32);
|
|
|
|
|
|
|
|
[titleImageButton setImage:titleImage forState:UIControlStateNormal];
|
|
|
|
return titleImageButton;
|
2011-12-02 16:23:00 -08:00
|
|
|
}
|
|
|
|
|
2012-07-12 22:05:23 -07:00
|
|
|
@end
|