Use profile name/avatar when creating new contact

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 9f45ddd393
commit 0290f176c0

@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
/** /**
* NOTE: This method calls `[UIUtil applyDefaultSystemAppearence]`. * NOTE: This method calls `[UIUtil applyDefaultSystemAppearence]`.
* When using this method, you must call `[UIUtil applySignalAppearence]` once contact editing is finished; * When using this method, you must call `[UIUtil applySignalAppearence]` once contact editing is finished;
*/ */
- (void)presentContactViewControllerForRecipientId:(NSString *)recipientId - (void)presentContactViewControllerForRecipientId:(NSString *)recipientId
fromViewController:(UIViewController<ContactEditingDelegate> *)fromViewController fromViewController:(UIViewController<ContactEditingDelegate> *)fromViewController

@ -5,6 +5,7 @@
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "Environment.h" #import "Environment.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalServiceKit/Contact.h> #import <SignalServiceKit/Contact.h>
#import <SignalServiceKit/OWSBlockingManager.h> #import <SignalServiceKit/OWSBlockingManager.h>
@ -28,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts; @property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts;
@property (nonatomic) BOOL hasUpdatedContactsAtLeastOnce; @property (nonatomic) BOOL hasUpdatedContactsAtLeastOnce;
@property (nonatomic) OWSProfileManager *profileManager;
@end @end
@ -49,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers]; _blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
_contactsManager = [Environment getCurrent].contactsManager; _contactsManager = [Environment getCurrent].contactsManager;
_profileManager = [OWSProfileManager sharedManager];
// We don't want to notify the delegate in the `updateContacts`. // We don't want to notify the delegate in the `updateContacts`.
self.shouldNotifyDelegateOfUpdatedContacts = YES; self.shouldNotifyDelegateOfUpdatedContacts = YES;
@ -409,6 +412,13 @@ NS_ASSUME_NONNULL_BEGIN
CNLabeledValue<CNPhoneNumber *> *labeledPhoneNumber = CNLabeledValue<CNPhoneNumber *> *labeledPhoneNumber =
[CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber]; [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber];
newContact.phoneNumbers = @[ labeledPhoneNumber ]; newContact.phoneNumbers = @[ labeledPhoneNumber ];
newContact.givenName = [self.profileManager profileNameForRecipientId:recipientId];
UIImage *_Nullable profileImage = [self.profileManager profileAvatarForRecipientId:recipientId];
if (profileImage) {
// TODO get raw jpg data from profileManager to avoid recompress.
newContact.imageData = UIImageJPEGRepresentation(profileImage, 0.9);
}
contactViewController = [CNContactViewController viewControllerForNewContact:newContact]; contactViewController = [CNContactViewController viewControllerForNewContact:newContact];
} }

Loading…
Cancel
Save