Fix build warnings.

pull/1/head
Matthew Chen 7 years ago
parent 9a08afae28
commit 6f0c1a975b

@ -19,7 +19,6 @@
#import <SignalServiceKit/PhoneNumber.h> #import <SignalServiceKit/PhoneNumber.h>
#import <SignalServiceKit/SignalAccount.h> #import <SignalServiceKit/SignalAccount.h>
@import AddressBook;
@import Contacts; @import Contacts;
NSString *const OWSContactsManagerSignalAccountsDidChangeNotification NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
@ -570,9 +569,9 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
NSDictionary<NSString *, id> *normalFontAttributes = NSDictionary<NSString *, id> *normalFontAttributes =
@{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor ows_darkGrayColor] }; @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor ows_darkGrayColor] };
NSDictionary<NSString *, id> *firstNameAttributes NSDictionary<NSString *, id> *firstNameAttributes
= (ABPersonGetSortOrdering() == kABPersonSortByFirstName ? boldFontAttributes : normalFontAttributes); = (self.shouldSortByGivenName ? boldFontAttributes : normalFontAttributes);
NSDictionary<NSString *, id> *lastNameAttributes NSDictionary<NSString *, id> *lastNameAttributes
= (ABPersonGetSortOrdering() == kABPersonSortByFirstName ? normalFontAttributes : boldFontAttributes); = (self.shouldSortByGivenName ? normalFontAttributes : boldFontAttributes);
NSString *cachedFirstName = [self cachedFirstNameForRecipientId:recipientId]; NSString *cachedFirstName = [self cachedFirstNameForRecipientId:recipientId];
NSString *cachedLastName = [self cachedLastNameForRecipientId:recipientId]; NSString *cachedLastName = [self cachedLastNameForRecipientId:recipientId];
@ -585,8 +584,12 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
NSAttributedString *lastName = NSAttributedString *lastName =
[[NSAttributedString alloc] initWithString:cachedLastName attributes:lastNameAttributes]; [[NSAttributedString alloc] initWithString:cachedLastName attributes:lastNameAttributes];
CNMutableContact *formatContact = [CNMutableContact new];
formatContact.givenName = firstName.string;
formatContact.familyName = lastName.string;
CNContactDisplayNameOrder nameOrder = [CNContactFormatter nameOrderForContact:formatContact];
NSAttributedString *_Nullable leftName, *_Nullable rightName; NSAttributedString *_Nullable leftName, *_Nullable rightName;
if (ABPersonGetCompositeNameFormat() == kABPersonCompositeNameFormatFirstNameFirst) { if (nameOrder == CNContactDisplayNameOrderGivenNameFirst) {
leftName = firstName; leftName = firstName;
rightName = lastName; rightName = lastName;
} else { } else {
@ -812,11 +815,16 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
}; };
} }
- (BOOL)shouldSortByGivenName
{
return [[CNContactsUserDefaults sharedDefaults] sortOrder] == CNContactSortOrderGivenName;
}
- (NSString *)comparableNameForSignalAccount:(SignalAccount *)signalAccount - (NSString *)comparableNameForSignalAccount:(SignalAccount *)signalAccount
{ {
NSString *_Nullable name; NSString *_Nullable name;
if (signalAccount.contact) { if (signalAccount.contact) {
if (ABPersonGetSortOrdering() == kABPersonSortByFirstName) { if (self.shouldSortByGivenName) {
name = signalAccount.contact.comparableNameFirstLast; name = signalAccount.contact.comparableNameFirstLast;
} else { } else {
name = signalAccount.contact.comparableNameLastFirst; name = signalAccount.contact.comparableNameLastFirst;

Loading…
Cancel
Save