diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2014-03-31 16:53:51 +0100 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2014-04-18 15:26:58 +0100 |
commit | 223c4e57e9e0cd2eb9193aa9ddde35686d440ea7 (patch) | |
tree | 39a85087a0987ee906994d066533be26c6214bfb /platform/ios | |
parent | eebc3385ebfa60574d78cf41badd6622987c1121 (diff) | |
download | mupdf-223c4e57e9e0cd2eb9193aa9ddde35686d440ea7.tar.xz |
iOS: add AirPrint support
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/Classes/MuDocumentController.h | 2 | ||||
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 45 | ||||
-rw-r--r-- | platform/ios/MuPDF.xcodeproj/project.pbxproj | 8 |
3 files changed, 55 insertions, 0 deletions
diff --git a/platform/ios/Classes/MuDocumentController.h b/platform/ios/Classes/MuDocumentController.h index 4abacc42..29a9ac1a 100644 --- a/platform/ios/Classes/MuDocumentController.h +++ b/platform/ios/Classes/MuDocumentController.h @@ -15,6 +15,7 @@ enum { BARMODE_MAIN, BARMODE_SEARCH, + BARMODE_MORE, BARMODE_ANNOTATION, BARMODE_HIGHLIGHT, BARMODE_UNDERLINE, @@ -37,6 +38,7 @@ enum UISearchBar *searchBar; UIBarButtonItem *nextButton, *prevButton, *cancelButton, *searchButton, *outlineButton, *linkButton; UIBarButtonItem *moreButton; + UIBarButtonItem *printButton, *annotButton; UIBarButtonItem *highlightButton, *underlineButton, *strikeoutButton; UIBarButtonItem *inkButton; UIBarButtonItem *tickButton; diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index d56313c9..490ba40e 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -249,6 +249,8 @@ static void saveDoc(char *current_path, fz_document *doc) nextButton = [self resourceBasedButton:@"ic_arrow_right" withAction:@selector(onSearchNext:)]; reflowButton = [self resourceBasedButton:@"ic_reflow" withAction:@selector(onToggleReflow:)]; moreButton = [self resourceBasedButton:@"ic_more" withAction:@selector(onMore:)]; + annotButton = [self resourceBasedButton:@"ic_annotation" withAction:@selector(onAnnot:)]; + printButton = [self resourceBasedButton:@"ic_print" withAction:@selector(onPrint:)]; highlightButton = [self resourceBasedButton:@"ic_highlight" withAction:@selector(onHighlight:)]; underlineButton = [self resourceBasedButton:@"ic_underline" withAction:@selector(onUnderline:)]; strikeoutButton = [self resourceBasedButton:@"ic_strike" withAction:@selector(onStrikeout:)]; @@ -443,6 +445,14 @@ static void saveDoc(char *current_path, fz_document *doc) [self scrollViewDidScroll:canvas]; } +- (void) showMoreMenu +{ + [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:printButton, annotButton, nil]]; + [[self navigationItem] setLeftBarButtonItem:cancelButton]; + + barmode = BARMODE_MORE; +} + - (void) showAnnotationMenu { [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:inkButton, strikeoutButton, underlineButton, highlightButton, nil]]; @@ -465,9 +475,43 @@ static void saveDoc(char *current_path, fz_document *doc) - (void) onMore: (id)sender { + [self showMoreMenu]; +} + +- (void) onAnnot: (id)sender +{ [self showAnnotationMenu]; } +- (void) onPrint: (id)sender +{ + NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:filePath]]; + UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; + if (pic && [UIPrintInteractionController canPrintURL:url] ) { + + UIPrintInfo *printInfo = [UIPrintInfo printInfo]; + printInfo.outputType = UIPrintInfoOutputGeneral; + printInfo.jobName = key; + printInfo.duplex = UIPrintInfoDuplexLongEdge; + pic.printInfo = printInfo; + pic.showsPageRange = YES; + pic.printingItem = url; + + void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = + ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) { + if (!completed && error) + NSLog(@"FAILED! due to error in domain %@ with error code %u", + error.domain, (unsigned int)error.code); + }; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [pic presentFromBarButtonItem:printButton animated:YES + completionHandler:completionHandler]; + } else { + [pic presentAnimated:YES completionHandler:completionHandler]; + } + } +} + - (void) textSelectModeOn { [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObject:tickButton]]; @@ -594,6 +638,7 @@ static void saveDoc(char *current_path, fz_document *doc) [self resetSearch]; /* fallthrough */ case BARMODE_ANNOTATION: + case BARMODE_MORE: [[self navigationItem] setTitleView: nil]; [self addMainMenuButtons]; barmode = BARMODE_MAIN; diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj index 82aa03af..eb9b3fb1 100644 --- a/platform/ios/MuPDF.xcodeproj/project.pbxproj +++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj @@ -39,6 +39,8 @@ DA442E30183B9F13008EF49B /* MuInkView.m in Sources */ = {isa = PBXBuildFile; fileRef = DA442E2F183B9F13008EF49B /* MuInkView.m */; }; DA4C0622187B1EA200755D0D /* MuTextFieldController.m in Sources */ = {isa = PBXBuildFile; fileRef = DA4C0620187B1EA200755D0D /* MuTextFieldController.m */; }; DA4C0623187B1EA200755D0D /* MuTextFieldController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DA4C0621187B1EA200755D0D /* MuTextFieldController.xib */; }; + DA7AAA3B18E4683600A577E3 /* ic_annotation.png in Resources */ = {isa = PBXBuildFile; fileRef = DA7AAA3A18E45FA300A577E3 /* ic_annotation.png */; }; + DA7AAA3C18E4683600A577E3 /* ic_print.png in Resources */ = {isa = PBXBuildFile; fileRef = DA32FC7218E33CC7001D7902 /* ic_print.png */; }; DAA6E56F17F03F96002B1E4E /* MuPageViewReflow.m in Sources */ = {isa = PBXBuildFile; fileRef = DAA6E56E17F03AAE002B1E4E /* MuPageViewReflow.m */; }; DAAC6A2E17FC6E4A00A0E83A /* MuTapResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DAAC6A2D17FC6E4A00A0E83A /* MuTapResult.m */; }; DAB067A61831225D00DDA774 /* MuWord.m in Sources */ = {isa = PBXBuildFile; fileRef = DAB067A51831225D00DDA774 /* MuWord.m */; }; @@ -114,12 +116,14 @@ DA1C68C217E8968C0061F586 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; }; DA1C68C317E8969C0061F586 /* common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = common.m; sourceTree = "<group>"; }; DA300CA31847A64C004F92BB /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; + DA32FC7218E33CC7001D7902 /* ic_print.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_print.png; path = "../android/res/drawable-ldpi/ic_print.png"; sourceTree = "<group>"; }; DA442E2C183B796F008EF49B /* ic_pen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_pen.png; path = "../android/res/drawable-ldpi/ic_pen.png"; sourceTree = "<group>"; }; DA442E2E183B9F13008EF49B /* MuInkView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuInkView.h; path = Classes/MuInkView.h; sourceTree = "<group>"; }; DA442E2F183B9F13008EF49B /* MuInkView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuInkView.m; path = Classes/MuInkView.m; sourceTree = "<group>"; }; DA4C061F187B1EA200755D0D /* MuTextFieldController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuTextFieldController.h; path = Classes/MuTextFieldController.h; sourceTree = "<group>"; }; DA4C0620187B1EA200755D0D /* MuTextFieldController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuTextFieldController.m; path = Classes/MuTextFieldController.m; sourceTree = "<group>"; }; DA4C0621187B1EA200755D0D /* MuTextFieldController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MuTextFieldController.xib; path = Classes/MuTextFieldController.xib; sourceTree = "<group>"; }; + DA7AAA3A18E45FA300A577E3 /* ic_annotation.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_annotation.png; path = "../android/res/drawable-ldpi/ic_annotation.png"; sourceTree = "<group>"; }; DAA6E56D17F03AAE002B1E4E /* MuPageViewReflow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuPageViewReflow.h; path = Classes/MuPageViewReflow.h; sourceTree = "<group>"; }; DAA6E56E17F03AAE002B1E4E /* MuPageViewReflow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuPageViewReflow.m; path = Classes/MuPageViewReflow.m; sourceTree = "<group>"; }; DAAC6A2C17FC6E4A00A0E83A /* MuTapResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuTapResult.h; path = Classes/MuTapResult.h; sourceTree = "<group>"; }; @@ -219,6 +223,8 @@ 968E1E461779A54F0050CEA3 /* Resources */ = { isa = PBXGroup; children = ( + DA7AAA3A18E45FA300A577E3 /* ic_annotation.png */, + DA32FC7218E33CC7001D7902 /* ic_print.png */, DAD72803183E6F33005C14FA /* ic_trash.png */, DACD12261833CDA600D4B9C5 /* ic_check.png */, DAD47D2B1832615900E173A0 /* ic_highlight.png */, @@ -371,6 +377,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + DA7AAA3B18E4683600A577E3 /* ic_annotation.png in Resources */, + DA7AAA3C18E4683600A577E3 /* ic_print.png in Resources */, 968E1E531779A54F0050CEA3 /* Default.png in Resources */, 968E1E551779A54F0050CEA3 /* Default@2x.png in Resources */, 968E1E571779A54F0050CEA3 /* Default-568h@2x.png in Resources */, |