-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-20589] iOS: Allow editing contacts in iOS9 and above #7870
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,10 @@ -(NSArray*)members:(id)unused | |
CNContactFetchRequest *fetchRequest = [[CNContactFetchRequest alloc] initWithKeysToFetch:[ContactsModule contactKeysWithImage]]; | ||
fetchRequest.predicate = [CNContact predicateForContactsInGroupWithIdentifier:[group identifier]]; | ||
BOOL success = [ourContactStore enumerateContactsWithFetchRequest:fetchRequest error:&error usingBlock:^(CNContact * __nonnull contact, BOOL * __nonnull stop) { | ||
TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[self executionContext] contactId:(CNMutableContact*)contact module:module] autorelease]; | ||
TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[self executionContext] | ||
contactId:(CNMutableContact*)contact | ||
module:module | ||
observer:module] autorelease]; | ||
[peopleRefs addObject:person]; | ||
}]; | ||
if (success) { | ||
|
@@ -211,7 +214,11 @@ -(NSArray*)sortedMembers:(id)value | |
fetchRequest.sortOrder = sortOrder; | ||
fetchRequest.mutableObjects = YES; | ||
BOOL success = [ourContactStore enumerateContactsWithFetchRequest:fetchRequest error:&error usingBlock:^(CNContact * __nonnull contact, BOOL * __nonnull stop) { | ||
TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[self executionContext] contactId:(CNMutableContact*)contact module:module] autorelease]; | ||
// Observer is module because we want all changes to be propagated and the respective CNSaveRequest is updated. | ||
TiContactsPerson* person = [[[TiContactsPerson alloc] _initWithPageContext:[self executionContext] | ||
contactId:(CNMutableContact*)contact | ||
module:module | ||
observer:module] autorelease]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the observer be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hansemannn observer is |
||
[peopleRefs addObject:person]; | ||
}]; | ||
RELEASE_TO_NIL(fetchRequest) | ||
|
@@ -259,7 +266,6 @@ -(void)add:(id)arg | |
{ | ||
ENSURE_SINGLE_ARG(arg,TiContactsPerson) | ||
ENSURE_UI_THREAD(add,arg); | ||
|
||
if ([TiUtils isIOS9OrGreater]) { | ||
TiContactsPerson *person = arg; | ||
CNContactStore *ourContactStore = [module contactStore]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,12 @@ | |
#import <AddressBook/AddressBook.h> | ||
#import <Contacts/Contacts.h> | ||
|
||
@class TiContactsPerson; | ||
@protocol TiContactsPersonUpdateObserver <NSObject> | ||
@optional | ||
- (void)didUpdatePerson:(TiContactsPerson*)person; | ||
@end | ||
|
||
@class ContactsModule; | ||
|
||
@interface TiContactsPerson : TiProxy { | ||
|
@@ -31,10 +37,19 @@ | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the initializer I wanted to stay there (with no observer), so modules can still use it. |
||
-(id)_initWithPageContext:(id<TiEvaluator>)context recordId:(ABRecordID)id_ module:(ContactsModule*)module_; | ||
-(id)_initWithPageContext:(id<TiEvaluator>)context person:(ABRecordRef)person_ module:(ContactsModule*)module_; | ||
|
||
@property(readonly,nonatomic) NSString* identifier; | ||
@property(assign, nonatomic) id<TiContactsPersonUpdateObserver> observer; | ||
|
||
+(NSDictionary*)iOS9multiValueLabels; | ||
+(NSDictionary*)iOS9propertyKeys; | ||
-(id)_initWithPageContext:(id<TiEvaluator>)context contactId:(CNMutableContact*)person_ module:(ContactsModule*)module_; | ||
-(id)_initWithPageContext:(id<TiEvaluator>)context | ||
contactId:(CNMutableContact*)person_ | ||
module:(ContactsModule*)module_; | ||
-(id)_initWithPageContext:(id<TiEvaluator>)context | ||
contactId:(CNMutableContact*)person_ | ||
module:(ContactsModule*)module_ | ||
observer:(id<TiContactsPersonUpdateObserver>) observer_; | ||
-(CNSaveRequest*)getSaveRequestForDeletion; | ||
-(CNSaveRequest*)getSaveRequestForAddition:(NSString*)containerIdentifier; | ||
-(CNSaveRequest*)getSaveRequestForAddToGroup: (CNMutableGroup*) group; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may should consider to leave the old initializer in place, because module developers might use the interface their modules. Also, we don't need to nil the observer on those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats right. Retained old initialiser and made the new initialiser as the designated initialiser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes the required arguments
contactId:newContact module:self
. Did you test the changes?