Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 88 additions & 19 deletions Baker.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Baker/BKRAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@interface BKRAppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) BKRInterceptorWindow *window;
@property (nonatomic, strong) UIViewController *rootViewController;
@property (nonatomic, strong) UINavigationController *rootNavigationController;
@property (nonatomic, strong) IBOutlet UIViewController *rootViewController;
@property (nonatomic, strong) IBOutlet UINavigationController *rootNavigationController;

@end
50 changes: 14 additions & 36 deletions Baker/BKRAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,16 @@ + (void)initialize {
}

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

if ([BKRSettings sharedSettings].isNewsstand) {
[self configureNewsstandApp:application options:launchOptions];
} else {
[self configureStandAloneApp:application options:launchOptions];
}else{
if([[BKRIssuesManager localBooksList] count] == 1) {
self.window.rootViewController = [[BKRBookViewController alloc] initWithIssue:[BKRIssuesManager localBooksList][0]];
[self.window makeKeyAndVisible];
}
}

self.rootNavigationController = [[BKRCustomNavigationController alloc] initWithRootViewController:self.rootViewController];

[self configureNavigationBar];
[self configureAnalytics];

self.window = [[BKRInterceptorWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = self.rootNavigationController;
[self.window makeKeyAndVisible];

[self configureAnalytics];
return YES;
}

Expand Down Expand Up @@ -119,32 +112,9 @@ - (void)configureNewsstandApp:(UIApplication*)application options:(NSDictionary*
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
}
}

self.rootViewController = [[BKRShelfViewController alloc] init];

}

- (void)configureStandAloneApp:(UIApplication*)application options:(NSDictionary*)launchOptions {

NSLog(@"====== Baker Standalone Mode enabled ======");
NSArray *books = [BKRIssuesManager localBooksList];
if (books.count == 1) {
BKRBook *book = [books[0] bakerBook];
self.rootViewController = [[BKRBookViewController alloc] initWithBook:book];
} else {
self.rootViewController = [[BKRShelfViewController alloc] initWithBooks:books];
}

}

- (void)configureNavigationBar {
BKRCustomNavigationBar *navigationBar = (BKRCustomNavigationBar*)self.rootNavigationController.navigationBar;
navigationBar.tintColor = [UIColor bkrColorWithHexString:[BKRSettings sharedSettings].issuesActionBackgroundColor];
navigationBar.barTintColor = [UIColor bkrColorWithHexString:@"ffffff"];
navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor bkrColorWithHexString:@"000000"]};
[navigationBar setBackgroundImage:[UIImage imageNamed:@"navigation-bar-bg"] forBarMetrics:UIBarMetricsDefault];
}

- (void)configureAnalytics {
[BKRAnalyticsEvents sharedInstance]; // Initialization
[[NSNotificationCenter defaultCenter] postNotificationName:@"BakerApplicationStart" object:self]; // -> Baker Analytics Event
Expand Down Expand Up @@ -247,6 +217,14 @@ - (void)applicationWillHandleNewsstandNotificationOfContent:(NSString*)contentNa

}

