diff --git a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m index bb3b8bbdb..f22e16e5b 100644 --- a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m @@ -168,7 +168,14 @@ NS_ASSUME_NONNULL_BEGIN __weak ShowGroupMembersViewController *weakSelf = self; ContactsViewHelper *helper = self.contactsViewHelper; - for (NSString *recipientId in [recipientIds sortedArrayUsingSelector:@selector(compare:)]) { + // Sort the group members using contacts manager. + NSArray *sortedRecipientIds = + [recipientIds sortedArrayUsingComparator:^NSComparisonResult(NSString *recipientIdA, NSString *recipientIdB) { + SignalAccount *signalAccountA = [helper.contactsManager signalAccountForRecipientId:recipientIdA]; + SignalAccount *signalAccountB = [helper.contactsManager signalAccountForRecipientId:recipientIdB]; + return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB]; + }]; + for (NSString *recipientId in sortedRecipientIds) { [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ ShowGroupMembersViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 8d42b0441..eadbc4cb2 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -78,17 +78,14 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; _nameLabel = [UILabel new]; _nameLabel.lineBreakMode = NSLineBreakByTruncatingTail; - _nameLabel.font = [UIFont ows_dynamicTypeBodyFont]; [_nameContainerView addSubview:_nameLabel]; _profileNameLabel = [UILabel new]; _profileNameLabel.lineBreakMode = NSLineBreakByTruncatingTail; - _profileNameLabel.font = [UIFont ows_regularFontWithSize:11.f]; _profileNameLabel.textColor = [UIColor grayColor]; [_nameContainerView addSubview:_profileNameLabel]; _subtitle = [UILabel new]; - _subtitle.font = [UIFont ows_regularFontWithSize:11.f]; _subtitle.textColor = [UIColor ows_darkGrayColor]; [_nameContainerView addSubview:self.subtitle]; @@ -113,10 +110,19 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; [_nameContainerView autoPinLeadingToTrailingEdgeOfView:_avatarView offset:kContactTableViewCellAvatarTextMargin]; [_nameContainerView autoPinTrailingToSuperviewMargin]; + [self configureFonts]; + // Force layout, since imageView isn't being initally rendered on App Store optimized build. [self layoutSubviews]; } +- (void)configureFonts +{ + self.nameLabel.font = [UIFont ows_dynamicTypeBodyFont]; + self.profileNameLabel.font = [UIFont ows_regularFontWithSize:11.f]; + self.subtitle.font = [UIFont ows_regularFontWithSize:11.f]; +} + - (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager { [self configureWithRecipientId:signalAccount.recipientId contactsManager:contactsManager]; @@ -124,6 +130,12 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager { + OWSAssert(recipientId.length > 0); + OWSAssert(contactsManager); + + // Update fonts to reflect changes to dynamic type. + [self configureFonts]; + self.recipientId = recipientId; self.contactsManager = contactsManager; @@ -155,6 +167,10 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; - (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager { OWSAssert(thread); + + // Update fonts to reflect changes to dynamic type. + [self configureFonts]; + self.contactsManager = contactsManager; NSString *threadName = thread.name; diff --git a/SignalMessaging/contacts/OWSContactsManager.h b/SignalMessaging/contacts/OWSContactsManager.h index f49dc29cb..90ee69dc5 100644 --- a/SignalMessaging/contacts/OWSContactsManager.h +++ b/SignalMessaging/contacts/OWSContactsManager.h @@ -70,6 +70,7 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification; * Used for sorting, respects system contacts name sort order preference. */ - (NSString *)comparableNameForSignalAccount:(SignalAccount *)signalAccount; +- (NSComparisonResult)compareSignalAccount:(SignalAccount *)left withSignalAccount:(SignalAccount *)right; // Generally we prefer the formattedProfileName over the raw profileName so as to // distinguish a profile name apart from a name pulled from the system's contacts. diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m index 8d590e4cc..5f0ddc19f 100644 --- a/SignalMessaging/contacts/OWSContactsManager.m +++ b/SignalMessaging/contacts/OWSContactsManager.m @@ -757,6 +757,11 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification return image; } +- (NSComparisonResult)compareSignalAccount:(SignalAccount *)left withSignalAccount:(SignalAccount *)right +{ + return self.signalAccountComparator(left, right); +} + - (NSComparisonResult (^)(SignalAccount *left, SignalAccount *right))signalAccountComparator { return ^NSComparisonResult(SignalAccount *left, SignalAccount *right) {