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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Classes/ReaderDemoController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
9 changes: 9 additions & 0 deletions Reader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
115DB41F19F609FC006B76A2 /* ReaderColors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ReaderColors.m; path = Sources/ReaderColors.m; sourceTree = "<group>"; };
11EB39D819F5DCDC007134F4 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
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; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -391,6 +397,7 @@
knownRegions = (
en,
de,
es,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
Expand Down Expand Up @@ -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 */,
Expand All @@ -478,6 +486,7 @@
children = (
4541A9D5122EA686001A5E60 /* en */,
458BF155143E077500CDF567 /* de */,
11EB39D819F5DCDC007134F4 /* es */,
);
name = Localizable.strings;
sourceTree = "<group>";
Expand Down
47 changes: 47 additions & 0 deletions Sources/ReaderColors.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

@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
62 changes: 62 additions & 0 deletions Sources/ReaderColors.m
Original file line number Diff line number Diff line change
@@ -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
69 changes: 61 additions & 8 deletions Sources/ReaderConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,64 @@

#import <Foundation/Foundation.h>

#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
40 changes: 40 additions & 0 deletions Sources/ReaderConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions Sources/ReaderContentPage.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading