aboutsummaryrefslogtreecommitdiffstats
path: root/phonegap/iPhone/FixMyStreet/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'phonegap/iPhone/FixMyStreet/Classes')
-rw-r--r--phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h10
-rw-r--r--phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m83
-rw-r--r--phonegap/iPhone/FixMyStreet/Classes/MainViewController.h4
-rw-r--r--phonegap/iPhone/FixMyStreet/Classes/MainViewController.m84
4 files changed, 94 insertions, 87 deletions
diff --git a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h
index f583369ad..cee4240b1 100644
--- a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h
+++ b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.h
@@ -19,9 +19,9 @@
//
// AppDelegate.h
-// FixMyStreet
+// cordova1.8.0
//
-// Created by Struan Donald on 08/03/2012.
+// Created by Struan Donald on 08/06/2012.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
@@ -34,17 +34,15 @@
#endif
-@interface AppDelegate : NSObject < UIApplicationDelegate, UIWebViewDelegate, CDVCommandDelegate > {
+@interface AppDelegate : NSObject < UIApplicationDelegate > {
- NSString* invokeString;
}
// invoke string is passed to your app on launch, this is only valid if you
-// edit FooBar.plist to add a protocol
+// edit cordova1.8.0-Info.plist to add a protocol
// a simple tutorial can be found here :
// http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
-@property (nonatomic, copy) NSString* invokeString;
@property (nonatomic, retain) IBOutlet UIWindow* window;
@property (nonatomic, retain) IBOutlet CDVViewController* viewController;
diff --git a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m
index 6a7defb8c..ad518dc80 100644
--- a/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m
+++ b/phonegap/iPhone/FixMyStreet/Classes/AppDelegate.m
@@ -19,9 +19,9 @@
//
// AppDelegate.m
-// FixMyStreet
+// cordova1.8.0
//
-// Created by Struan Donald on 08/03/2012.
+// Created by Struan Donald on 08/06/2012.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
@@ -39,7 +39,7 @@
@implementation AppDelegate
-@synthesize invokeString, window, viewController;
+@synthesize window, viewController;
- (id) init
{
@@ -48,8 +48,8 @@
**/
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
-
- [CDVURLProtocol registerPGHttpURLProtocol];
+
+ [CDVURLProtocol registerURLProtocol];
return [super init];
}
@@ -62,9 +62,11 @@
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
+ NSString* invokeString = nil;
+
if (url && [url isKindOfClass:[NSURL class]]) {
- self.invokeString = [url absoluteString];
- NSLog(@"FixMyStreet launchOptions = %@", url);
+ invokeString = [url absoluteString];
+ NSLog(@"cordova1.8.0 launchOptions = %@", url);
}
CGRect screenBounds = [[UIScreen mainScreen] bounds];
@@ -77,12 +79,9 @@
self.viewController.useSplashScreen = YES;
self.viewController.wwwFolderName = @"www";
self.viewController.startPage = @"index.html";
+ self.viewController.invokeString = invokeString;
self.viewController.view.frame = viewBounds;
- // over-ride delegates
- self.viewController.webView.delegate = self;
- self.viewController.commandDelegate = self;
-
// check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation
BOOL forceStartupRotation = YES;
UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation];
@@ -116,7 +115,7 @@
}
// this happens while we are running ( in the background, or from within our own app )
-// only valid if FooBar.plist specifies a protocol to handle
+// only valid if cordova1.8.0-Info.plist specifies a protocol to handle
- (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url
{
if (!url) {
@@ -133,66 +132,6 @@
return YES;
}
-#pragma PGCommandDelegate implementation
-
-- (id) getCommandInstance:(NSString*)className
-{
- return [self.viewController getCommandInstance:className];
-}
-
-- (BOOL) execute:(CDVInvokedUrlCommand*)command
-{
- return [self.viewController execute:command];
-}
-
-- (NSString*) pathForResource:(NSString*)resourcepath;
-{
- return [self.viewController pathForResource:resourcepath];
-}
-
-#pragma UIWebDelegate implementation
-
-- (void) webViewDidFinishLoad:(UIWebView*) theWebView
-{
- // only valid if FooBar.plist specifies a protocol to handle
- if (self.invokeString)
- {
- // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
- NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
- [theWebView stringByEvaluatingJavaScriptFromString:jsString];
- }
-
- // Black base color for background matches the native apps
- theWebView.backgroundColor = [UIColor blackColor];
-
- return [self.viewController webViewDidFinishLoad:theWebView];
-}
-
-- (void) webViewDidStartLoad:(UIWebView*)theWebView
-{
- return [self.viewController webViewDidStartLoad:theWebView];
-}
-
-- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- return [self.viewController webView:theWebView didFailLoadWithError:error];
-}
-
-- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- NSURL *url = [request URL];
-
- // Intercept the external http requests and forward to Safari.app
- // Otherwise forward to the PhoneGap WebView
- if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
- [[UIApplication sharedApplication] openURL:url];
- return NO;
- }
- else {
- return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
- }
-}
-
- (void) dealloc
{
[super dealloc];
diff --git a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h
index 3222496ce..3f48936da 100644
--- a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h
+++ b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.h
@@ -19,9 +19,9 @@
//
// MainViewController.h
-// FixMyStreet
+// cordova1.8.0
//
-// Created by Struan Donald on 08/03/2012.
+// Created by Struan Donald on 08/06/2012.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
diff --git a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.m b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.m
index ef5d1c0be..289da3596 100644
--- a/phonegap/iPhone/FixMyStreet/Classes/MainViewController.m
+++ b/phonegap/iPhone/FixMyStreet/Classes/MainViewController.m
@@ -19,9 +19,9 @@
//
// MainViewController.h
-// FixMyStreet
+// cordova1.8.0
//
-// Created by Struan Donald on 08/03/2012.
+// Created by Struan Donald on 08/06/2012.
// Copyright __MyCompanyName__ 2012. All rights reserved.
//
@@ -29,7 +29,7 @@
@implementation MainViewController
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
@@ -38,7 +38,7 @@
return self;
}
-- (void)didReceiveMemoryWarning
+- (void) didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
@@ -48,23 +48,93 @@
#pragma mark - View lifecycle
-- (void)viewDidLoad
+- (void) viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-- (void)viewDidUnload
+- (void) viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
+/* Comment out the block below to over-ride */
+/*
+- (CDVCordovaView*) newCordovaViewWithFrame:(CGRect)bounds
+{
+ return[super newCordovaViewWithFrame:bounds];
+}
+*/
+
+/* Comment out the block below to over-ride */
+/*
+#pragma CDVCommandDelegate implementation
+
+- (id) getCommandInstance:(NSString*)className
+{
+ return [super getCommandInstance:className];
+}
+
+- (BOOL) execute:(CDVInvokedUrlCommand*)command
+{
+ return [super execute:command];
+}
+
+- (NSString*) pathForResource:(NSString*)resourcepath;
+{
+ return [super pathForResource:resourcepath];
+}
+
+- (void) registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
+{
+ return [super registerPlugin:plugin withClassName:className];
+}
+*/
+
+#pragma UIWebDelegate implementation
+
+- (void) webViewDidFinishLoad:(UIWebView*) theWebView
+{
+ // only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle
+ if (self.invokeString)
+ {
+ // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
+ NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
+ [theWebView stringByEvaluatingJavaScriptFromString:jsString];
+ }
+
+ // Black base color for background matches the native apps
+ theWebView.backgroundColor = [UIColor blackColor];
+
+ return [super webViewDidFinishLoad:theWebView];
+}
+
+/* Comment out the block below to over-ride */
+/*
+
+- (void) webViewDidStartLoad:(UIWebView*)theWebView
+{
+ return [super webViewDidStartLoad:theWebView];
+}
+
+- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
+{
+ return [super webView:theWebView didFailLoadWithError:error];
+}
+
+- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
+{
+ return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
+}
+*/
+
@end