diff --git a/Signal/src/ViewControllers/ContactsViewHelper.h b/Signal/src/ViewControllers/ContactsViewHelper.h index 3101659ab..e963ba687 100644 --- a/Signal/src/ViewControllers/ContactsViewHelper.h +++ b/Signal/src/ViewControllers/ContactsViewHelper.h @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN /** * 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 fromViewController:(UIViewController *)fromViewController diff --git a/Signal/src/ViewControllers/ContactsViewHelper.m b/Signal/src/ViewControllers/ContactsViewHelper.m index 58f8f9981..e0b240206 100644 --- a/Signal/src/ViewControllers/ContactsViewHelper.m +++ b/Signal/src/ViewControllers/ContactsViewHelper.m @@ -5,6 +5,7 @@ #import "ContactsViewHelper.h" #import "ContactTableViewCell.h" #import "Environment.h" +#import "OWSProfileManager.h" #import "Signal-Swift.h" #import #import @@ -28,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) BOOL shouldNotifyDelegateOfUpdatedContacts; @property (nonatomic) BOOL hasUpdatedContactsAtLeastOnce; +@property (nonatomic) OWSProfileManager *profileManager; @end @@ -49,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN _blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers]; _contactsManager = [Environment getCurrent].contactsManager; + _profileManager = [OWSProfileManager sharedManager]; // We don't want to notify the delegate in the `updateContacts`. self.shouldNotifyDelegateOfUpdatedContacts = YES; @@ -409,6 +412,13 @@ NS_ASSUME_NONNULL_BEGIN CNLabeledValue *labeledPhoneNumber = [CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberMain value:phoneNumber]; 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]; }