diff --git a/Externals/TouchUI/Geometry.m b/Externals/TouchUI/Geometry.m index 1df5571..bcf2ef5 100755 --- a/Externals/TouchUI/Geometry.m +++ b/Externals/TouchUI/Geometry.m @@ -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) diff --git a/Source/Library/CLibraryViewController.m b/Source/Library/CLibraryViewController.m index c2a2f7f..22edb43 100644 --- a/Source/Library/CLibraryViewController.m +++ b/Source/Library/CLibraryViewController.m @@ -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]; diff --git a/Source/PDF Model/CPDFDocument.m b/Source/PDF Model/CPDFDocument.m index 5f12a1b..28258cc 100644 --- a/Source/PDF Model/CPDFDocument.m +++ b/Source/PDF Model/CPDFDocument.m @@ -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) { diff --git a/Source/PDF Model/CPDFPage.m b/Source/PDF Model/CPDFPage.m index ddd74fc..a9c42d9 100644 --- a/Source/PDF Model/CPDFPage.m +++ b/Source/PDF Model/CPDFPage.m @@ -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 @@ -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) { diff --git a/Source/PDF Model/CPDFStream.m b/Source/PDF Model/CPDFStream.m index 4311d70..4be5673 100644 --- a/Source/PDF Model/CPDFStream.m +++ b/Source/PDF Model/CPDFStream.m @@ -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 @@ -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); diff --git a/Source/PDF UI/CPDFAnnotationView.m b/Source/PDF UI/CPDFAnnotationView.m index 027e17f..1af8e8a 100644 --- a/Source/PDF UI/CPDFAnnotationView.m +++ b/Source/PDF UI/CPDFAnnotationView.m @@ -35,10 +35,11 @@ #import "PDFUtilities.h" #import "CPDFStream.h" -#import +#import +#import @interface CPDFAnnotationView () -@property (readwrite, nonatomic, strong) MPMoviePlayerController *moviePlayer; +@property (readwrite, nonatomic, strong) AVPlayer *moviePlayer; @end #pragma mark - @@ -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]; }); } } diff --git a/Source/PDF UI/CPDFDocumentViewController.h b/Source/PDF UI/CPDFDocumentViewController.h index 96268ed..be7d3b2 100644 --- a/Source/PDF UI/CPDFDocumentViewController.h +++ b/Source/PDF UI/CPDFDocumentViewController.h @@ -33,17 +33,24 @@ @class CPDFDocument; @class CContentScrollView; -@class CPreviewBar; @class CPDFPage; +@protocol CPDFDocumentViewControllerDelegate + +@optional +- (void)didTap:(BOOL)thumbnailsVisible; +- (void)didChangeRotation:(UIInterfaceOrientation)orientation andThumbnailsVisible:(BOOL)thumbnailsVisible; + +@end + @interface CPDFDocumentViewController : UIViewController +@property (readwrite, nonatomic, weak) id 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; diff --git a/Source/PDF UI/CPDFDocumentViewController.m b/Source/PDF UI/CPDFDocumentViewController.m index 6f9872f..00881d7 100644 --- a/Source/PDF UI/CPDFDocumentViewController.m +++ b/Source/PDF UI/CPDFDocumentViewController.m @@ -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]; }); } @@ -270,15 +270,20 @@ - (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]; }]; } } @@ -286,13 +291,20 @@ - (void)hideChrome { - (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; @@ -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]; @@ -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); } diff --git a/Source/PDF UI/CPreviewCollectionViewCell.m b/Source/PDF UI/CPreviewCollectionViewCell.m index 5167cf6..b40144f 100644 --- a/Source/PDF UI/CPreviewCollectionViewCell.m +++ b/Source/PDF UI/CPreviewCollectionViewCell.m @@ -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; } diff --git a/Source/Support/NSURL_Extensions.m b/Source/Support/NSURL_Extensions.m index 0ce34f0..c3a2370 100644 --- a/Source/Support/NSURL_Extensions.m +++ b/Source/Support/NSURL_Extensions.m @@ -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:@"&"]); diff --git a/Source/Support/iOS-PDF-Reader.strings b/Source/Support/iOS-PDF-Reader.strings new file mode 100644 index 0000000..52bc3aa --- /dev/null +++ b/Source/Support/iOS-PDF-Reader.strings @@ -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";