Skip to content

Commit 00b54b7

Browse files
author
Rad Azzouz
committed
Fix deprecated APIs
Also remove unimplemented (commented out)`PSPDFViewControllerDelegate` methods.
1 parent 8c55404 commit 00b54b7

File tree

2 files changed

+217
-465
lines changed

2 files changed

+217
-465
lines changed

CordovaDemo/platforms/ios/CordovaDemo/Plugins/com.pspdfkit.cordovaplugin/PSPDFKitPlugin.m

Lines changed: 33 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
545545

546546
@"PSPDFPageTransition":
547547

548-
@{@"scrollPerPage": @(PSPDFPageTransitionScrollPerPage),
548+
@{@"scrollPerSpread": @(PSPDFPageTransitionScrollPerSpread),
549549
@"scrollContinuous": @(PSPDFPageTransitionScrollContinuous),
550550
@"curl": @(PSPDFPageTransitionCurl)},
551551

@@ -572,18 +572,18 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
572572
@"openSafari": @(PSPDFLinkActionOpenSafari),
573573
@"inlineBrowser": @(PSPDFLinkActionInlineBrowser)},
574574

575-
@"PSPDFHUDViewMode":
575+
@"PSPDFUserInterfaceViewMode":
576576

577-
@{@"always": @(PSPDFHUDViewModeAlways),
578-
@"automatic": @(PSPDFHUDViewModeAutomatic),
579-
@"automaticNoFirstLastPage": @(PSPDFHUDViewModeAutomaticNoFirstLastPage),
580-
@"never": @(PSPDFHUDViewModeNever)},
577+
@{@"always": @(PSPDFUserInterfaceViewModeAlways),
578+
@"automatic": @(PSPDFUserInterfaceViewModeAutomatic),
579+
@"automaticNoFirstLastPage": @(PSPDFUserInterfaceViewModeAutomaticNoFirstLastPage),
580+
@"never": @(PSPDFUserInterfaceViewModeNever)},
581581

582-
@"PSPDFHUDViewAnimation":
582+
@"PSPDFUserInterfaceViewAnimation":
583583

584-
@{@"none": @(PSPDFHUDViewAnimationNone),
585-
@"fade": @(PSPDFHUDViewAnimationFade),
586-
@"slide": @(PSPDFHUDViewAnimationSlide)},
584+
@{@"none": @(PSPDFUserInterfaceViewAnimationNone),
585+
@"fade": @(PSPDFUserInterfaceViewAnimationFade),
586+
@"slide": @(PSPDFUserInterfaceViewAnimationSlide)},
587587

588588
@"PSPDFThumbnailBarMode":
589589

@@ -655,25 +655,6 @@ - (NSDictionary *)enumValuesOfType:(NSString *)type
655655
return enumsByType[type];
656656
}
657657

658-
///// Status bar style. (old status will be restored regardless of the style chosen)
659-
//typedef NS_ENUM(NSInteger, PSPDFStatusBarStyleSetting) {
660-
// PSPDFStatusBarInherit, // Don't change status bar style, but show/hide statusbar on HUD events.
661-
// PSPDFStatusBarSmartBlack, // UIStatusBarStyleBlackOpaque on iPad, UIStatusBarStyleBlackTranslucent on iPhone.
662-
// PSPDFStatusBarSmartBlackHideOnIpad,// Similar to PSPDFStatusBarSmartBlack, but also hides statusBar on iPad.
663-
// PSPDFStatusBarBlackOpaque, // Opaque Black everywhere.
664-
// PSPDFStatusBarDefault, // Default statusbar (white on iPhone/black on iPad).
665-
// PSPDFStatusBarDisable, // Never show status bar.
666-
//};
667-
668-
//// Customize how a single page should be displayed.
669-
//typedef NS_ENUM(NSInteger, PSPDFPageRenderingMode) {
670-
// PSPDFPageRenderingModeThumbnailThenFullPage, // Load cached page async.
671-
// PSPDFPageRenderingModeFullPage, // Load cached page async, no upscaled thumb.
672-
// PSPDFPageRenderingModeFullPageBlocking, // Load cached page directly.
673-
// PSPDFPageRenderingModeThumbnailThenRender, // Don't use cached page but thumb.
674-
// PSPDFPageRenderingModeRender // Don't use cached page nor thumb.
675-
//};
676-
677658
#pragma mark License Key
678659

