incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject git commit: Fixed iOS 5 quirks with presenting/dismissing modal viewcontrollers.
Date Wed, 18 Jan 2012 19:23:16 GMT
Updated Branches:
  refs/heads/master e7aaf41c6 -> f03d6a2d6


Fixed iOS 5 quirks with presenting/dismissing modal viewcontrollers.


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

Branch: refs/heads/master
Commit: f03d6a2d6b2c1aff1c6be5b2eaedb05a3a516370
Parents: e7aaf41
Author: Shazron Abdullah <shazron@apache.org>
Authored: Wed Jan 18 11:22:41 2012 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Wed Jan 18 11:22:41 2012 -0800

----------------------------------------------------------------------
 PhoneGapLib/Classes/Camera.m   |   18 ++++++++++--
 PhoneGapLib/Classes/Capture.m  |   37 ++++++++++++++++++++++----
 PhoneGapLib/Classes/Contacts.m |   49 +++++++++++++++++++++++++++--------
 3 files changed, 84 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f03d6a2d/PhoneGapLib/Classes/Camera.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Camera.m b/PhoneGapLib/Classes/Camera.m
index 6b94dc6..34b537b 100644
--- a/PhoneGapLib/Classes/Camera.m
+++ b/PhoneGapLib/Classes/Camera.m
@@ -106,7 +106,11 @@
         }
         else 
         { 
-            [self.viewController presentModalViewController:self.pickerController animated:YES];

+            if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
+                [self.viewController presentViewController:self.pickerController animated:YES
completion:nil];        
+            } else {
+                [self.viewController presentModalViewController:self.pickerController animated:YES
];
+            }              
         }
     }
 }
@@ -130,7 +134,11 @@
 	}
 	else 
 	{
-		[self.pickerController dismissModalViewControllerAnimated:YES]; 
+        if ([self.pickerController respondsToSelector:@selector(presentingViewController)])
{ 
+            [[self.pickerController presentingViewController] dismissModalViewControllerAnimated:YES];
+        } else {
+            [[self.pickerController parentViewController] dismissModalViewControllerAnimated:YES];
+        }        
 	}
 	NSString* jsString = nil;
     PluginResult* result = nil;
@@ -224,7 +232,11 @@
 {	
 	NSString* callbackId = self.pickerController.callbackId;
 	
-	[picker dismissModalViewControllerAnimated:YES];
+    if ([picker respondsToSelector:@selector(presentingViewController)]) { 
+        [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
 	
 	PluginResult* result = [PluginResult resultWithStatus: PGCommandStatus_OK messageAsString:
@"no image selected"]; // error callback expects string ATM
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f03d6a2d/PhoneGapLib/Classes/Capture.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Capture.m b/PhoneGapLib/Classes/Capture.m
index 9185ec3..2cbd68e 100644
--- a/PhoneGapLib/Classes/Capture.m
+++ b/PhoneGapLib/Classes/Capture.m
@@ -96,7 +96,11 @@
         UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:audioViewController]
autorelease];
         self.inUse = YES;
         
-        [self.viewController presentModalViewController:navController animated: YES];
+        if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
+            [self.viewController presentViewController:navController animated:YES completion:nil];
       
+        } else {
+            [self.viewController presentModalViewController:navController animated:YES ];
+        }              
     }
         
     if (result) {
@@ -141,7 +145,11 @@
         pickerController.callbackId = callbackId;
         pickerController.mimeType = mode;
 	
-        [self.viewController presentModalViewController:pickerController animated:YES];
+        if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
+            [self.viewController presentViewController:pickerController animated:YES completion:nil];
       
+        } else {
+            [self.viewController presentModalViewController:pickerController animated:YES
];
+        }              
     }
 
 }
@@ -256,7 +264,11 @@
         // PGImagePicker specific property
         pickerController.callbackId = callbackId;
         
-        [self.viewController presentModalViewController:pickerController animated:YES];
+        if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
+            [self.viewController presentViewController:pickerController animated:YES completion:nil];
       
+        } else {
+            [self.viewController presentModalViewController:pickerController animated:YES
];
+        }              
     }
     
 }
@@ -475,7 +487,11 @@
     PGImagePicker* cameraPicker = (PGImagePicker*)picker;
 	NSString* callbackId = cameraPicker.callbackId;
 	
