From d99bbc0f6a210a3e0f3a9c648d4160f10a0be857 Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Mon, 20 Oct 2014 20:40:14 -0500 Subject: [PATCH 1/8] Spanish Localization Added. --- Reader.xcodeproj/project.pbxproj | 3 +++ es.lproj/Localizable.strings | Bin 0 -> 2584 bytes 2 files changed, 3 insertions(+) create mode 100644 es.lproj/Localizable.strings diff --git a/Reader.xcodeproj/project.pbxproj b/Reader.xcodeproj/project.pbxproj index 3c8d2376..ad9319cd 100644 --- a/Reader.xcodeproj/project.pbxproj +++ b/Reader.xcodeproj/project.pbxproj @@ -67,6 +67,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 11EB39D819F5DCDC007134F4 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D6058910D05DD3D006BFB54 /* Reader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Reader.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -391,6 +392,7 @@ knownRegions = ( en, de, + es, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; @@ -478,6 +480,7 @@ children = ( 4541A9D5122EA686001A5E60 /* en */, 458BF155143E077500CDF567 /* de */, + 11EB39D819F5DCDC007134F4 /* es */, ); name = Localizable.strings; sourceTree = ""; diff --git a/es.lproj/Localizable.strings b/es.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..3d5bc7243416df4209147dfbfc0239b7840f18a8 GIT binary patch literal 2584 zcmaKu*=`e25JdYGzG7s71QH>DkU$_FOf~}E$As3VtlrD)(i6|%WJeyn(f|5L5~Ki@-HG=<T zesTPnJu&or@4~s6=^eOXst_W$nN$^@YCKX^!NUXXPkncyQK@mE+CR$TTD44!{khf) z_kpo1k2b3^l!`jn9!iB;SP~;RNqiA`uE>E2|EWB`dM0v%30+3Q%awBCX zj-8#Xa;gzsL#_9;PQ8US>|iZN!|pHDL&wl}i4gSE8s6)^g^-^4ZmEtz;ZP*HbgY#? z17AcMEAox%Nlw0;D^yY#KIuWAqfiIP4IRgz&cUdV!6Q*~j?Q9Sj#5)#f;oE!GB z%@cO)^+e3s!g8!Emy2AX&8D(&#y}7~8W_$rpDhs9N~6L$k7Q4!qpzZ$f{WGeLeH@I zDpg8VSu?aA7uK<#s)B1Fk6PoTFY`wqQ9b(vSr^>^EGgBaMmEwV}R66{9b^j^-bhN?aA&yUcm%h zg1IBxj$-uvyQh6{z#P9g?1dd%9acN&14)&Xh(RMwyHE!zxb?`_obbxKfsPQizkKC%Zjaumv7}|0c z;V1Q>26#a|cIgPzg>P(DbJLZujTI^|%btPlZdF5eZS+7y!7llXtf;+=D0@EH|Jw?+ bt>yi|I6T7suKt6% Date: Mon, 20 Oct 2014 20:41:16 -0500 Subject: [PATCH 2/8] Changed hardcoded constants to propertys with comments. --- Sources/ReaderConstants.h | 61 ++++++++++++++++++++++++++++++++++----- Sources/ReaderConstants.m | 41 ++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/Sources/ReaderConstants.h b/Sources/ReaderConstants.h index b09f2e65..2d72b744 100644 --- a/Sources/ReaderConstants.h +++ b/Sources/ReaderConstants.h @@ -29,11 +29,56 @@ #import -#define READER_FLAT_UI TRUE -#define READER_SHOW_SHADOWS TRUE -#define READER_ENABLE_THUMBS TRUE -#define READER_DISABLE_RETINA FALSE -#define READER_ENABLE_PREVIEW TRUE -#define READER_DISABLE_IDLE FALSE -#define READER_STANDALONE FALSE -#define READER_BOOKMARKS TRUE +@interface ReaderConstants : NSObject; + ++ (ReaderConstants *)sharedReaderConstants; + +/** + * If TRUE, follows the Fuglyosity of Flat Fad (flattens the UI). + * Default . + */ +@property (nonatomic, assign) BOOL flatUI; + +/** + * If TRUE, a shadow is shown around each page and page thumbnail. + * Default YES. + */ +@property (nonatomic, assign) BOOL showShadows; + +/** + * If TRUE, a thumbs button is added to the main toolbar enabling page thumbnail document navigation. + * Default YES. + */ +@property (nonatomic, assign) BOOL enableThumbs; + +/** + * If TRUE, sets the CATiledLayer contentScale to 1.0f. This effectively disables retina support and results in non-retina device rendering speeds on retina display devices at the loss of retina display quality. + * Default NO. + */ +@property (nonatomic, assign) BOOL disableRetina; + +/** + * If TRUE, a medium resolution page thumbnail is displayed before the CATiledLayer starts to render the PDF page. + * Default YES. + */ +@property (nonatomic, assign) BOOL enablePreview; + +/** + * If TRUE, the iOS idle timer is disabled while viewing a document (beware of battery drain). + * Default NO. + */ +@property (nonatomic, assign) BOOL disableIdle; + +/** + * If FALSE, a "Done" button is added to the toolbar and the -dismissReaderViewController: delegate method is messaged when it is tapped. + * Default NO. + */ +@property (nonatomic, assign) BOOL standalone; + +/** + * If TRUE, enables page bookmark support. + * Default YES. + */ +@property (nonatomic, assign) BOOL bookmarks; + +@end \ No newline at end of file diff --git a/Sources/ReaderConstants.m b/Sources/ReaderConstants.m index b58cc373..efec144c 100644 --- a/Sources/ReaderConstants.m +++ b/Sources/ReaderConstants.m @@ -26,3 +26,44 @@ #import "ReaderConstants.h" static NSString *const kReaderCopyrightNotice = @"Reader v2.x.y • Copyright © 2011-2014 Julius Oklamcak. All rights reserved."; + +@implementation ReaderConstants + ++ (ReaderConstants *)sharedReaderConstants{ + static ReaderConstants *_sharedReaderConstants = nil; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedReaderConstants = [[self alloc] init]; + }); + + return _sharedReaderConstants; +} + +- (instancetype)init{ + self = [super init]; + + if (self) { + // Default Values + + self.flatUI = [ReaderConstants isAtLeastiOS7]; + self.showShadows = YES; + self.enableThumbs = YES; + self.disableRetina = NO; + self.enablePreview = YES; + self.disableIdle = NO; + self.standalone = NO; + self.bookmarks = YES; + } + + return self; +} + ++ (BOOL)isAtLeastiOS7{ + NSString *reqSysVer = @"7.0"; + NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; + return [currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending; +} + +@end + From 13f35f7951e4c3441c7a173638fcbbe811360bfb Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Mon, 20 Oct 2014 21:16:03 -0500 Subject: [PATCH 3/8] Changed all the compilers conditionals to use the new bools properties. --- Sources/ReaderContentPage.m | 10 +- Sources/ReaderContentView.m | 50 ++++---- Sources/ReaderMainPagebar.m | 13 +- Sources/ReaderMainToolbar.m | 213 +++++++++++++++++---------------- Sources/ReaderViewController.m | 106 ++++++++-------- Sources/ThumbsMainToolbar.m | 76 ++++++------ Sources/ThumbsViewController.m | 34 +++--- Sources/UIXToolbarView.m | 10 +- 8 files changed, 258 insertions(+), 254 deletions(-) diff --git a/Sources/ReaderContentPage.m b/Sources/ReaderContentPage.m index 9124cf45..51b40234 100644 --- a/Sources/ReaderContentPage.m +++ b/Sources/ReaderContentPage.m @@ -517,15 +517,15 @@ - (void)dealloc CGPDFDocumentRelease(_PDFDocRef), _PDFDocRef = NULL; } -#if (READER_DISABLE_RETINA == TRUE) // Option - - (void)didMoveToWindow { - self.contentScaleFactor = 1.0f; // Override scale factor + if ([[ReaderConstants sharedReaderConstants] disableRetina]) { // Option + + self.contentScaleFactor = 1.0f; // Override scale factor + + } // end of disableRetina Option } -#endif // end of READER_DISABLE_RETINA Option - #pragma mark - CATiledLayer delegate methods - (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context diff --git a/Sources/ReaderContentView.m b/Sources/ReaderContentView.m index 398cbe96..33c752c5 100644 --- a/Sources/ReaderContentView.m +++ b/Sources/ReaderContentView.m @@ -144,23 +144,23 @@ - (instancetype)initWithFrame:(CGRect)frame fileURL:(NSURL *)fileURL page:(NSUIn theContainerView.autoresizingMask = UIViewAutoresizingNone; theContainerView.backgroundColor = [UIColor whiteColor]; -#if (READER_SHOW_SHADOWS == TRUE) // Option - - theContainerView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); - theContainerView.layer.shadowRadius = 4.0f; theContainerView.layer.shadowOpacity = 1.0f; - theContainerView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theContainerView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option + if ([[ReaderConstants sharedReaderConstants] showShadows]){ // Option + + theContainerView.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); + theContainerView.layer.shadowRadius = 4.0f; theContainerView.layer.shadowOpacity = 1.0f; + theContainerView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theContainerView.bounds].CGPath; + + } // end of showShadows Option self.contentSize = theContentPage.bounds.size; [self centerScrollViewContent]; -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - theThumbView = [[ReaderContentThumb alloc] initWithFrame:theContentPage.bounds]; // Page thumb view - - [theContainerView addSubview:theThumbView]; // Add the page thumb view to the container view - -#endif // end of READER_ENABLE_PREVIEW Option + if ([[ReaderConstants sharedReaderConstants] enablePreview]) { // Option + + theThumbView = [[ReaderContentThumb alloc] initWithFrame:theContentPage.bounds]; // Page thumb view + + [theContainerView addSubview:theThumbView]; // Add the page thumb view to the container view + + } // end of enablePreview Option [theContainerView addSubview:theContentPage]; // Add the content page to the container view @@ -220,17 +220,17 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N - (void)showPageThumb:(NSURL *)fileURL page:(NSInteger)page password:(NSString *)phrase guid:(NSString *)guid { -#if (READER_ENABLE_PREVIEW == TRUE) // Option - - CGSize size = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE) : CGSizeMake(PAGE_THUMB_SMALL, PAGE_THUMB_SMALL)); - - ReaderThumbRequest *request = [ReaderThumbRequest newForView:theThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; - - UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the page thumb - - if ([image isKindOfClass:[UIImage class]]) [theThumbView showImage:image]; // Show image from cache - -#endif // end of READER_ENABLE_PREVIEW Option + if ([[ReaderConstants sharedReaderConstants] enablePreview]) { // Option + + CGSize size = ((userInterfaceIdiom == UIUserInterfaceIdiomPad) ? CGSizeMake(PAGE_THUMB_LARGE, PAGE_THUMB_LARGE) : CGSizeMake(PAGE_THUMB_SMALL, PAGE_THUMB_SMALL)); + + ReaderThumbRequest *request = [ReaderThumbRequest newForView:theThumbView fileURL:fileURL password:phrase guid:guid page:page size:size]; + + UIImage *image = [[ReaderThumbCache sharedInstance] thumbRequest:request priority:YES]; // Request the page thumb + + if ([image isKindOfClass:[UIImage class]]) [theThumbView showImage:image]; // Show image from cache + + } // end of enablePreview Option } - (id)processSingleTap:(UITapGestureRecognizer *)recognizer diff --git a/Sources/ReaderMainPagebar.m b/Sources/ReaderMainPagebar.m index 0181bcd4..3f24fca9 100644 --- a/Sources/ReaderMainPagebar.m +++ b/Sources/ReaderMainPagebar.m @@ -71,13 +71,12 @@ @implementation ReaderMainPagebar #pragma mark - ReaderMainPagebar class methods -+ (Class)layerClass -{ -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option ++ (Class)layerClass { + if ([[ReaderConstants sharedReaderConstants] flatUI]) { // Option + return [CALayer class]; + }else{ + return [CAGradientLayer class]; + } // end of flatUI Option } #pragma mark - ReaderMainPagebar instance methods diff --git a/Sources/ReaderMainToolbar.m b/Sources/ReaderMainToolbar.m index 8073a6c8..f359a890 100644 --- a/Sources/ReaderMainToolbar.m +++ b/Sources/ReaderMainToolbar.m @@ -35,6 +35,9 @@ @implementation ReaderMainToolbar UIImage *markImageN; UIImage *markImageY; + + UIImage *buttonH; + UIImage *buttonN; } #pragma mark - Constants @@ -72,12 +75,10 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document { CGFloat viewWidth = self.bounds.size.width; // Toolbar view width -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option + if (![[ReaderConstants sharedReaderConstants] flatUI]) { // Option + buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; + buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; + } // end of flatUI Option BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); @@ -87,73 +88,74 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document CGFloat leftButtonX = BUTTON_X; // Left-side button start X position -#if (READER_STANDALONE == FALSE) // Option - - UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; - NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); - CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; - CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); - - UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; - doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); - [doneButton setTitleColor:[UIColor colorWithWhite:0.0f alpha:1.0f] forState:UIControlStateNormal]; - [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; - [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; - [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - doneButton.autoresizingMask = UIViewAutoresizingNone; - //doneButton.backgroundColor = [UIColor grayColor]; - doneButton.exclusiveTouch = YES; - - [self addSubview:doneButton]; leftButtonX += (doneButtonWidth + buttonSpacing); - - titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); - -#endif // end of READER_STANDALONE Option - -#if (READER_ENABLE_THUMBS == TRUE) // Option - - UIButton *thumbsButton = [UIButton buttonWithType:UIButtonTypeCustom]; - thumbsButton.frame = CGRectMake(leftButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - [thumbsButton setImage:[UIImage imageNamed:@"Reader-Thumbs"] forState:UIControlStateNormal]; - [thumbsButton addTarget:self action:@selector(thumbsButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [thumbsButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [thumbsButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - thumbsButton.autoresizingMask = UIViewAutoresizingNone; - //thumbsButton.backgroundColor = [UIColor grayColor]; - thumbsButton.exclusiveTouch = YES; - - [self addSubview:thumbsButton]; //leftButtonX += (iconButtonWidth + buttonSpacing); - - titleX += (iconButtonWidth + buttonSpacing); titleWidth -= (iconButtonWidth + buttonSpacing); - -#endif // end of READER_ENABLE_THUMBS Option + if (![[ReaderConstants sharedReaderConstants] standalone]) { // Option + + UIFont *doneButtonFont = [UIFont systemFontOfSize:BUTTON_FONT_SIZE]; + NSString *doneButtonText = NSLocalizedString(@"Done", @"button"); + CGSize doneButtonSize = [doneButtonText sizeWithFont:doneButtonFont]; + CGFloat doneButtonWidth = (doneButtonSize.width + TEXT_BUTTON_PADDING); + + UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom]; + doneButton.frame = CGRectMake(leftButtonX, BUTTON_Y, doneButtonWidth, BUTTON_HEIGHT); + [doneButton setTitleColor:[UIColor colorWithWhite:0.0f alpha:1.0f] forState:UIControlStateNormal]; + [doneButton setTitleColor:[UIColor colorWithWhite:1.0f alpha:1.0f] forState:UIControlStateHighlighted]; + [doneButton setTitle:doneButtonText forState:UIControlStateNormal]; doneButton.titleLabel.font = doneButtonFont; + [doneButton addTarget:self action:@selector(doneButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; + [doneButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; + [doneButton setBackgroundImage:buttonN forState:UIControlStateNormal]; + doneButton.autoresizingMask = UIViewAutoresizingNone; + //doneButton.backgroundColor = [UIColor grayColor]; + doneButton.exclusiveTouch = YES; + + [self addSubview:doneButton]; + leftButtonX += (doneButtonWidth + buttonSpacing); + + titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); + + } // end of standalone Option + + if ([[ReaderConstants sharedReaderConstants] enableThumbs]) { // Option + + UIButton *thumbsButton = [UIButton buttonWithType:UIButtonTypeCustom]; + thumbsButton.frame = CGRectMake(leftButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); + [thumbsButton setImage:[UIImage imageNamed:@"Reader-Thumbs"] forState:UIControlStateNormal]; + [thumbsButton addTarget:self action:@selector(thumbsButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; + [thumbsButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; + [thumbsButton setBackgroundImage:buttonN forState:UIControlStateNormal]; + thumbsButton.autoresizingMask = UIViewAutoresizingNone; + //thumbsButton.backgroundColor = [UIColor grayColor]; + thumbsButton.exclusiveTouch = YES; + + [self addSubview:thumbsButton]; //leftButtonX += (iconButtonWidth + buttonSpacing); + + titleX += (iconButtonWidth + buttonSpacing); titleWidth -= (iconButtonWidth + buttonSpacing); + + } // end of enableThumbs Option CGFloat rightButtonX = viewWidth; // Right-side buttons start X position -#if (READER_BOOKMARKS == TRUE) // Option - - rightButtonX -= (iconButtonWidth + buttonSpacing); // Position - - UIButton *flagButton = [UIButton buttonWithType:UIButtonTypeCustom]; - flagButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); - //[flagButton setImage:[UIImage imageNamed:@"Reader-Mark-N"] forState:UIControlStateNormal]; - [flagButton addTarget:self action:@selector(markButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [flagButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; - [flagButton setBackgroundImage:buttonN forState:UIControlStateNormal]; - flagButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - //flagButton.backgroundColor = [UIColor grayColor]; - flagButton.exclusiveTouch = YES; - - [self addSubview:flagButton]; titleWidth -= (iconButtonWidth + buttonSpacing); - - markButton = flagButton; markButton.enabled = NO; markButton.tag = NSIntegerMin; - - markImageN = [UIImage imageNamed:@"Reader-Mark-N"]; // N image - markImageY = [UIImage imageNamed:@"Reader-Mark-Y"]; // Y image - -#endif // end of READER_BOOKMARKS Option + if ([[ReaderConstants sharedReaderConstants] bookmarks]) { // Option + + rightButtonX -= (iconButtonWidth + buttonSpacing); // Position + + UIButton *flagButton = [UIButton buttonWithType:UIButtonTypeCustom]; + flagButton.frame = CGRectMake(rightButtonX, BUTTON_Y, iconButtonWidth, BUTTON_HEIGHT); + //[flagButton setImage:[UIImage imageNamed:@"Reader-Mark-N"] forState:UIControlStateNormal]; + [flagButton addTarget:self action:@selector(markButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; + [flagButton setBackgroundImage:buttonH forState:UIControlStateHighlighted]; + [flagButton setBackgroundImage:buttonN forState:UIControlStateNormal]; + flagButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; + //flagButton.backgroundColor = [UIColor grayColor]; + flagButton.exclusiveTouch = YES; + + [self addSubview:flagButton]; titleWidth -= (iconButtonWidth + buttonSpacing); + + markButton = flagButton; markButton.enabled = NO; markButton.tag = NSIntegerMin; + + markImageN = [UIImage imageNamed:@"Reader-Mark-N"]; // N image + markImageY = [UIImage imageNamed:@"Reader-Mark-Y"]; // Y image + + } // end of bookmarks Option if (document.canEmail == YES) // Document email enabled { @@ -234,10 +236,11 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document titleLabel.adjustsFontSizeToFitWidth = YES; titleLabel.minimumScaleFactor = 0.75f; titleLabel.text = [document.fileName stringByDeletingPathExtension]; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.75f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option + + if (![[ReaderConstants sharedReaderConstants] flatUI]) { // Option + titleLabel.shadowColor = [UIColor colorWithWhite:0.75f alpha:1.0f]; + titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); + } // end of flatUI Option [self addSubview:titleLabel]; } @@ -248,41 +251,41 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document - (void)setBookmarkState:(BOOL)state { -#if (READER_BOOKMARKS == TRUE) // Option - - if (state != markButton.tag) // Only if different state - { - if (self.hidden == NO) // Only if toolbar is visible - { - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - markButton.tag = state; // Update bookmarked state tag - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option + if ([[ReaderConstants sharedReaderConstants] bookmarks]) { // Option + + if (state != markButton.tag) // Only if different state + { + if (self.hidden == NO) // Only if toolbar is visible + { + UIImage *image = (state ? markImageY : markImageN); + + [markButton setImage:image forState:UIControlStateNormal]; + } + + markButton.tag = state; // Update bookmarked state tag + } + + if (markButton.enabled == NO) markButton.enabled = YES; + + } // end of bookmarks Option } - (void)updateBookmarkImage { -#if (READER_BOOKMARKS == TRUE) // Option - - if (markButton.tag != NSIntegerMin) // Valid tag - { - BOOL state = markButton.tag; // Bookmarked state - - UIImage *image = (state ? markImageY : markImageN); - - [markButton setImage:image forState:UIControlStateNormal]; - } - - if (markButton.enabled == NO) markButton.enabled = YES; - -#endif // end of READER_BOOKMARKS Option + if ([[ReaderConstants sharedReaderConstants] bookmarks]) { // Option + + if (markButton.tag != NSIntegerMin) // Valid tag + { + BOOL state = markButton.tag; // Bookmarked state + + UIImage *image = (state ? markImageY : markImageN); + + [markButton setImage:image forState:UIControlStateNormal]; + } + + if (markButton.enabled == NO) markButton.enabled = YES; + + } // end of bookmarks Option } - (void)hideToolbar diff --git a/Sources/ReaderViewController.m b/Sources/ReaderViewController.m index 3d326efb..35da6a22 100644 --- a/Sources/ReaderViewController.m +++ b/Sources/ReaderViewController.m @@ -410,11 +410,11 @@ - (void)viewDidAppear:(BOOL)animated [self performSelector:@selector(showDocument) withObject:nil afterDelay:0.0]; } -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = YES; - -#endif // end of READER_DISABLE_IDLE Option + if ([[ReaderConstants sharedReaderConstants] disableIdle]) { // Option + + [UIApplication sharedApplication].idleTimerDisabled = YES; + + } // end of disableIdle Option } - (void)viewWillDisappear:(BOOL)animated @@ -423,11 +423,11 @@ - (void)viewWillDisappear:(BOOL)animated lastAppearSize = self.view.bounds.size; // Track view size -#if (READER_DISABLE_IDLE == TRUE) // Option - - [UIApplication sharedApplication].idleTimerDisabled = NO; - -#endif // end of READER_DISABLE_IDLE Option + if ([[ReaderConstants sharedReaderConstants] disableIdle]) { // Option + + [UIApplication sharedApplication].idleTimerDisabled = NO; + + } // end of disableIdle Option } - (void)viewDidDisappear:(BOOL)animated @@ -712,29 +712,29 @@ - (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touch - (void)tappedInToolbar:(ReaderMainToolbar *)toolbar doneButton:(UIButton *)button { -#if (READER_STANDALONE == FALSE) // Option - - [self closeDocument]; // Close ReaderViewController - -#endif // end of READER_STANDALONE Option + if (![[ReaderConstants sharedReaderConstants] standalone]) { // Option + + [self closeDocument]; // Close ReaderViewController + + } // end of standalone Option } - (void)tappedInToolbar:(ReaderMainToolbar *)toolbar thumbsButton:(UIButton *)button { -#if (READER_ENABLE_THUMBS == TRUE) // Option - - if (printInteraction != nil) [printInteraction dismissAnimated:NO]; - - ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] initWithReaderDocument:document]; - - thumbsViewController.title = self.title; thumbsViewController.delegate = self; // ThumbsViewControllerDelegate - - thumbsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; - thumbsViewController.modalPresentationStyle = UIModalPresentationFullScreen; - - [self presentViewController:thumbsViewController animated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option + if ([[ReaderConstants sharedReaderConstants] enableThumbs]) { // Option + + if (printInteraction != nil) [printInteraction dismissAnimated:NO]; + + ThumbsViewController *thumbsViewController = [[ThumbsViewController alloc] initWithReaderDocument:document]; + + thumbsViewController.title = self.title; thumbsViewController.delegate = self; // ThumbsViewControllerDelegate + + thumbsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; + thumbsViewController.modalPresentationStyle = UIModalPresentationFullScreen; + + [self presentViewController:thumbsViewController animated:NO completion:NULL]; + + } // end of enableThumbs Option } - (void)tappedInToolbar:(ReaderMainToolbar *)toolbar exportButton:(UIButton *)button @@ -829,20 +829,20 @@ - (void)tappedInToolbar:(ReaderMainToolbar *)toolbar emailButton:(UIButton *)but - (void)tappedInToolbar:(ReaderMainToolbar *)toolbar markButton:(UIButton *)button { -#if (READER_BOOKMARKS == TRUE) // Option - - if (printInteraction != nil) [printInteraction dismissAnimated:YES]; - - if ([document.bookmarks containsIndex:currentPage]) // Remove bookmark - { - [document.bookmarks removeIndex:currentPage]; [mainToolbar setBookmarkState:NO]; - } - else // Add the bookmarked page number to the bookmark index set - { - [document.bookmarks addIndex:currentPage]; [mainToolbar setBookmarkState:YES]; - } - -#endif // end of READER_BOOKMARKS Option + if ([[ReaderConstants sharedReaderConstants] bookmarks]) { // Option + + if (printInteraction != nil) [printInteraction dismissAnimated:YES]; + + if ([document.bookmarks containsIndex:currentPage]) // Remove bookmark + { + [document.bookmarks removeIndex:currentPage]; [mainToolbar setBookmarkState:NO]; + } + else // Add the bookmarked page number to the bookmark index set + { + [document.bookmarks addIndex:currentPage]; [mainToolbar setBookmarkState:YES]; + } + + } // end of bookmarks Option } #pragma mark - MFMailComposeViewControllerDelegate methods @@ -867,20 +867,20 @@ - (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteraction - (void)thumbsViewController:(ThumbsViewController *)viewController gotoPage:(NSInteger)page { -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self showDocumentPage:page]; - -#endif // end of READER_ENABLE_THUMBS Option + if ([[ReaderConstants sharedReaderConstants] enableThumbs]) { // Option + + [self showDocumentPage:page]; + + } // end of enableThumbs Option } - (void)dismissThumbsViewController:(ThumbsViewController *)viewController { -#if (READER_ENABLE_THUMBS == TRUE) // Option - - [self dismissViewControllerAnimated:NO completion:NULL]; - -#endif // end of READER_ENABLE_THUMBS Option + if ([[ReaderConstants sharedReaderConstants] enableThumbs]) { // Option + + [self dismissViewControllerAnimated:NO completion:NULL]; + + } // end of enableThumbs Option } #pragma mark - ReaderMainPagebarDelegate methods diff --git a/Sources/ThumbsMainToolbar.m b/Sources/ThumbsMainToolbar.m index d95b07ab..794f5de8 100644 --- a/Sources/ThumbsMainToolbar.m +++ b/Sources/ThumbsMainToolbar.m @@ -26,7 +26,10 @@ #import "ReaderConstants.h" #import "ThumbsMainToolbar.h" -@implementation ThumbsMainToolbar +@implementation ThumbsMainToolbar{ + UIImage *buttonH; + UIImage *buttonN; +} #pragma mark - Constants @@ -62,12 +65,10 @@ - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title { CGFloat viewWidth = self.bounds.size.width; // Toolbar view width -#if (READER_FLAT_UI == TRUE) // Option - UIImage *buttonH = nil; UIImage *buttonN = nil; -#else - UIImage *buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; - UIImage *buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; -#endif // end of READER_FLAT_UI Option + if (![[ReaderConstants sharedReaderConstants] flatUI]) { // Option + buttonH = [[UIImage imageNamed:@"Reader-Button-H"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; + buttonN = [[UIImage imageNamed:@"Reader-Button-N"] stretchableImageWithLeftCapWidth:5 topCapHeight:0]; + } // end of flatUI Option BOOL largeDevice = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); @@ -98,32 +99,32 @@ - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title titleX += (doneButtonWidth + buttonSpacing); titleWidth -= (doneButtonWidth + buttonSpacing); -#if (READER_BOOKMARKS == TRUE) // Option - - CGFloat showControlX = (viewWidth - (SHOW_CONTROL_WIDTH + buttonSpacing)); - - UIImage *thumbsImage = [UIImage imageNamed:@"Reader-Thumbs"]; - UIImage *bookmarkImage = [UIImage imageNamed:@"Reader-Mark-Y"]; - NSArray *buttonItems = [NSArray arrayWithObjects:thumbsImage, bookmarkImage, nil]; - - BOOL useTint = [self respondsToSelector:@selector(tintColor)]; // iOS 7 and up - - UISegmentedControl *showControl = [[UISegmentedControl alloc] initWithItems:buttonItems]; - showControl.frame = CGRectMake(showControlX, BUTTON_Y, SHOW_CONTROL_WIDTH, BUTTON_HEIGHT); - showControl.tintColor = (useTint ? [UIColor blackColor] : [UIColor colorWithWhite:0.8f alpha:1.0f]); - showControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; - showControl.segmentedControlStyle = UISegmentedControlStyleBar; - showControl.selectedSegmentIndex = 0; // Default segment index - //showControl.backgroundColor = [UIColor grayColor]; - showControl.exclusiveTouch = YES; - - [showControl addTarget:self action:@selector(showControlTapped:) forControlEvents:UIControlEventValueChanged]; - - [self addSubview:showControl]; - - titleWidth -= (SHOW_CONTROL_WIDTH + buttonSpacing); - -#endif // end of READER_BOOKMARKS Option + if ([[ReaderConstants sharedReaderConstants] bookmarks]) { // Option + + CGFloat showControlX = (viewWidth - (SHOW_CONTROL_WIDTH + buttonSpacing)); + + UIImage *thumbsImage = [UIImage imageNamed:@"Reader-Thumbs"]; + UIImage *bookmarkImage = [UIImage imageNamed:@"Reader-Mark-Y"]; + NSArray *buttonItems = [NSArray arrayWithObjects:thumbsImage, bookmarkImage, nil]; + + BOOL useTint = [self respondsToSelector:@selector(tintColor)]; // iOS 7 and up + + UISegmentedControl *showControl = [[UISegmentedControl alloc] initWithItems:buttonItems]; + showControl.frame = CGRectMake(showControlX, BUTTON_Y, SHOW_CONTROL_WIDTH, BUTTON_HEIGHT); + showControl.tintColor = (useTint ? [UIColor blackColor] : [UIColor colorWithWhite:0.8f alpha:1.0f]); + showControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; + showControl.segmentedControlStyle = UISegmentedControlStyleBar; + showControl.selectedSegmentIndex = 0; // Default segment index + //showControl.backgroundColor = [UIColor grayColor]; + showControl.exclusiveTouch = YES; + + [showControl addTarget:self action:@selector(showControlTapped:) forControlEvents:UIControlEventValueChanged]; + + [self addSubview:showControl]; + + titleWidth -= (SHOW_CONTROL_WIDTH + buttonSpacing); + + } // end of bookmarks Option if (largeDevice == YES) // Show document filename in toolbar { @@ -140,10 +141,11 @@ - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title titleLabel.adjustsFontSizeToFitWidth = YES; titleLabel.minimumScaleFactor = 0.75f; titleLabel.text = title; -#if (READER_FLAT_UI == FALSE) // Option - titleLabel.shadowColor = [UIColor colorWithWhite:0.65f alpha:1.0f]; - titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); -#endif // end of READER_FLAT_UI Option + + if (![[ReaderConstants sharedReaderConstants] flatUI]) { // Option + titleLabel.shadowColor = [UIColor colorWithWhite:0.65f alpha:1.0f]; + titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f); + } // end of flatUI Option [self addSubview:titleLabel]; } diff --git a/Sources/ThumbsViewController.m b/Sources/ThumbsViewController.m index c0db1346..33f8d4af 100644 --- a/Sources/ThumbsViewController.m +++ b/Sources/ThumbsViewController.m @@ -399,13 +399,13 @@ - (instancetype)initWithFrame:(CGRect)frame backView.autoresizingMask = UIViewAutoresizingNone; backView.backgroundColor = [UIColor whiteColor]; -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); - backView.layer.shadowRadius = 3.0f; backView.layer.shadowOpacity = 1.0f; - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option + if ([[ReaderConstants sharedReaderConstants] showShadows]){ // Option + + backView.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); + backView.layer.shadowRadius = 3.0f; backView.layer.shadowOpacity = 1.0f; + backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; + + } // end of showShadows Option [self insertSubview:backView belowSubview:textLabel]; @@ -459,11 +459,11 @@ - (void)showImage:(UIImage *)image tintView.frame = imageView.bounds; backView.bounds = viewRect; backView.center = location; -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option + if ([[ReaderConstants sharedReaderConstants] showShadows]){ // Option + + backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; + + } // end of showShadows Option } - (void)reuse @@ -478,11 +478,11 @@ - (void)reuse tintView.hidden = YES; tintView.frame = imageView.bounds; backView.frame = defaultRect; -#if (READER_SHOW_SHADOWS == TRUE) // Option - - backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; - -#endif // end of READER_SHOW_SHADOWS Option + if ([[ReaderConstants sharedReaderConstants] showShadows]){ // Option + + backView.layer.shadowPath = [UIBezierPath bezierPathWithRect:backView.bounds].CGPath; + + } // end of showShadows Option } - (void)showBookmark:(BOOL)show diff --git a/Sources/UIXToolbarView.m b/Sources/UIXToolbarView.m index 1019df6e..c227ade3 100644 --- a/Sources/UIXToolbarView.m +++ b/Sources/UIXToolbarView.m @@ -38,11 +38,11 @@ @implementation UIXToolbarView + (Class)layerClass { -#if (READER_FLAT_UI == FALSE) // Option - return [CAGradientLayer class]; -#else - return [CALayer class]; -#endif // end of READER_FLAT_UI Option + if ([[ReaderConstants sharedReaderConstants] flatUI]) { // Option + return [CALayer class]; + } else { + return [CAGradientLayer class]; + } // end of flatUI Option } #pragma mark - UIXToolbarView instance methods From 01f0f45d8e66aa6f76deddfa5541b9626bd92079 Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Mon, 20 Oct 2014 21:25:06 -0500 Subject: [PATCH 4/8] Added an import flag for ReaderConstants.h in ReaderViewController. --- Sources/ReaderViewController.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ReaderViewController.h b/Sources/ReaderViewController.h index f05c5733..6828ae88 100644 --- a/Sources/ReaderViewController.h +++ b/Sources/ReaderViewController.h @@ -26,6 +26,7 @@ #import #import "ReaderDocument.h" +#import "ReaderConstants.h" @class ReaderViewController; From f21d4d09ba8060803cfd3c3efe300348d05410c0 Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Mon, 20 Oct 2014 21:26:47 -0500 Subject: [PATCH 5/8] Added an example comment on ReaderDemoController of the way you can customize the Constants flags. --- Classes/ReaderDemoController.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Classes/ReaderDemoController.m b/Classes/ReaderDemoController.m index 1e5cc7e6..f0144133 100644 --- a/Classes/ReaderDemoController.m +++ b/Classes/ReaderDemoController.m @@ -177,6 +177,24 @@ - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer NSString *filePath = [pdfs firstObject]; assert(filePath != nil); // Path to first PDF file ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase]; + + /* + + // You can customize the flags right here, before the ReaderViewController is init. + // All the flags (bools) have a default value. See ReaderConstants.m + + ReaderConstants *readerConstants = [ReaderConstants sharedReaderConstants]; + + readerConstants.flatUI = ; + readerConstants.showShadows = ; + readerConstants.enableThumbs = ; + readerConstants.disableRetina = ; + readerConstants.enablePreview = ; + readerConstants.disableIdle = ; + readerConstants.standalone = ; + readerConstants.bookmarks = ; + + */ if (document != nil) // Must have a valid ReaderDocument object in order to proceed with things { From 002b137b9bd838785c91a0d11718470a3df3ebcc Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Mon, 20 Oct 2014 21:47:04 -0500 Subject: [PATCH 6/8] Fix on documentation of ReaderConstants. --- Sources/ReaderConstants.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ReaderConstants.h b/Sources/ReaderConstants.h index 2d72b744..9cf1af99 100644 --- a/Sources/ReaderConstants.h +++ b/Sources/ReaderConstants.h @@ -35,7 +35,7 @@ /** * If TRUE, follows the Fuglyosity of Flat Fad (flattens the UI). - * Default . + * Default YES if iOS version is equal or greater than 7.0. */ @property (nonatomic, assign) BOOL flatUI; From 2d6637882e2133f506a07e4c0e55d5b30d03e771 Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Tue, 21 Oct 2014 00:15:37 -0500 Subject: [PATCH 7/8] Added ReaderColors to centralize some colors that con be customize. Added textColor and toolbarBackground color. --- Classes/ReaderDemoController.m | 41 +++++++++++++++------ Reader.xcodeproj/project.pbxproj | 6 ++++ Sources/ReaderColors.h | 47 ++++++++++++++++++++++++ Sources/ReaderColors.m | 62 ++++++++++++++++++++++++++++++++ Sources/ReaderMainPagebar.m | 7 ++-- Sources/ReaderMainToolbar.m | 3 +- Sources/ReaderViewController.h | 1 + Sources/ReaderViewController.m | 1 - Sources/ThumbsMainToolbar.m | 3 +- Sources/UIXToolbarView.m | 7 ++-- 10 files changed, 158 insertions(+), 20 deletions(-) create mode 100644 Sources/ReaderColors.h create mode 100644 Sources/ReaderColors.m diff --git a/Classes/ReaderDemoController.m b/Classes/ReaderDemoController.m index f0144133..2623c0d5 100644 --- a/Classes/ReaderDemoController.m +++ b/Classes/ReaderDemoController.m @@ -179,20 +179,39 @@ - (void)handleSingleTap:(UITapGestureRecognizer *)recognizer ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase]; /* + + // You can customize the flags right here, before the ReaderViewController is init. + // All the flags (bools) have a default value. See ReaderConstants.m + + ReaderConstants *readerConstants = [ReaderConstants sharedReaderConstants]; + + readerConstants.flatUI = ; + readerConstants.showShadows = ; + readerConstants.enableThumbs = ; + readerConstants.disableRetina = ; + readerConstants.enablePreview = ; + readerConstants.disableIdle = ; + readerConstants.standalone = ; + readerConstants.bookmarks = ; + + */ - // You can customize the flags right here, before the ReaderViewController is init. - // All the flags (bools) have a default value. See ReaderConstants.m + /* - ReaderConstants *readerConstants = [ReaderConstants sharedReaderConstants]; + // You can customize the colors right here, before the ReaderViewController is init. + // All the colors (NSArray, UIColor) have a default value and manage the alpha of the view too. + // See ReaderColors.m + + ReaderColors *readerColors = [ReaderColors sharedReaderColors]; + + if ([[ReaderConstants sharedReaderConstants] flatUI]) { + readerColors.toolbarBackgroundColor = @[[UIColor colorWithWhite:<#(CGFloat)#> alpha:<#(CGFloat)#>]]; + } else { + readerColors.toolbarBackgroundColor = @[[UIColor colorWithWhite:<#(CGFloat)#> alpha:<#(CGFloat)#>], + [UIColor colorWithWhite:<#(CGFloat)#> alpha:<#(CGFloat)#>]]; + } - readerConstants.flatUI = ; - readerConstants.showShadows = ; - readerConstants.enableThumbs = ; - readerConstants.disableRetina = ; - readerConstants.enablePreview = ; - readerConstants.disableIdle = ; - readerConstants.standalone = ; - readerConstants.bookmarks = ; + readerColors.textColor = [UIColor color]; */ diff --git a/Reader.xcodeproj/project.pbxproj b/Reader.xcodeproj/project.pbxproj index ad9319cd..51fe96ce 100644 --- a/Reader.xcodeproj/project.pbxproj +++ b/Reader.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 115DB42019F609FC006B76A2 /* ReaderColors.m in Sources */ = {isa = PBXBuildFile; fileRef = 115DB41F19F609FC006B76A2 /* ReaderColors.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; @@ -67,6 +68,8 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 115DB41E19F609FC006B76A2 /* ReaderColors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ReaderColors.h; path = Sources/ReaderColors.h; sourceTree = ""; }; + 115DB41F19F609FC006B76A2 /* ReaderColors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ReaderColors.m; path = Sources/ReaderColors.m; sourceTree = ""; }; 11EB39D819F5DCDC007134F4 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D6058910D05DD3D006BFB54 /* Reader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Reader.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -308,6 +311,8 @@ children = ( 45AB72EF141FC0B1003524C3 /* ReaderConstants.h */, 45AB72F0141FC0B1003524C3 /* ReaderConstants.m */, + 115DB41E19F609FC006B76A2 /* ReaderColors.h */, + 115DB41F19F609FC006B76A2 /* ReaderColors.m */, 45AB72F7141FC0B1003524C3 /* ReaderDocument.h */, 45AB72F8141FC0B1003524C3 /* ReaderDocument.m */, 45AB730D141FC0B1003524C3 /* ReaderViewController.h */, @@ -457,6 +462,7 @@ 45AB7319141FC0B1003524C3 /* ReaderMainPagebar.m in Sources */, 45AB731A141FC0B1003524C3 /* ReaderMainToolbar.m in Sources */, 45AB731C141FC0B1003524C3 /* ReaderThumbCache.m in Sources */, + 115DB42019F609FC006B76A2 /* ReaderColors.m in Sources */, 45AB731D141FC0B1003524C3 /* ReaderThumbFetch.m in Sources */, 45AB731E141FC0B1003524C3 /* ReaderThumbQueue.m in Sources */, 45AB731F141FC0B1003524C3 /* ReaderThumbRender.m in Sources */, diff --git a/Sources/ReaderColors.h b/Sources/ReaderColors.h new file mode 100644 index 00000000..6dcd0905 --- /dev/null +++ b/Sources/ReaderColors.h @@ -0,0 +1,47 @@ +// +// ReaderColors.m +// Reader vX.X.X +// +// Created by Guillermo Sáenz Urday on 2014-10-20. +// Copyright © 2011-2014 Julius Oklamcak. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to +// do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#import + +@interface ReaderColors : NSObject + ++ (ReaderColors *)sharedReaderColors; + +/** + * MainToolbar and MainPagebar color. If flatUI is enable then you have to put only 1 color in the array if not you have to put 2 colors that will make the gradient. The colors also manage the alpha value of the view. + * See ReaderColors.m + * + * Default if flatUI is enable is white if not is a gradient from a lite color to a dark one. + */ +@property (nonatomic, strong) NSArray *toolbarBackgroundColor; + +/** + * Toolbar text color + * + * Default Black + */ +@property (nonatomic, strong) UIColor *textColor; + +@end diff --git a/Sources/ReaderColors.m b/Sources/ReaderColors.m new file mode 100644 index 00000000..0c50c688 --- /dev/null +++ b/Sources/ReaderColors.m @@ -0,0 +1,62 @@ +// +// ReaderColors.m +// Reader vX.X.X +// +// Created by Guillermo Sáenz Urday on 2014-10-20. +// Copyright © 2011-2014 Julius Oklamcak. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to +// do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#import "ReaderColors.h" +#import "ReaderConstants.h" + +@implementation ReaderColors + ++ (ReaderColors *)sharedReaderColors{ + static ReaderColors *_sharedReaderColors = nil; + + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedReaderColors = [[self alloc] init]; + }); + + return _sharedReaderColors; +} + +- (instancetype)init{ + self = [super init]; + + if (self) { + // Default Values + + if ([[ReaderConstants sharedReaderConstants] flatUI]) { + self.toolbarBackgroundColor = @[[UIColor colorWithWhite:0.94f alpha:0.94f]]; + } else { + self.toolbarBackgroundColor = @[[UIColor colorWithWhite:0.92f alpha:0.8f], + [UIColor colorWithWhite:0.32f alpha:0.8f]]; + ; + } + + self.textColor = [UIColor blackColor]; + } + + return self; +} + +@end diff --git a/Sources/ReaderMainPagebar.m b/Sources/ReaderMainPagebar.m index 3f24fca9..aec46bdf 100644 --- a/Sources/ReaderMainPagebar.m +++ b/Sources/ReaderMainPagebar.m @@ -24,6 +24,7 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "ReaderMainPagebar.h" #import "ReaderThumbCache.h" #import "ReaderDocument.h" @@ -158,8 +159,8 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object self.backgroundColor = [UIColor clearColor]; CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.82f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; + UIColor *liteColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] firstObject]; + UIColor *darkColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] lastObject]; layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; CGRect shadowRect = self.bounds; shadowRect.size.height = SHADOW_HEIGHT; shadowRect.origin.y -= shadowRect.size.height; @@ -170,7 +171,7 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)object } else // Follow The Fuglyosity of Flat Fad { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; + self.backgroundColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] firstObject]; CGRect lineRect = self.bounds; lineRect.size.height = 1.0f; lineRect.origin.y -= lineRect.size.height; diff --git a/Sources/ReaderMainToolbar.m b/Sources/ReaderMainToolbar.m index f359a890..f0b7fd3c 100644 --- a/Sources/ReaderMainToolbar.m +++ b/Sources/ReaderMainToolbar.m @@ -24,6 +24,7 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "ReaderMainToolbar.h" #import "ReaderDocument.h" @@ -231,7 +232,7 @@ - (instancetype)initWithFrame:(CGRect)frame document:(ReaderDocument *)document titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; + titleLabel.textColor = [[ReaderColors sharedReaderColors] textColor]; titleLabel.backgroundColor = [UIColor clearColor]; titleLabel.adjustsFontSizeToFitWidth = YES; titleLabel.minimumScaleFactor = 0.75f; diff --git a/Sources/ReaderViewController.h b/Sources/ReaderViewController.h index 6828ae88..163d2377 100644 --- a/Sources/ReaderViewController.h +++ b/Sources/ReaderViewController.h @@ -27,6 +27,7 @@ #import "ReaderDocument.h" #import "ReaderConstants.h" +#import "ReaderColors.h" @class ReaderViewController; diff --git a/Sources/ReaderViewController.m b/Sources/ReaderViewController.m index 35da6a22..fb5d00bc 100644 --- a/Sources/ReaderViewController.m +++ b/Sources/ReaderViewController.m @@ -23,7 +23,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#import "ReaderConstants.h" #import "ReaderViewController.h" #import "ThumbsViewController.h" #import "ReaderMainToolbar.h" diff --git a/Sources/ThumbsMainToolbar.m b/Sources/ThumbsMainToolbar.m index 794f5de8..5ca25672 100644 --- a/Sources/ThumbsMainToolbar.m +++ b/Sources/ThumbsMainToolbar.m @@ -24,6 +24,7 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "ThumbsMainToolbar.h" @implementation ThumbsMainToolbar{ @@ -136,7 +137,7 @@ - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title titleLabel.font = [UIFont systemFontOfSize:TITLE_FONT_SIZE]; titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth; titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - titleLabel.textColor = [UIColor colorWithWhite:0.0f alpha:1.0f]; + titleLabel.textColor = [[ReaderColors sharedReaderColors] textColor]; titleLabel.backgroundColor = [UIColor clearColor]; titleLabel.adjustsFontSizeToFitWidth = YES; titleLabel.minimumScaleFactor = 0.75f; diff --git a/Sources/UIXToolbarView.m b/Sources/UIXToolbarView.m index c227ade3..a19cca61 100644 --- a/Sources/UIXToolbarView.m +++ b/Sources/UIXToolbarView.m @@ -24,6 +24,7 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "UIXToolbarView.h" #import @@ -61,8 +62,8 @@ - (instancetype)initWithFrame:(CGRect)frame self.backgroundColor = [UIColor clearColor]; CAGradientLayer *layer = (CAGradientLayer *)self.layer; - UIColor *liteColor = [UIColor colorWithWhite:0.92f alpha:0.8f]; - UIColor *darkColor = [UIColor colorWithWhite:0.32f alpha:0.8f]; + UIColor *liteColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] firstObject]; + UIColor *darkColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] lastObject]; layer.colors = [NSArray arrayWithObjects:(id)liteColor.CGColor, (id)darkColor.CGColor, nil]; CGRect shadowRect = self.bounds; shadowRect.origin.y += shadowRect.size.height; shadowRect.size.height = SHADOW_HEIGHT; @@ -73,7 +74,7 @@ - (instancetype)initWithFrame:(CGRect)frame } else // Follow The Fuglyosity of Flat Fad { - self.backgroundColor = [UIColor colorWithWhite:0.94f alpha:0.94f]; + self.backgroundColor = [[[ReaderColors sharedReaderColors] toolbarBackgroundColor] firstObject]; CGRect lineRect = self.bounds; lineRect.origin.y += lineRect.size.height; lineRect.size.height = 1.0f; From 5236f460d096a41728dde2c68502c5b14b25803d Mon Sep 17 00:00:00 2001 From: Guillermo Saenz Date: Tue, 21 Oct 2014 00:16:09 -0500 Subject: [PATCH 8/8] Fix on the documentation. --- Sources/ReaderConstants.h | 10 +++++++++- Sources/ReaderConstants.m | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Sources/ReaderConstants.h b/Sources/ReaderConstants.h index 9cf1af99..51d68844 100644 --- a/Sources/ReaderConstants.h +++ b/Sources/ReaderConstants.h @@ -35,50 +35,58 @@ /** * If TRUE, follows the Fuglyosity of Flat Fad (flattens the UI). + * * Default YES if iOS version is equal or greater than 7.0. */ @property (nonatomic, assign) BOOL flatUI; /** * If TRUE, a shadow is shown around each page and page thumbnail. + * * Default YES. */ @property (nonatomic, assign) BOOL showShadows; /** * If TRUE, a thumbs button is added to the main toolbar enabling page thumbnail document navigation. + * * Default YES. */ @property (nonatomic, assign) BOOL enableThumbs; /** * If TRUE, sets the CATiledLayer contentScale to 1.0f. This effectively disables retina support and results in non-retina device rendering speeds on retina display devices at the loss of retina display quality. + * * Default NO. */ @property (nonatomic, assign) BOOL disableRetina; /** * If TRUE, a medium resolution page thumbnail is displayed before the CATiledLayer starts to render the PDF page. + * * Default YES. */ @property (nonatomic, assign) BOOL enablePreview; /** * If TRUE, the iOS idle timer is disabled while viewing a document (beware of battery drain). + * * Default NO. */ @property (nonatomic, assign) BOOL disableIdle; /** * If FALSE, a "Done" button is added to the toolbar and the -dismissReaderViewController: delegate method is messaged when it is tapped. + * * Default NO. */ @property (nonatomic, assign) BOOL standalone; /** * If TRUE, enables page bookmark support. + * * Default YES. */ @property (nonatomic, assign) BOOL bookmarks; -@end \ No newline at end of file +@end diff --git a/Sources/ReaderConstants.m b/Sources/ReaderConstants.m index efec144c..94f7357a 100644 --- a/Sources/ReaderConstants.m +++ b/Sources/ReaderConstants.m @@ -66,4 +66,3 @@ + (BOOL)isAtLeastiOS7{ } @end -