679660
- (void)setLicenseKey:(CDVInvokedUrlCommand *)command {
@@ -769,7 +750,7 @@ - (void)setRenderAnnotationTypesForPSPDFDocumentWithJSON:(NSArray *)options
769750

770751
- (void)setPageTransitionForPSPDFViewControllerWithJSON:(NSString *)transition
771752
{
772-
PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey:transition ofType:@"PSPDFPageTransition" withDefault:PSPDFPageTransitionScrollPerPage];
753+
PSPDFPageTransition pageTransition = (PSPDFPageTransition) [self enumValueForKey:transition ofType:@"PSPDFPageTransition" withDefault:PSPDFPageTransitionScrollPerSpread];
773754
[_pdfController updateConfigurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
774755
builder.pageTransition = pageTransition;
775756
}];
@@ -847,35 +828,35 @@ - (NSString *)linkActionAsJSON
847828
return [self enumKeyForValue:_pdfController.configuration.linkAction ofType:@"PSPDFLinkAction"];
848829
}
849830

850-
- (void)setHUDViewModeForPSPDFViewControllerWithJSON:(NSString *)mode
831+
- (void)setUserInterfaceViewModeForPSPDFViewControllerWithJSON:(NSString *)mode
851832
{
852-
PSPDFHUDViewMode HUDViewMode = (PSPDFHUDViewMode) [self enumValueForKey:mode ofType:@"PSPDFHUDViewMode" withDefault:PSPDFHUDViewModeAutomatic];
833+
PSPDFUserInterfaceViewMode userInterfaceViewMode = (PSPDFUserInterfaceViewMode) [self enumValueForKey:mode ofType:@"PSPDFUserInterfaceViewMode" withDefault:PSPDFUserInterfaceViewModeAutomatic];
853834
[_pdfController updateConfigurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
854-
builder.HUDViewMode = HUDViewMode;
835+
builder.userInterfaceViewMode = userInterfaceViewMode;
855836
}];
856837
}
857838

858-
- (NSString *)HUDViewModeAsJSON
839+
- (NSString *)userInterfaceViewModeAsJSON
859840
{
860-
return [self enumKeyForValue:_pdfController.configuration.HUDViewMode ofType:@"PSPDFHUDViewMode"];
841+
return [self enumKeyForValue:_pdfController.configuration.userInterfaceViewMode ofType:@"PSPDFUserInterfaceViewMode"];
861842
}
862843

863-
- (void)setHUDViewAnimationForPSPDFViewControllerWithJSON:(NSString *)mode
844+
- (void)setUserInterfaceViewAnimationForPSPDFViewControllerWithJSON:(NSString *)mode
864845
{
865-
PSPDFHUDViewAnimation HUDViewAnimation = (PSPDFHUDViewAnimation) [self enumValueForKey:mode ofType:@"HUDViewAnimation" withDefault:PSPDFHUDViewAnimationFade];
846+
PSPDFUserInterfaceViewAnimation userInterfaceViewAnimation = (PSPDFUserInterfaceViewAnimation) [self enumValueForKey:mode ofType:@"UserInterfaceViewAnimation" withDefault:PSPDFUserInterfaceViewAnimationFade];
866847
[_pdfController updateConfigurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
867-
builder.HUDViewAnimation = HUDViewAnimation;
848+
builder.userInterfaceViewAnimation = userInterfaceViewAnimation;
868849
}];
869850
}
870851

871-
- (NSString *)HUDViewAnimationAsJSON
852+
- (NSString *)userInterfaceViewAnimationAsJSON
872853
{
873-
return [self enumKeyForValue:_pdfController.configuration.HUDViewAnimation ofType:@"PSPDFHUDViewAnimation"];
854+
return [self enumKeyForValue:_pdfController.configuration.userInterfaceViewAnimation ofType:@"PSPDFUserInterfaceViewAnimation"];
874855
}
875856

876-
- (void)setHUDVisibleAnimatedForPSPDFViewControllerWithJSON:(NSNumber *)visible
857+
- (void)setUserInterfaceVisibleAnimatedForPSPDFViewControllerWithJSON:(NSNumber *)visible
877858
{
878-
[_pdfController setHUDVisible:[visible boolValue] animated:YES];
859+
[_pdfController setUserInterfaceVisible:[visible boolValue] animated:YES];
879860
}
880861

881862
- (void)setPageAnimatedForPSPDFViewControllerWithJSON:(NSNumber *)page
@@ -1230,15 +1211,15 @@ - (void)getPageCount:(CDVInvokedUrlCommand *)command
12301211
- (void)scrollToNextPage:(CDVInvokedUrlCommand *)command
12311212
{
12321213
BOOL animated = [[command argumentAtIndex:0 withDefault:@NO] boolValue];
1233-
[_pdfController scrollToNextPageAnimated:animated];
1214+
[_pdfController.documentViewController scrollToNextSpreadAnimated:animated];
12341215
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
12351216
callbackId:command.callbackId];
12361217
}
12371218

