summaryrefslogtreecommitdiff
path: root/platform/ios/Classes/MuAppDelegate.m
diff options
context:
space:
mode:
authorPaul Gardiner <paul@pauls-mac-mini.site>2013-09-17 15:04:13 +0100
committerPaul Gardiner <paul@pauls-mac-mini.site>2013-09-17 15:08:40 +0100
commit43bcd8a7516bfbd455d81de7e00d5e139abce438 (patch)
tree71efd1fe71fb8dfd6dd4399547f9e10fa2b24d5d /platform/ios/Classes/MuAppDelegate.m
parent0f6711fd4db36602034734b063cdaf30a396126c (diff)
downloadmupdf-43bcd8a7516bfbd455d81de7e00d5e139abce438.tar.xz
iOS: split the classes into separate files
Diffstat (limited to 'platform/ios/Classes/MuAppDelegate.m')
-rw-r--r--platform/ios/Classes/MuAppDelegate.m98
1 files changed, 98 insertions, 0 deletions
diff --git a/platform/ios/Classes/MuAppDelegate.m b/platform/ios/Classes/MuAppDelegate.m
new file mode 100644
index 00000000..aaf0cff9
--- /dev/null
+++ b/platform/ios/Classes/MuAppDelegate.m
@@ -0,0 +1,98 @@
+//
+// MuAppDelegate.m
+// MuPDF
+//
+// Copyright (c) 2013 Artifex Software, Inc. All rights reserved.
+//
+
+#include "common.h"
+
+#import "MuAppDelegate.h"
+
+@implementation MuAppDelegate
+
+- (BOOL) application: (UIApplication*)application didFinishLaunchingWithOptions: (NSDictionary*)launchOptions
+{
+ NSString *filename;
+
+ queue = dispatch_queue_create("com.artifex.mupdf.queue", NULL);
+
+ // use at most 128M for resource cache
+ ctx = fz_new_context(NULL, NULL, 128<<20);
+
+ screenScale = [[UIScreen mainScreen] scale];
+
+ library = [[MuLibraryController alloc] initWithStyle: UITableViewStylePlain];
+
+ navigator = [[UINavigationController alloc] initWithRootViewController: library];
+ [[navigator navigationBar] setTranslucent: YES];
+ [[navigator toolbar] setTranslucent: YES];
+ [navigator setDelegate: self];
+
+ window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
+ [window setBackgroundColor: [UIColor scrollViewTexturedBackgroundColor]];
+ [window setRootViewController: navigator];
+ [window makeKeyAndVisible];
+
+ filename = [[NSUserDefaults standardUserDefaults] objectForKey: @"OpenDocumentKey"];
+ if (filename)
+ [library openDocument: filename];
+
+ filename = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];
+ NSLog(@"urlkey = %@\n", filename);
+
+ return YES;
+}
+
+- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
+{
+ NSLog(@"openURL: %@\n", url);
+ if ([url isFileURL]) {
+ NSString *path = [url path];
+ NSString *dir = [NSString stringWithFormat: @"%@/Documents/", NSHomeDirectory()];
+ path = [path stringByReplacingOccurrencesOfString:@"/private" withString:@""];
+ path = [path stringByReplacingOccurrencesOfString:dir withString:@""];
+ NSLog(@"file relative path: %@\n", path);
+ [library openDocument:path];
+ return YES;
+ }
+ return NO;
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ printf("applicationDidEnterBackground!\n");
+ [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ printf("applicationWillEnterForeground!\n");
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ printf("applicationDidBecomeActive!\n");
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ printf("applicationWillTerminate!\n");
+ [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
+- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
+{
+ printf("applicationDidReceiveMemoryWarning\n");
+}
+
+- (void) dealloc
+{
+ dispatch_release(queue);
+ [library release];
+ [navigator release];
+ [window release];
+ [super dealloc];
+}
+
+@end