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
2 changes: 1 addition & 1 deletion Externals/TouchUI/Geometry.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ CGRect ScaleAndAlignRectToRect(CGRect inImageRect, CGRect inDestinationRect, EIm

NSString *NSStringFromCIntegerPoint(CIntegerPoint inPoint)
{
return([NSString stringWithFormat:@"%d,%d", inPoint.x, inPoint.y]);
return([NSString stringWithFormat:@"%ld,%ld", (long)inPoint.x, (long)inPoint.y]);
}

extern CIntegerPoint CIntegerPointFromString(NSString *inString)
Expand Down
2 changes: 1 addition & 1 deletion Source/Library/CLibraryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (void)viewDidLoad
{
[super viewDidLoad];

self.title = @"Library";
self.title = LocStringModule(@"STR_TITLE", @"iOS-PDF-Reader"); //@"Library";


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidOpenURL:) name:@"applicationDidOpenURL" object:NULL];
Expand Down
2 changes: 1 addition & 1 deletion Source/PDF Model/CPDFDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (NSString *)title

- (CPDFPage *)pageForPageNumber:(NSInteger)inPageNumber
{
NSString *theKey = [NSString stringWithFormat:@"page_%d", inPageNumber];
NSString *theKey = [NSString stringWithFormat:@"page_%ld", (long)inPageNumber];
CPDFPage *thePage = [self.cache objectForKey:theKey];
if (thePage == NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions Source/PDF Model/CPDFPage.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ - (id)initWithDocument:(CPDFDocument *)inDocument pageNumber:(NSInteger)inPageNu

- (NSString *)description
{
return([NSString stringWithFormat:@"%@ (#%d, %@)", [super description], self.pageNumber, NSStringFromCGRect(self.mediaBox)]);
return([NSString stringWithFormat:@"%@ (#%ld, %@)", [super description], (long)self.pageNumber, NSStringFromCGRect(self.mediaBox)]);
}

- (CGPDFPageRef)cg
Expand Down Expand Up @@ -137,14 +137,14 @@ - (UIImage *)imageWithSize:(CGSize)inSize scale:(CGFloat)inScale

- (UIImage *)thumbnail
{
NSString *theKey = [NSString stringWithFormat:@"page_%d_image_128x128", self.pageNumber];
NSString *theKey = [NSString stringWithFormat:@"page_%ld_image_128x128", (long)self.pageNumber];
UIImage *theImage = [self.document.cache objectForKey:theKey];
return(theImage);
}

- (UIImage *)preview
{
NSString *theKey = [NSString stringWithFormat:@"page_%d_image_preview2", self.pageNumber];
NSString *theKey = [NSString stringWithFormat:@"page_%ld_image_preview2", (long)self.pageNumber];
UIImage *theImage = [self.document.cache objectForKey:theKey];
if (theImage == NULL)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/PDF Model/CPDFStream.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (NSString *)description
{
CGPDFDataFormat theFormat;
NSData *theData = (__bridge_transfer NSData *)CGPDFStreamCopyData(_stream, &theFormat);
return([NSString stringWithFormat:@"%@ (format: %d, length: %d)", [super description], theFormat, theData.length]);
return([NSString stringWithFormat:@"%@ (format: %d, length: %lu)", [super description], theFormat, (unsigned long)theData.length]);
}

- (NSData *)data
Expand All @@ -62,7 +62,7 @@ - (NSURL *)fileURLWithPathExtension:(NSString *)inPathExtension
size_t theBufferLength = strlen([thePath UTF8String]) + 1;
char thePathBuffer[theBufferLength];
strncpy(thePathBuffer, [thePath UTF8String], theBufferLength);
int theFileDescriptor = mkstemps(thePathBuffer, inPathExtension.length + 1);
int theFileDescriptor = mkstemps(thePathBuffer, (int)inPathExtension.length + 1);

NSData *theData = self.data;
write(theFileDescriptor, theData.bytes, inPathExtension.length + 1);
Expand Down
19 changes: 10 additions & 9 deletions Source/PDF UI/CPDFAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
#import "PDFUtilities.h"
#import "CPDFStream.h"

#import <MediaPlayer/MediaPlayer.h>
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>

@interface CPDFAnnotationView ()
@property (readwrite, nonatomic, strong) MPMoviePlayerController *moviePlayer;
@property (readwrite, nonatomic, strong) AVPlayer *moviePlayer;
@end

#pragma mark -
Expand Down Expand Up @@ -70,17 +71,17 @@ - (void)layoutSubviews

if (theURL)
{
self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theURL];
self.moviePlayer.view.frame = self.bounds;
self.moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.moviePlayer prepareToPlay];
[self addSubview:self.moviePlayer.view];

self.moviePlayer = [[AVPlayer alloc]initWithURL:theURL];
AVPlayerViewController* controller = [AVPlayerViewController new];
controller.allowsPictureInPicturePlayback = false;
controller.player = self.moviePlayer;
[controller.view setFrame:self.bounds];



double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// [self.moviePlayer play];
});
}
}
Expand Down
11 changes: 9 additions & 2 deletions Source/PDF UI/CPDFDocumentViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,24 @@

@class CPDFDocument;
@class CContentScrollView;
@class CPreviewBar;
@class CPDFPage;

@protocol CPDFDocumentViewControllerDelegate <NSObject>

@optional
- (void)didTap:(BOOL)thumbnailsVisible;
- (void)didChangeRotation:(UIInterfaceOrientation)orientation andThumbnailsVisible:(BOOL)thumbnailsVisible;

@end

@interface CPDFDocumentViewController : UIViewController

@property (readwrite, nonatomic, weak) id<CPDFDocumentViewControllerDelegate> delegate;
@property (readwrite, nonatomic, strong) NSURL *documentURL;
@property (readwrite, nonatomic, strong) CPDFDocument *document;

@property (readonly, nonatomic, strong) UIPageViewController *pageViewController;
@property (readwrite, nonatomic, strong) UIView *backgroundView;
@property (readwrite, nonatomic, assign) BOOL magazineMode;
@property (nonatomic) BOOL statusBarHidden;

- (BOOL)openPage:(CPDFPage *)inPage;
Expand Down
22 changes: 17 additions & 5 deletions Source/PDF UI/CPDFDocumentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ - (void)viewWillAppear:(BOOL)animated {
// select first cell. Both things are required to get the correct behaviour.
UICollectionViewCell *cell = [self.previewCollectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
[cell setSelected:YES];
[self.previewCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:nil];
[self.previewCollectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UICollectionViewScrollPositionNone];
});
}

Expand All @@ -270,29 +270,41 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInte
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self.renderedPageCache removeAllObjects];
[self populateCache];

if([self.delegate respondsToSelector:@selector(didChangeRotation:andThumbnailsVisible:)]) {
[self.delegate didChangeRotation:self.currentInterfaceOrientation andThumbnailsVisible:!self.chromeHidden];
}
}

- (void)hideChrome {
if (!self.chromeHidden) {
[UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{
self.navigationController.navigationBar.alpha = 0.0;
self.previewCollectionView.alpha = 0.0;
} completion:^(BOOL finished) {
self.chromeHidden = YES;

[self notifyDidTap];
}];
}
}

- (void)toggleChrome {
[UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{
CGFloat newAlpha = 1.0f - (self.chromeHidden ? 0.0f : 1.0f);
self.navigationController.navigationBar.alpha = newAlpha;
self.previewCollectionView.alpha = newAlpha;
} completion:^(BOOL finished) {
self.chromeHidden = !self.chromeHidden;

[self notifyDidTap];
}];
}

- (void) notifyDidTap {
if([self.delegate respondsToSelector:@selector(didTap:)]) {
[self.delegate didTap:!self.chromeHidden];
}
}

- (void)resizePageViewControllerForOrientation:(UIInterfaceOrientation)inOrientation {
CGRect theBounds = self.view.bounds;
CGRect theFrame;
Expand Down Expand Up @@ -403,7 +415,7 @@ - (void)populateCache {
CGRect theBounds = thePageView.bounds;

for (NSInteger thePageNumber = theStartPageNumber; thePageNumber <= theLastPageNumber; ++thePageNumber) {
NSString *theKey = [NSString stringWithFormat:@"%d[%d,%d]", thePageNumber, (int) theBounds.size.width, (int) theBounds.size.height];
NSString *theKey = [NSString stringWithFormat:@"%d[%d,%d]", (int)thePageNumber, (int) theBounds.size.width, (int) theBounds.size.height];
if ([self.renderedPageCache objectForKey:theKey] == NULL) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
UIImage *theImage = [[self.document pageForPageNumber:thePageNumber] imageWithSize:theBounds.size scale:[UIScreen mainScreen].scale];
Expand All @@ -425,7 +437,7 @@ - (UIViewController *)pageViewController:(UIPageViewController *)pageViewControl
return (NULL);
}

if (theNextPageNumber == 0 && UIInterfaceOrientationIsPortrait(self.currentInterfaceOrientation)) {
if (theNextPageNumber == 0 && (UIInterfaceOrientationIsPortrait(self.currentInterfaceOrientation) || self.document.numberOfPages == 1)) {
return (NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/PDF UI/CPreviewCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (instancetype)initWithFrame:(CGRect)frame
self.imageView = [[UIImageView alloc] init];
self.imageView.frame = self.frame;
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.viewForBaselineLayout addSubview:self.imageView];
[self.viewForLastBaselineLayout addSubview:self.imageView];
}
return self;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Support/NSURL_Extensions.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ + (NSString *)queryStringForDictionary:(NSDictionary *)inQueryDictionary
for (id subValue in theValue)
{
NSString *tempSubValue = [subValue description];
[theQueryComponents addObject:[NSString stringWithFormat:@"%@=%@", theKey, [tempSubValue stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
[theQueryComponents addObject:[NSString stringWithFormat:@"%@=%@", theKey, [tempSubValue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]]];
}
}
else
{
// this fixes the issue of spaces in values. %@ = [value description]
NSString *tempValue = [theValue description];
[theQueryComponents addObject:[NSString stringWithFormat:@"%@=%@", theKey, [tempValue stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
[theQueryComponents addObject:[NSString stringWithFormat:@"%@=%@", theKey, [tempValue stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]]];
}
}
return([theQueryComponents componentsJoinedByString:@"&"]);
Expand Down
9 changes: 9 additions & 0 deletions Source/Support/iOS-PDF-Reader.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
iOS-PDF-Reader.strings
DVAG

Created by Kevin Greim on 01.06.17.
Copyright © 2017 DVAG. All rights reserved.
*/

"STR_TITLE" = "Library";