You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/10/21 10:52:58 UTC

[1/2] ios commit: Remove unused code, also pre-iOS 4 only code

Repository: cordova-ios
Updated Branches:
  refs/heads/master 7a1d6c833 -> 01b3d191d


Remove unused code, also pre-iOS 4 only code


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/6506b22f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/6506b22f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/6506b22f

Branch: refs/heads/master
Commit: 6506b22f71efcbebc8df4a71300203771250caf5
Parents: 7a1d6c8
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Oct 21 01:42:17 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Oct 21 01:42:17 2014 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.m | 17 -----------------
 1 file changed, 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6506b22f/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 1e59b1b..9f02d82 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -779,23 +779,6 @@
     [self.commandDelegate evalJs:jsString];
 }
 
-+ (NSString*)resolveImageResource:(NSString*)resource
-{
-    NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-    BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
-
-    // the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
-    if (isLessThaniOS4) {
-        if (CDV_IsIPad()) {
-            return [NSString stringWithFormat:@"%@~ipad.png", resource];
-        } else {
-            return [NSString stringWithFormat:@"%@.png", resource];
-        }
-    }
-
-    return resource;
-}
-
 + (NSString*)applicationDocumentsDirectory
 {
     NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/2] ios commit: CB-7606 - handleOpenURL handler firing more than necessary

Posted by sh...@apache.org.
CB-7606 - handleOpenURL handler firing more than necessary

- plus style fixups through uncrustify


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/01b3d191
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/01b3d191
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/01b3d191

Branch: refs/heads/master
Commit: 01b3d191d47b5f5b9549a1174b0d92ae0f0a901d
Parents: 6506b22
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Oct 21 01:52:40 2014 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Oct 21 01:52:40 2014 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.h          |  1 +
 CordovaLib/Classes/CDVViewController.m          | 35 ++++++++++++++------
 .../__PROJECT_NAME__/Classes/AppDelegate.m      | 18 +++++-----
 3 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/01b3d191/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
index 1d34ddd..51863a5 100644
--- a/CordovaLib/Classes/CDVViewController.h
+++ b/CordovaLib/Classes/CDVViewController.h
@@ -79,5 +79,6 @@
 - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
 
 - (BOOL)URLisAllowed:(NSURL*)url;
+- (void)processOpenUrl:(NSURL*)url;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/01b3d191/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 9f02d82..acb88f7 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -72,7 +72,8 @@
                                                      name:UIApplicationWillEnterForegroundNotification object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
                                                      name:UIApplicationDidEnterBackgroundNotification object:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPageDidLoad:)
+                                                     name:CDVPageDidLoadNotification object:nil];
 
         // read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad, if its iPad) from -Info.plist
         self.supportedOrientations = [self parseInterfaceOrientations:
@@ -562,7 +563,7 @@
 - (NSString*)userAgent
 {
     if (_userAgent == nil) {
-        NSString *localBaseUserAgent;
+        NSString* localBaseUserAgent;
         if (self.baseUserAgent != nil) {
             localBaseUserAgent = self.baseUserAgent;
         } else {
@@ -649,8 +650,6 @@
      */
     [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
 
-    [self processOpenUrl];
-
     [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:self.webView]];
 }
 
@@ -953,21 +952,37 @@
 
 // ///////////////////////
 
-- (void)handleOpenURL:(NSNotification*)notification
+- (void)onPageDidLoad:(NSNotification*)notification
 {
-    self.openURL = notification.object;
+    if (self.openURL) {
+        [self processOpenUrl:self.openURL pageLoaded:YES];
+        self.openURL = nil;
+    }
 }
 
-- (void)processOpenUrl
+- (void)processOpenUrl:(NSURL*)url pageLoaded:(BOOL)pageLoaded
 {
-    if (self.openURL) {
+    if (!pageLoaded) {
+        // query the webview for readystate
+        NSString* readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
+        pageLoaded = [readyState isEqualToString:@"loaded"] || [readyState isEqualToString:@"complete"];
+    }
+
+    if (pageLoaded) {
         // calls into javascript global function 'handleOpenURL'
-        NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", [self.openURL description]];
+        NSString* jsString = [NSString stringWithFormat:@"if (typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");}", url];
         [self.webView stringByEvaluatingJavaScriptFromString:jsString];
-        self.openURL = nil;
+    } else {
+        // save for when page has loaded
+        self.openURL = url;
     }
 }
 
+- (void)processOpenUrl:(NSURL*)url
+{
+    [self processOpenUrl:url pageLoaded:NO];
+}
+
 // ///////////////////////
 
 - (void)dealloc

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/01b3d191/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m b/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m
index 1cf7fb6..fe4a7a0 100644
--- a/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m
+++ b/bin/templates/project/__PROJECT_NAME__/Classes/AppDelegate.m
@@ -99,9 +99,7 @@
         return NO;
     }
 
-    // calls into javascript global function 'handleOpenURL'
-    NSString* jsString = [NSString stringWithFormat:@"if (typeof handleOpenURL === 'function') { handleOpenURL(\"%@\");}", url];
-    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
+    [self.viewController processOpenUrl:url];
 
     // all plugins will get the notification, and their handlers will be called
     [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
@@ -117,20 +115,20 @@
     [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification];
 }
 
-- (void)                                application:(UIApplication *)application
-   didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
+- (void)                                 application:(UIApplication*)application
+    didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
 {
     // re-post ( broadcast )
     NSString* token = [[[[deviceToken description]
-                         stringByReplacingOccurrencesOfString: @"<" withString: @""]
-                        stringByReplacingOccurrencesOfString: @">" withString: @""]
-                       stringByReplacingOccurrencesOfString: @" " withString: @""];
+        stringByReplacingOccurrencesOfString:@"<" withString:@""]
+        stringByReplacingOccurrencesOfString:@">" withString:@""]
+        stringByReplacingOccurrencesOfString:@" " withString:@""];
 
     [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token];
 }
 
-- (void)                                 application:(UIApplication *)application
-    didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
+- (void)                                 application:(UIApplication*)application
+    didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
 {
     // re-post ( broadcast )
     [[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error];


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org