diff --git a/Classes/ReaderDemoController.m b/Classes/ReaderDemoController.m index 1e5cc7e6..2623c0d5 100644 --- a/Classes/ReaderDemoController.m +++ b/Classes/ReaderDemoController.m @@ -177,6 +177,43 @@ - (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 = ; + + */ + + /* + + // 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)#>]]; + } + + readerColors.textColor = [UIColor color]; + + */ if (document != nil) // Must have a valid ReaderDocument object in order to proceed with things { diff --git a/Reader.xcodeproj/project.pbxproj b/Reader.xcodeproj/project.pbxproj index 3c8d2376..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,9 @@ /* 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; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; @@ -307,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 */, @@ -391,6 +397,7 @@ knownRegions = ( en, de, + es, ); mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; projectDirPath = ""; @@ -455,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 */, @@ -478,6 +486,7 @@ children = ( 4541A9D5122EA686001A5E60 /* en */, 458BF155143E077500CDF567 /* de */, + 11EB39D819F5DCDC007134F4 /* es */, ); name = Localizable.strings; sourceTree = ""; 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/ReaderConstants.h b/Sources/ReaderConstants.h index b09f2e65..51d68844 100644 --- a/Sources/ReaderConstants.h +++ b/Sources/ReaderConstants.h @@ -29,11 +29,64 @@ #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 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 diff --git a/Sources/ReaderConstants.m b/Sources/ReaderConstants.m index b58cc373..94f7357a 100644 --- a/Sources/ReaderConstants.m +++ b/Sources/ReaderConstants.m @@ -26,3 +26,43 @@ #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 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..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" @@ -71,13 +72,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 @@ -159,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; @@ -171,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 8073a6c8..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" @@ -35,6 +36,9 @@ @implementation ReaderMainToolbar UIImage *markImageN; UIImage *markImageY; + + UIImage *buttonH; + UIImage *buttonN; } #pragma mark - Constants @@ -72,12 +76,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 +89,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 { @@ -229,15 +232,16 @@ - (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; 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 +252,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.h b/Sources/ReaderViewController.h index f05c5733..163d2377 100644 --- a/Sources/ReaderViewController.h +++ b/Sources/ReaderViewController.h @@ -26,6 +26,8 @@ #import #import "ReaderDocument.h" +#import "ReaderConstants.h" +#import "ReaderColors.h" @class ReaderViewController; diff --git a/Sources/ReaderViewController.m b/Sources/ReaderViewController.m index 3d326efb..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" @@ -410,11 +409,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 +422,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 +711,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 +828,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 +866,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..5ca25672 100644 --- a/Sources/ThumbsMainToolbar.m +++ b/Sources/ThumbsMainToolbar.m @@ -24,9 +24,13 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "ThumbsMainToolbar.h" -@implementation ThumbsMainToolbar +@implementation ThumbsMainToolbar{ + UIImage *buttonH; + UIImage *buttonN; +} #pragma mark - Constants @@ -62,12 +66,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 +100,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 { @@ -135,15 +137,16 @@ - (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; 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..a19cca61 100644 --- a/Sources/UIXToolbarView.m +++ b/Sources/UIXToolbarView.m @@ -24,6 +24,7 @@ // #import "ReaderConstants.h" +#import "ReaderColors.h" #import "UIXToolbarView.h" #import @@ -38,11 +39,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 @@ -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; diff --git a/es.lproj/Localizable.strings b/es.lproj/Localizable.strings new file mode 100644 index 00000000..3d5bc724 Binary files /dev/null and b/es.lproj/Localizable.strings differ