12381219
- (void)scrollToPreviousPage:(CDVInvokedUrlCommand *)command
12391220
{
12401221
BOOL animated = [[command argumentAtIndex:0 withDefault:@NO] boolValue];
1241-
[_pdfController scrollToPreviousPageAnimated:animated];
1222+
[_pdfController.documentViewController scrollToNextSpreadAnimated:animated];
12421223
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
12431224
callbackId:command.callbackId];
12441225
}
@@ -1325,31 +1306,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didBeginPageDragg
13251306
[self sendEventWithJSON:@"{type:'didBeginPageDragging'}"];
13261307
}
13271308

1328-
- (void)pdfViewController:(PSPDFViewController *)pdfController didEndPageDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
1329-
{
1330-
[self sendEventWithJSON:[NSString stringWithFormat:@"{type:'didBeginPageDragging',willDecelerate:'%@',velocity:'{%g,%g}'}", decelerate? @"true": @"false", velocity.x, velocity.y]];
1331-
}
1332-
1333-
- (void)pdfViewController:(PSPDFViewController *)pdfController didEndPageScrollingAnimation:(UIScrollView *)scrollView
1334-
{
1335-
[self sendEventWithJSON:@"{type:'didEndPageScrollingAnimation'}"];
1336-
}
1337-
1338-
- (void)pdfViewController:(PSPDFViewController *)pdfController didBeginPageZooming:(UIScrollView *)scrollView
1339-
{
1340-
[self sendEventWithJSON:@"{type:'didBeginPageZooming'}"];
1341-
}
1342-
1343-
- (void)pdfViewController:(PSPDFViewController *)pdfController didEndPageZooming:(UIScrollView *)scrollView atScale:(CGFloat)scale
1344-
{
1345-
[self sendEventWithJSON:[NSString stringWithFormat:@"{type:'didEndPageZooming',scale:%g}", scale]];
1346-
}
1347-
1348-
//- (PSPDFDocument *)pdfViewController:(PSPDFViewController *)pdfController documentForRelativePath:(NSString *)relativePath
1349-
//{
1350-
//
1351-
//}
1352-
13531309
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController didTapOnPageView:(PSPDFPageView *)pageView atPoint:(CGPoint)viewPoint
13541310
{
13551311
// inverted because it's almost always YES (due to handling JS eval calls).
@@ -1378,76 +1334,6 @@ - (void)pdfViewController:(PSPDFViewController *)pdfController didSelectText:(NS
13781334
[self sendEventWithJSON:@{@"type": @"didSelectText", @"text": text, @"rect": PSPDFStringFromCGRect(rect)}];
13791335
}
13801336

1381-
//- (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forSelectedText:(NSString *)selectedText inRect:(CGRect)textRect onPageView:(PSPDFPageView *)pageView
1382-
//{
1383-
//
1384-
//}
1385-
1386-
//- (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forSelectedImage:(PSPDFImageInfo *)selectedImage inRect:(CGRect)textRect onPageView:(PSPDFPageView *)pageView
1387-
//{
1388-
//
1389-
//}
1390-
1391-
//- (NSArray *)pdfViewController:(PSPDFViewController *)pdfController shouldShowMenuItems:(NSArray *)menuItems atSuggestedTargetRect:(CGRect)rect forAnnotation:(PSPDFAnnotation *)annotation inRect:(CGRect)annotationRect onPageView:(PSPDFPageView *)pageView
1392-
//{
1393-
//
1394-
//}
1395-
1396-
//- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldDisplayAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1397-
//{
1398-
//
1399-
//}
1400-
1401-
//- (BOOL)pdfViewController:(PSPDFViewController *)pdfController didTapOnAnnotation:(PSPDFAnnotation *)annotation annotationPoint:(CGPoint)annotationPoint annotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView pageView:(PSPDFPageView *)pageView viewPoint:(CGPoint)viewPoint
1402-
//{
1403-
//
1404-
//}
1405-
1406-
//- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldSelectAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1407-
//{
1408-
//
1409-
//}
1410-
1411-
//- (void)pdfViewController:(PSPDFViewController *)pdfController didSelectAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1412-
//{
1413-
//
1414-
//}
1415-
1416-
//- (UIView <PSPDFAnnotationViewProtocol> *)pdfViewController:(PSPDFViewController *)pdfController annotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView forAnnotation:(PSPDFAnnotation *)annotation onPageView:(PSPDFPageView *)pageView
1417-
//{
1418-
//
1419-
//}
1420-
1421-
//- (void)pdfViewController:(PSPDFViewController *)pdfController willShowAnnotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView onPageView:(PSPDFPageView *)pageView
1422-
//{
1423-
//
1424-
//}
1425-
1426-
//- (void)pdfViewController:(PSPDFViewController *)pdfController didShowAnnotationView:(UIView <PSPDFAnnotationViewProtocol> *)annotationView onPageView:(PSPDFPageView *)pageView
1427-
//{
1428-
//
1429-
//}
1430-
1431-
//- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowController:(id)viewController embeddedInController:(id)controller animated:(BOOL)animated
1432-
//{
1433-
//
1434-
//}
1435-
1436-
//- (void)pdfViewController:(PSPDFViewController *)pdfController didShowController:(id)viewController embeddedInController:(id)controller animated:(BOOL)animated
1437-
//{
1438-
//
1439-
//}
1440-
1441-
//- (void)pdfViewController:(PSPDFViewController *)pdfController requestsUpdateForBarButtonItem:(UIBarButtonItem *)barButtonItem animated:(BOOL)animated
1442-
//{
1443-
//
1444-
//}
1445-
1446-
//- (void)pdfViewController:(PSPDFViewController *)pdfController didChangeViewMode:(PSPDFViewMode)viewMode
1447-
//{
1448-
//
1449-
//}
1450-
14511337
- (void)pdfViewControllerWillDismiss:(PSPDFViewController *)pdfController
14521338
{
14531339
[self sendEventWithJSON:@"{type:'willDismiss'}"];
@@ -1464,34 +1350,24 @@ - (void)pdfViewControllerDidDismiss:(PSPDFViewController *)pdfController
14641350
[self sendEventWithJSON:@"{type:'didDismiss'}"];
14651351
}
14661352

1467-
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowHUD:(BOOL)animated
1468-
{
1469-
return [self sendEventWithJSON:@{@"type": @"shouldShowHUD", @"animated": @(animated)}];
1470-
}
1471-
1472-
- (void)pdfViewController:(PSPDFViewController *)pdfController willShowHUD:(BOOL)animated
1473-
{
1474-
[self sendEventWithJSON:@{@"type": @"willShowHUD", @"animated": @(animated)}];
1475-
}
1476-
1477-
- (void)pdfViewController:(PSPDFViewController *)pdfController didShowHUD:(BOOL)animated
1353+
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldShowUserInterface:(BOOL)animated
14781354
{
1479-
[self sendEventWithJSON:@{@"type": @"didShowHUD", @"animated": @(animated)}];
1355+
return [self sendEventWithJSON:@{@"type": @"shouldShowUserInterface", @"animated": @(animated)}];
14801356
}
14811357

1482-
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldHideHUD:(BOOL)animated
1358+
- (void)pdfViewController:(PSPDFViewController *)pdfController didShowUserInterface:(BOOL)animated
14831359
{
1484-
return [self sendEventWithJSON:@{@"type": @"shouldHideHUD", @"animated": @(animated)}];
1360+
[self sendEventWithJSON:@{@"type": @"didShowUserInterface", @"animated": @(animated)}];
14851361
}
14861362

1487-
- (void)pdfViewController:(PSPDFViewController *)pdfController willHideHUD:(BOOL)animated
1363+
- (BOOL)pdfViewController:(PSPDFViewController *)pdfController shouldHideUserInterface:(BOOL)animated
14881364
{
1489-
[self sendEventWithJSON:@{@"type": @"willHideHUD", @"animated": @(animated)}];
1365+
return [self sendEventWithJSON:@{@"type": @"shouldHideUserInterface", @"animated": @(animated)}];
14901366
}
14911367

1492-
- (void)pdfViewController:(PSPDFViewController *)pdfController didHideHUD:(BOOL)animated
1368+
- (void)pdfViewController:(PSPDFViewController *)pdfController didHideUserInterface:(BOOL)animated
14931369
{
1494-
[self sendEventWithJSON:@{@"type": @"didHideHUD", @"animated": @(animated)}];
1370+
[self sendEventWithJSON:@{@"type": @"didHideUserInterface", @"animated": @(animated)}];
14951371
}
14961372

14971373
#pragma mark Annotation toolbar delegate methods

0 commit comments

Comments
 (0)