-	[picker dismissModalViewControllerAnimated:YES];
+    if ([picker respondsToSelector:@selector(presentingViewController)]) { 
+        [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
 	
     NSString* jsString = nil;
     PluginResult* result = nil;
@@ -518,7 +534,11 @@
     PGImagePicker* cameraPicker = (PGImagePicker*)picker;
 	NSString* callbackId = cameraPicker.callbackId;
 	
-	[picker dismissModalViewControllerAnimated:YES];
+    if ([picker respondsToSelector:@selector(presentingViewController)]) { 
+        [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
 	
     NSString* jsString = nil;
     PluginResult* result = nil;
@@ -776,7 +796,12 @@
 - (void) dismissAudioView: (id) sender
 {
     // called when done button pressed or when error condition to do cleanup and remove view
-    [self.captureCommand.viewController.modalViewController dismissModalViewControllerAnimated:YES];
+    if ([self.captureCommand.viewController.modalViewController respondsToSelector:@selector(presentingViewController)])
{ 
+        [[self.captureCommand.viewController.modalViewController presentingViewController]
dismissModalViewControllerAnimated:YES];
+    } else {
+        [[self.captureCommand.viewController.modalViewController parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
+    
     if (!self.resultString) {
         // return error
         PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_OK messageToErrorObject:self.errorCode];

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f03d6a2d/PhoneGapLib/Classes/Contacts.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Contacts.m b/PhoneGapLib/Classes/Contacts.m
index d6d3afe..deb8d72 100755
--- a/PhoneGapLib/Classes/Contacts.m
+++ b/PhoneGapLib/Classes/Contacts.m
@@ -86,8 +86,12 @@
 	npController.callbackId = callbackId;
 
 	UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:npController]
autorelease];
-	[self.viewController presentModalViewController:navController animated: YES];
- 
+    
+    if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
+        [self.viewController presentViewController:navController animated:YES completion:nil];
       
+    } else {
+        [self.viewController presentModalViewController:navController animated:YES ];
+    }              
 }
 
 - (void) newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person
@@ -101,7 +105,13 @@
 			//return the contact id
 			recordId = ABRecordGetRecordID(person);
 	}
-	[newPersonViewController dismissModalViewControllerAnimated:YES];
+
+    if ([newPersonViewController respondsToSelector:@selector(presentingViewController)])
{ 
+        [[newPersonViewController presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[newPersonViewController parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
+    
 	PluginResult* result = [PluginResult resultWithStatus: PGCommandStatus_OK messageAsInt:
 recordId];
 	//jsString = [NSString stringWithFormat: @"%@(%d);", newCP.jsCallback, recordId];
 	[self writeJavascript: [result toSuccessCallbackString:callbackId]];
@@ -133,7 +143,11 @@
 
         [navController pushViewController:personController animated:YES];
 
-		[self.viewController presentModalViewController:navController animated: YES];
+        if ([self.viewController respondsToSelector:@selector(presentViewController:::)])
{
+            [self.viewController presentViewController:navController animated:YES completion:nil];
       
+        } else {
+            [self.viewController presentModalViewController:navController animated:YES ];
+        }              
 
 		if (bEdit) {
             // create the editing controller and push it onto the stack
@@ -142,7 +156,6 @@
             editPersonController.personViewDelegate = self;
             editPersonController.allowsEditing = YES; 
             [navController pushViewController:editPersonController animated:YES];
-            
         }
 	} 
 	else 
@@ -171,7 +184,11 @@
 	pickerController.selectedId = kABRecordInvalidID;
 	pickerController.allowsEditing = (BOOL)[options existsValue:@"true" forKey:@"allowsEditing"];
 	
-	[self.viewController presentModalViewController:pickerController animated: YES];
+    if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
+        [self.viewController presentViewController:pickerController animated:YES completion:nil];
       
+    } else {
+        [self.viewController presentModalViewController:pickerController animated:YES ];
+    }              
 }
 
 - (BOOL) peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker

@@ -197,8 +214,11 @@
 		PluginResult* result = [PluginResult resultWithStatus: PGCommandStatus_OK messageAsInt:
contactId];
 		[self writeJavascript:[result toSuccessCallbackString: picker.callbackId]];
 		
-
-		[picker dismissModalViewControllerAnimated:YES];
+        if ([picker respondsToSelector:@selector(presentingViewController)]) { 
+            [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
+        } else {
+            [[picker parentViewController] dismissModalViewControllerAnimated:YES];
+        }        
 	}
 	return NO;
 }
@@ -216,7 +236,11 @@
 	PluginResult* result = [PluginResult resultWithStatus:PGCommandStatus_OK messageAsInt: picker.selectedId];
 	[self writeJavascript:[result toSuccessCallbackString:picker.callbackId]];
 	
-	[peoplePicker dismissModalViewControllerAnimated:YES]; 
+    if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) { 
+        [[peoplePicker presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
 }
 
 - (void) search:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
@@ -473,8 +497,11 @@
     [super viewDidDisappear: animated];
     // I couldn't find the appViewController in the hierarchy of this UIViewController 
     // so using the passed ContactPlugin to access it.
-    [self.contactsPlugin.viewController dismissModalViewControllerAnimated:NO];
-    
+    if ([self.contactsPlugin.viewController respondsToSelector:@selector(presentingViewController)])
{ 
+        [[self.contactsPlugin.viewController presentingViewController] dismissModalViewControllerAnimated:YES];
+    } else {
+        [[self.contactsPlugin.viewController parentViewController] dismissModalViewControllerAnimated:YES];
+    }        
 }
 -(void) dealloc
 {


Mime
View raw message