You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/08/16 17:23:21 UTC

[2/4] ios commit: Udpated CDVContacts chooseContact() to support allowsEditing behavior.

Udpated CDVContacts chooseContact() to support allowsEditing behavior.


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/f4ee4eef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/f4ee4eef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/f4ee4eef

Branch: refs/heads/master
Commit: f4ee4eef9fb0844c5ec628b6419d8af55f9f63fb
Parents: 92e159b
Author: Olivier Louvignes <ol...@mg-crea.com>
Authored: Thu Jul 12 16:55:32 2012 +0200
Committer: Becky Gibson <be...@apache.org>
Committed: Thu Aug 16 11:19:50 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVContacts.h |    4 ++--
 CordovaLib/Classes/CDVContacts.m |   12 +++++-------
 2 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f4ee4eef/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
index e5f65a8..dc3b774 100755
--- a/CordovaLib/Classes/CDVContacts.h
+++ b/CordovaLib/Classes/CDVContacts.h
@@ -108,13 +108,13 @@
 	BOOL allowsEditing;
 	NSString* callbackId;
 	NSMutableDictionary *options;
-	ABRecordID selectedId;
+	NSDictionary *pickedContactDictionary;
 }
 
 @property BOOL allowsEditing;
 @property (copy) NSString* callbackId;
 @property (nonatomic, retain) NSMutableDictionary *options;
-@property ABRecordID selectedId;
+@property (nonatomic, retain) NSDictionary *pickedContactDictionary;
 
 @end
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/f4ee4eef/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 0aaea7f..93b0e2d 100755
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -30,7 +30,7 @@
 @synthesize allowsEditing;
 @synthesize callbackId;
 @synthesize options;
-@synthesize selectedId;
+@synthesize pickedContactDictionary;
 
 @end
 @implementation CDVNewContactsController
@@ -179,7 +179,7 @@
 	pickerController.peoplePickerDelegate = self;
 	pickerController.callbackId = callbackId;
 	pickerController.options = options;
-	pickerController.selectedId = kABRecordInvalidID;
+	pickerController.pickedContactDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kABRecordInvalidID], @"id", nil];
 	pickerController.allowsEditing = (BOOL)[options existsValue:@"true" forKey:@"allowsEditing"];
 	
     if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
@@ -194,14 +194,12 @@
 {
 	
 	CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
-	ABRecordID contactId = ABRecordGetRecordID(person);
-	picker.selectedId = contactId; // save so can return when dismiss
 
 	// Retreive pickedContact information
 	CDVContact* pickedContact = [[[CDVContact alloc] initFromABRecord:(ABRecordRef)person] autorelease];
 	NSArray *fields = [picker.options objectForKey:@"fields"] ?: [NSArray arrayWithObjects:@"id", nil];
 	NSDictionary *returnFields = [[CDVContact class] calcReturnFields: fields];
-	NSDictionary *pickedContactDictionary = [pickedContact toDictionary:returnFields];
+	picker.pickedContactDictionary = [pickedContact toDictionary:returnFields];
 	
 	if (picker.allowsEditing) {
 		
@@ -214,7 +212,7 @@
 		[peoplePicker pushViewController:personController animated:YES];
 	} else {
 		// return the pickedContact information
-		CDVPluginResult *result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: pickedContactDictionary];
+		CDVPluginResult *result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: picker.pickedContactDictionary];
 		[self writeJavascript:[result toSuccessCallbackString: picker.callbackId]];
 		
         if ([picker respondsToSelector:@selector(presentingViewController)]) { 
@@ -236,7 +234,7 @@
 {
 	// return contactId or invalid if none picked
 	CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
-	CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kABRecordInvalidID], @"id", nil]];
+	CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
 	[self writeJavascript:[result toSuccessCallbackString:picker.callbackId]];
 	
     if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) {