Skip to content

Commit abffa0c

Browse files
authored
Merge pull request #14 from PSPDFKit/rad/update-to-pspdfkit7
Update to PSPDFKit 7.0.0 and Titanium SDK 6.2.2.GA
2 parents 048ae8d + c2a5b60 commit abffa0c

15 files changed

+80
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ com.pspdfkit*
2525
PSPDFKit
2626

2727
PSPDFKit.framework
28+
PSPDFKitUI.framework
2829

2930
metadata.json

Classes/ComPspdfkitModule.m

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,22 @@ - (TIPSPDFViewControllerProxy *)pspdf_displayPdfInternal:(NSArray *)pdfNames ani
121121
PSPDFAESCryptoDataProvider *cryptoWrapper = [[PSPDFAESCryptoDataProvider alloc] initWithURL:pdfURL passphraseProvider:^NSString *{
122122
return passphrase;
123123
} salt:salt rounds:PSPDFDefaultPBKDFNumberOfRounds];
124-
document = [PSPDFDocument documentWithDataProvider:cryptoWrapper];
124+
document = [[PSPDFDocument alloc] initWithDataProviders:@[cryptoWrapper]];
125125
}
126126

127-
if (!document) document = [[PSPDFDocument alloc] initWithBaseURL:nil files:pdfNames];
127+
if (!document) {
128+
NSMutableArray<PSPDFCoordinatedFileDataProvider *> *dataProviders = [NSMutableArray array];
129+
for (NSString *pdfPath in pdfNames) {
130+
NSURL *pdfURL = [NSURL fileURLWithPath:pdfPath isDirectory:NO];
131+
if ([pdfURL.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
132+
PSPDFCoordinatedFileDataProvider *coordinatedFileDataProvider = [[PSPDFCoordinatedFileDataProvider alloc] initWithFileURL:pdfURL];
133+
if (coordinatedFileDataProvider) {
134+
[dataProviders addObject:coordinatedFileDataProvider];
135+
}
136+
}
137+
}
138+
document = [[PSPDFDocument alloc] initWithDataProviders:dataProviders];
139+
}
128140

129141
TIPSPDFViewController *pdfController = [[TIPSPDFViewController alloc] initWithDocument:document];
130142

@@ -217,9 +229,7 @@ - (void)cacheDocument:(id)args {
217229
NSArray *documents = [PSPDFUtils documentsFromArgs:args];
218230
for (PSPDFDocument *document in documents) {
219231
[[PSPDFKit sharedInstance].cache cacheDocument:document
220-
pageSizes:@[[NSValue valueWithCGSize:CGSizeMake(170.f, 220.f)], [NSValue valueWithCGSize:UIScreen.mainScreen.bounds.size]]
221-
withDiskCacheStrategy:PSPDFDiskCacheStrategyEverything
222-
aroundPageAtIndex:0];
232+
withPageSizes:@[[NSValue valueWithCGSize:CGSizeMake(170.f, 220.f)], [NSValue valueWithCGSize:UIScreen.mainScreen.bounds.size]]];
223233
}
224234
}
225235

Classes/ComPspdfkitView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//
1212

1313
#import "TIPSPDFViewControllerProxy.h"
14-
#import "TiUiViewProxy.h"
14+
#import "TiUIViewProxy.h"
1515

1616
@interface ComPspdfkitView : TiUIView
1717
@property (nonatomic) TIPSPDFViewControllerProxy *controllerProxy;