- (BKRInterceptorWindow *)window {
static BKRInterceptorWindow *customWindow = nil;
if (!customWindow) {
customWindow = [[BKRInterceptorWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}
return customWindow;
}

#pragma mark - Application Lifecycle

- (void)applicationWillResignActive:(UIApplication*)application {
Expand Down
2 changes: 2 additions & 0 deletions Baker/Baker-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<string>newsstand-content</string>
<string>remote-notification</string>
</array>
<key>UIMainStoryboardFile</key>
<string>BKRStoryboard</string>
<key>UINewsstandApp</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
Binary file added Baker/icon-buy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-buy@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-buy@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-categories.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-categories@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-categories@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-info@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-info@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-refresh@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-refresh@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-subscribe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-subscribe@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Baker/icon-subscribe@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@

#import <UIKit/UIKit.h>

@protocol BKRCategoryFilterItemDelegate <NSObject>
@protocol BKRCategoryFilterButtonDelegate <NSObject>
@required
- (void)categoryFilterItem:(id)categoryFilterItem clickedAction:(NSString *)action;
- (void)categoryFilterButton:(id)categoryFilterButton clickedAction:(NSString *)action;
@end

@interface BKRCategoryFilterItem : UIBarButtonItem <UIActionSheetDelegate> {
id <BKRCategoryFilterItemDelegate> delegate;
@interface BKRCategoryFilterButton : UIButton <UIActionSheetDelegate> {
id <BKRCategoryFilterButtonDelegate> delegate;
}

@property (retain) id delegate;
@property (nonatomic, strong) UIActionSheet *categoriesActionSheet;
@property (nonatomic, strong) NSArray *categoriesActionSheetActions;
@property (nonatomic, strong) NSArray *categories;

-(id)initWithCategories:(NSArray *)aCategories delegate:(NSObject *)aDelegate;
-(id)initWithDelegate:(NSObject *)aDelegate;
-(id)initWithCoder:(NSCoder *)aDecoder;
-(void)setCategories:(NSArray *)aCategories delegate:(NSObject *)aDelegate;


@end
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,33 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#import "BKRCategoryFilterItem.h"
#import "BKRCategoryFilterButton.h"
#import "BKRShelfViewController.h"

@implementation BKRCategoryFilterItem {
@implementation BKRCategoryFilterButton {

}

@synthesize delegate;

-(id)initWithCategories:(NSArray *)aCategories delegate:(NSObject *)aDelegate {

// Initialize dropdown
if(self = [super initWithTitle:NSLocalizedString(@"ALL_CATEGORIES_TITLE", nil) style:UIBarButtonItemStylePlain target:self action:@selector(categoryFilterItemTouched:)]) {

// Set categories
self.categories = aCategories;

// Set delegate
self.delegate = aDelegate;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
[self setTitle:NSLocalizedString(@"ALL_CATEGORIES_TITLE", nil) forState:UIControlStateNormal];
[self addTarget:self action:@selector(categoryFilterButtonTouched:) forControlEvents:UIControlEventTouchUpInside];
return self;
}

-(id)initWithDelegate:(NSObject *)aDelegate {
return [self initWithCategories:[NSArray array] delegate:aDelegate];
-(void)setCategories:(NSArray *)aCategories delegate:(NSObject *)aDelegate {
self.categories = aCategories;
self.delegate = aDelegate;
}

- (IBAction)categoryFilterItemTouched:(UIBarButtonItem *)sender {
- (void)categoryFilterButtonTouched:(UIButton *)sender {
if (self.categoriesActionSheet.visible) {
[self.categoriesActionSheet dismissWithClickedButtonIndex:(self.categoriesActionSheet.numberOfButtons - 1) animated:YES];
} else {
self.categoriesActionSheet = [self buildCategoriesActionSheet];
[self.categoriesActionSheet showFromBarButtonItem:sender animated:YES];
[self.categoriesActionSheet showFromRect:self.frame inView:self.superview animated:YES];
}
}

Expand Down Expand Up @@ -95,11 +90,11 @@ - (void) actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger
if (actionSheet == self.categoriesActionSheet && buttonIndex > -1) {
NSString *action = [self.categoriesActionSheetActions objectAtIndex:buttonIndex];
if ([action isEqualToString:@"reset-filter"]) {
[self setTitle:NSLocalizedString(@"ALL_CATEGORIES_TITLE", nil)];
[self setTitle:NSLocalizedString(@"ALL_CATEGORIES_TITLE", nil) forState:UIControlStateNormal];
} else {
[self setTitle:action];
[self setTitle:action forState:UIControlStateNormal];
}
[self.delegate categoryFilterItem:self clickedAction:action];
[self.delegate categoryFilterButton:self clickedAction:action];
}
}

Expand Down
2 changes: 2 additions & 0 deletions BakerShelf/BKRCustomNavigationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@

@interface BKRCustomNavigationController : UINavigationController

@property (nonatomic, copy) UIColor *originalTitleColor;

@end
22 changes: 22 additions & 0 deletions BakerShelf/BKRCustomNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,26 @@ - (BOOL)shouldAutorotate {
return [self.topViewController shouldAutorotate];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self updateTitleForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self updateTitleForOrientation:toInterfaceOrientation];
}

- (void)updateTitleForOrientation:(UIInterfaceOrientation)orientation {
if(!self.originalTitleColor) {
NSDictionary *titleTextAttributes = self.navigationBar.titleTextAttributes;
self.originalTitleColor = [titleTextAttributes objectForKey:@"TextColor"];
}
if(UIInterfaceOrientationIsPortrait(orientation) && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor clearColor], NSForegroundColorAttributeName, nil]];
}else{
[self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:self.originalTitleColor, NSForegroundColorAttributeName, nil]];
}
}

@end
37 changes: 27 additions & 10 deletions BakerShelf/BKRIssue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,65 @@

#import "BKRBook.h"

typedef enum transientStates {
BakerIssueTransientStatusNone,
BakerIssueTransientStatusDownloading,
BakerIssueTransientStatusOpening,
BakerIssueTransientStatusPurchasing,
BakerIssueTransientStatusUnpriced
} BakerIssueTransientStatus;
typedef enum issueStates {
BakerIssueStatusNone,
BakerIssueStatusDownloading,
BakerIssueStatusOpening,
BakerIssueStatusPurchasing,
BakerIssueStatusUnpriced
} BakerIssueStatus;

@protocol BKRIssueDelegate;

@interface BKRIssue : NSObject <NSURLConnectionDownloadDelegate> {
BKRPurchasesManager *purchasesManager;
}

@property (nonatomic, weak) id<BKRIssueDelegate> delegate;

@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *info;
@property (nonatomic, copy) NSString *date;
@property (nonatomic, copy) NSURL *url;
@property (nonatomic, copy) NSString *path;
@property (nonatomic, copy) NSArray *categories;

@property (nonatomic, copy) NSString *coverPath;
@property (nonatomic, copy) NSURL *coverURL;

@property (nonatomic, copy) NSString *productID;
@property (nonatomic, copy) NSString *price;

@property (nonatomic, strong) BKRBook *bakerBook;

@property (nonatomic, assign) BakerIssueTransientStatus transientStatus;
@property (nonatomic, assign) BakerIssueStatus status;

@property (nonatomic, copy) NSString *notificationDownloadStartedName;
@property (nonatomic, copy) NSString *notificationDownloadProgressingName;
@property (nonatomic, copy) NSString *notificationDownloadFinishedName;
@property (nonatomic, copy) NSString *notificationDownloadErrorName;
@property (nonatomic, copy) NSString *notificationUnzipErrorName;

@property (nonatomic, assign) BOOL purchaseDelayed;

- (id)initWithBakerBook:(BKRBook*)bakerBook;
- (void)getCoverWithCache:(bool)cache andBlock:(void(^)(UIImage *img))completionBlock;
- (NSString*)getStatus;

- (id)initWithIssueData:(NSDictionary*)issueData;
- (void)download;
- (void)downloadWithAsset:(NKAssetDownload*)asset;
- (void)dataChanged;

@end


@protocol BKRIssueDelegate <NSObject>

- (void)issue:(BKRIssue *)issue downloadStarted:(NSDictionary *)userInfo;
- (void)issue:(BKRIssue *)issue downloadProgressing:(NSDictionary *)userInfo;
- (void)issue:(BKRIssue *)issue downloadFinished:(NSDictionary *)userInfo;
- (void)issue:(BKRIssue *)issue downloadError:(NSDictionary *)userInfo;
- (void)issue:(BKRIssue *)issue unzipError:(NSDictionary *)userInfo;
- (void)issue:(BKRIssue *)issue dataChanged:(NSDictionary *)userInfo;

@end
Loading