Classes/ComPspdfkitView.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@ - (void)createControllerProxy {
2929

3030
if (!_controllerProxy) { // self triggers creation
3131
NSArray *pdfPaths = [PSPDFUtils resolvePaths:[self.proxy valueForKey:@"filename"]];
32-
PSPDFDocument *pdfDocument = [[PSPDFDocument alloc] initWithBaseURL:nil files:pdfPaths];
32+
NSMutableArray<PSPDFCoordinatedFileDataProvider *> *dataProviders = [NSMutableArray array];
33+
for (NSString *pdfPath in pdfPaths) {
34+
NSURL *pdfURL = [NSURL fileURLWithPath:pdfPath isDirectory:NO];
35+
if ([pdfURL.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
36+
PSPDFCoordinatedFileDataProvider *coordinatedFileDataProvider = [[PSPDFCoordinatedFileDataProvider alloc] initWithFileURL:pdfURL];
37+
if (coordinatedFileDataProvider) {
38+
[dataProviders addObject:coordinatedFileDataProvider];
39+
}
40+
}
41+
}
42+
43+
PSPDFDocument *pdfDocument = [[PSPDFDocument alloc] initWithDataProviders:dataProviders];
3344
TIPSPDFViewController *pdfController = [[TIPSPDFViewController alloc] initWithDocument:pdfDocument];
3445

3546
NSDictionary *options = [self.proxy valueForKey:@"options"];
@@ -51,7 +62,7 @@ - (void)createControllerProxy {
5162

5263
// Support for tinting the navigation controller/bar
5364
if (options[@"barColor"]) {
54-
UIColor *barColor = [[TiColor colorNamed:options[@"barColor"]] color];
65+
UIColor *barColor = [[TiColor colorNamed:options[@"barColor"]] _color];
5566
if (barColor) {
5667
navController.navigationBar.tintColor = barColor;
5768
}

Classes/ComPspdfkitViewProxy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
- (void)setAllowedMenuActions:(id)arg;
6868

6969
/// Expose the scrollingEnabled property
70-
- (void)setScrollingEnabled:(id)arg;
70+
- (void)setScrollEnabled:(id)arg;
7171

7272
/// Return document path.
7373
- (id)documentPath;

Classes/ComPspdfkitViewProxy.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ - (void)setEditableAnnotationTypes:(id)arg {
157157
[[[self pdfView] controllerProxy] setEditableAnnotationTypes:arg];
158158
}
159159

160-
- (void)setScrollingEnabled:(id)arg {
161-
ENSURE_UI_THREAD(setScrollingEnabled, arg);
162-
[[[self pdfView] controllerProxy] setScrollingEnabled:arg];
160+
- (void)setScrollEnabled:(id)arg {
161+
ENSURE_UI_THREAD(setScrollEnabled, arg);
162+
[[[self pdfView] controllerProxy] setScrollEnabled:arg];
163163
}
164164

165165
- (void)setPrintOptions:(id)arg {

Classes/PSPDFUtils.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ + (void)applyOptions:(NSDictionary *)options onObject:(id)object {
7272

7373
// convert color
7474
if ([key rangeOfString:@"color" options:NSCaseInsensitiveSearch].length > 0) {
75-
value = [[TiColor colorNamed:value] color];
75+
value = [[TiColor colorNamed:value] _color];
7676
}
7777

7878
// special handling for toolbar

Classes/TIPSPDFViewControllerProxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
/// Document's menu actions.
110110
- (void)setAllowedMenuActions:(id)arg;
111111

112-
/// Expose the scrollingEnabled property
113-
- (void)setScrollingEnabled:(id)args;
112+
/// Expose the scrollEnabled property
113+
- (void)setScrollEnabled:(id)args;
114114

115115
// Save changed annotations.
116116
- (void)saveAnnotations:(id)args;

Classes/TIPSPDFViewControllerProxy.m

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ - (void)setAllowedMenuActions:(id)arg {
220220
}
221221
}
222222

223-
- (void)setScrollingEnabled:(id)args {
224-
ENSURE_UI_THREAD(setScrollingEnabled, args);
223+
- (void)setScrollEnabled:(id)args {
224+
ENSURE_UI_THREAD(setScrollEnabled, args);
225225

226226
NSUInteger pageValue = [PSPDFUtils intValue:args onPosition:0];
227-
[_controller setScrollingEnabled:pageValue];
227+
[_controller.documentViewController setScrollEnabled:pageValue];
228228
}
229229

230230
- (void)scrollToPage:(id)args {
@@ -287,7 +287,7 @@ - (void)saveAnnotations:(id)args {
287287
ENSURE_UI_THREAD(saveAnnotations, args);
288288

289289
NSError *error = nil;
290-
BOOL success = [self.controller.document save:&error];
290+
BOOL success = [self.controller.document saveWithOptions:nil error:&error];
291291
if (!success && self.controller.configuration.isTextSelectionEnabled) {
292292
PSCLog(@"Saving annotations failed: %@", [error localizedDescription]);
293293
}
@@ -413,7 +413,7 @@ - (TiProxy *)eventProxy {
413413
}
414414

415415
/// delegate for tapping on an annotation. If you don't implement this or return false, it will be processed by default action (scroll to page, ask to open Safari)
416-
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController didTapOnAnnotation:(PSPDFAnnotation *)annotation annotationPoint:(CGPoint)annotationPoint annotationView:(UIView<PSPDFAnnotationViewProtocol> *)annotationView pageView:(PSPDFPageView *)pageView viewPoint:(CGPoint)viewPoint {
416+
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController didTapOnAnnotation:(PSPDFAnnotation *)annotation annotationPoint:(CGPoint)annotationPoint annotationView:(UIView<PSPDFAnnotationPresenting> *)annotationView pageView:(PSPDFPageView *)pageView viewPoint:(CGPoint)viewPoint {
417417
NSParameterAssert([pdfController isKindOfClass:[TIPSPDFViewController class]]);
418418

419419
NSMutableDictionary *eventDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:pageView.pageIndex], @"page", nil];
@@ -482,7 +482,7 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didChangeViewMode
482482
}
483483
}
484484

485-
- (UIView <PSPDFAnnotationViewProtocol> *)pdfViewController:(PSPDFViewController *)pdfController annotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView forAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView {
485+
- (UIView <PSPDFAnnotationPresenting> *)pdfViewController:(PSPDFViewController *)pdfController annotationView:(UIView <PSPDFAnnotationPresenting> *)annotationView forAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView {
486486

487487
if (annotation.type == PSPDFAnnotationTypeLink && [annotationView isKindOfClass:[PSPDFLinkAnnotationView class]]) {
488488
PSPDFLinkAnnotationView *linkAnnotation = (PSPDFLinkAnnotationView *)annotationView;
@@ -496,35 +496,35 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didChangeViewMode
496496
return annotationView;
497497
}
498498

499-
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowHUD:(BOOL)animated {
500-
if ([[self eventProxy] _hasListeners:@"shouldShowHUD"]) {
501-
[[self eventProxy] fireEvent:@"shouldShowHUD" withObject:nil];
499+
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowUserInterface:(BOOL)animated {
500+
if ([[self eventProxy] _hasListeners:@"shouldShowUserInterface"]) {
501+
[[self eventProxy] fireEvent:@"shouldShowUserInterface" withObject:nil];
502502
}
503-
if ([[self eventProxy] _hasListeners:@"willShowHUD"]) {
504-
[[self eventProxy] fireEvent:@"willShowHUD" withObject:nil];
503+
if ([[self eventProxy] _hasListeners:@"willShowUserInterface"]) {
504+
[[self eventProxy] fireEvent:@"willShowUserInterface" withObject:nil];
505505
}
506506
return YES;
507507
}
508508

509-
- (void)pdfViewController:(PSPDFViewController *)pdfController didShowHUD:(BOOL)animated {
510-
if ([[self eventProxy] _hasListeners:@"didShowHUD"]) {
511-
[[self eventProxy] fireEvent:@"didShowHUD" withObject:nil];
509+
- (void)pdfViewController:(PSPDFViewController *)pdfController didShowUserInterface:(BOOL)animated {
510+
if ([[self eventProxy] _hasListeners:@"didShowUserInterface"]) {
511+
[[self eventProxy] fireEvent:@"didShowUserInterface" withObject:nil];
512512
}
513513
}
514514

515-
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldHideHUD:(BOOL)animated {
516-
if ([[self eventProxy] _hasListeners:@"shouldHideHUD"]) {
517-
[[self eventProxy] fireEvent:@"shouldHideHUD" withObject:nil];
515+
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldHideUserInterface:(BOOL)animated {
516+
if ([[self eventProxy] _hasListeners:@"shouldHideUserInterface"]) {
517+
[[self eventProxy] fireEvent:@"shouldHideUserInterface" withObject:nil];
518518
}
519-
if ([[self eventProxy] _hasListeners:@"willHideHUD"]) {
520-
[[self eventProxy] fireEvent:@"willHideHUD" withObject:nil];
519+
if ([[self eventProxy] _hasListeners:@"willHideUserInterface"]) {
520+
[[self eventProxy] fireEvent:@"willHideUserInterface" withObject:nil];
521521
}
522522
return YES;
523523
}
524524

525-
- (void)pdfViewController:(PSPDFViewController *)pdfController didHideHUD:(BOOL)animated {
526-
if ([[self eventProxy] _hasListeners:@"didHideHUD"]) {
527-
[[self eventProxy] fireEvent:@"didHideHUD" withObject:nil];
525+
- (void)pdfViewController:(PSPDFViewController *)pdfController didHideUserInterface:(BOOL)animated {
526+
if ([[self eventProxy] _hasListeners:@"didHideUserInterface"]) {
527+
[[self eventProxy] fireEvent:@"didHideUserInterface" withObject:nil];
528528
}
529529
}
530530

ComPspdfkit_Prefix.pch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#import <UIKit/UIKit.h>
66
#import <Foundation/Foundation.h>
77
#import "PSPDFKit.h"
8+
#import "PSPDFKitUI.h"
89
#endif
910

1011
// Logging

0 commit comments

Comments
 (0)