Rework handling of phone number names.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 4032f40a3f
commit 535fc566a5

@ -198,59 +198,20 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification =
}
// 1. Find the phone number type of this account.
OWSPhoneNumberType phoneNumberType = [contact phoneNumberTypeForPhoneNumber:recipientId];
NSString *phoneNumberLabel;
switch (phoneNumberType) {
case OWSPhoneNumberTypeMobile:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_MOBILE", @"Label for 'Mobile' phone numbers.");
break;
case OWSPhoneNumberTypeIPhone:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_IPHONE", @"Label for 'IPhone' phone numbers.");
break;
case OWSPhoneNumberTypeMain:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_MAIN", @"Label for 'Main' phone numbers.");
break;
case OWSPhoneNumberTypeHomeFAX:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_HOME_FAX", @"Label for 'HomeFAX' phone numbers.");
break;
case OWSPhoneNumberTypeWorkFAX:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_WORK_FAX", @"Label for 'Work FAX' phone numbers.");
break;
case OWSPhoneNumberTypeOtherFAX:
phoneNumberLabel
= NSLocalizedString(@"PHONE_NUMBER_TYPE_OTHER_FAX", @"Label for 'Other FAX' phone numbers.");
break;
case OWSPhoneNumberTypePager:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_PAGER", @"Label for 'Pager' phone numbers.");
break;
case OWSPhoneNumberTypeUnknown:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_UNKNOWN",
@"Label used when we don't what kind of phone number it is (e.g. mobile/work/home).");
break;
case OWSPhoneNumberTypeHome:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_HOME", @"Label for 'Home' phone numbers.");
break;
case OWSPhoneNumberTypeWork:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_WORK", @"Label for 'Work' phone numbers.");
break;
case OWSPhoneNumberTypeOther:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_OTHER", @"Label for 'Other' phone numbers.");
break;
}
NSString *phoneNumberLabel = [contact nameForPhoneNumber:recipientId];
// 2. Find all phone numbers for this contact of the same type.
NSMutableArray *phoneNumbersOfTheSameType = [NSMutableArray new];
NSMutableArray *phoneNumbersWithTheSameName = [NSMutableArray new];
for (NSString *textSecureIdentifier in contact.textSecureIdentifiers) {
if (phoneNumberType == [contact phoneNumberTypeForPhoneNumber:textSecureIdentifier]) {
[phoneNumbersOfTheSameType addObject:textSecureIdentifier];
if ([phoneNumberLabel isEqualToString:[contact nameForPhoneNumber:textSecureIdentifier]]) {
[phoneNumbersWithTheSameName addObject:textSecureIdentifier];
}
}
OWSAssert([phoneNumbersOfTheSameType containsObject:recipientId]);
if (phoneNumbersOfTheSameType.count > 1) {
OWSAssert([phoneNumbersWithTheSameName containsObject:recipientId]);
if (phoneNumbersWithTheSameName.count > 1) {
NSUInteger index =
[[phoneNumbersOfTheSameType sortedArrayUsingSelector:@selector(compare:)] indexOfObject:recipientId];
[[phoneNumbersWithTheSameName sortedArrayUsingSelector:@selector(compare:)] indexOfObject:recipientId];
phoneNumberLabel =
[NSString stringWithFormat:NSLocalizedString(@"PHONE_NUMBER_TYPE_AND_INDEX_FORMAT",
@"Format for phone number label with an index. Embeds {{Phone number label "
@ -415,7 +376,6 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification =
return [[Contact alloc] initWithContactWithFirstName:self.unknownContactName
andLastName:nil
andUserTextPhoneNumbers:@[ identifier ]
phoneNumberTypeMap:nil
andImage:nil
andContactID:0];
}

@ -421,6 +421,9 @@
/* Generic error used whenver Signal can't contact the server */
"ERROR_DESCRIPTION_NO_INTERNET" = "Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data.";
/* Error indicating that an outgoing message had no valid recipients. */
"ERROR_DESCRIPTION_NO_VALID_RECIPIENTS" = "ERROR_DESCRIPTION_NO_VALID_RECIPIENTS";
/* Error message when attempting to send message */
"ERROR_DESCRIPTION_SENDING_UNAUTHORIZED" = "Your device is no longer registered for your phone number. You must remove and reinstall Signal.";
@ -574,7 +577,8 @@
/* No comment provided by engineer. */
"INCOMING_INCOMPLETE_CALL" = "Incomplete incoming call from";
/* Label for the cell that presents the 'invite contacts' workflow. */
/* Label for the cell that presents the 'invite contacts' workflow.
Text for button at the top of the contact picker */
"INVITE_FRIENDS_CONTACT_TABLE_BUTTON" = "Invite Friends to Signal";
/* Search */
@ -658,9 +662,6 @@
/* message footer while attachment is uploading */
"MESSAGE_STATUS_UPLOADING" = "Uploading…";
/* A label for audio attachments of unknown type. */
"MESSAGES_VIEW_AUDIO_TYPE_GENERIC" = "Audio";
/* Indicates that this 1:1 conversation has been blocked. */
"MESSAGES_VIEW_CONTACT_BLOCKED" = "You Blocked this User";
@ -830,7 +831,7 @@
"OVERSIZE_TEXT_MESSAGE_VIEW_TITLE" = "Message";
/* Format for phone number label with an index. Embeds {{Phone number label (e.g. 'home')}} and {{index, e.g. 2}}. */
"PHONE_NUMBER_TYPE_AND_INDEX_FORMAT" = "%@ (%d)";
"PHONE_NUMBER_TYPE_AND_INDEX_FORMAT" = "%@ %d";
/* Label for 'Home' phone numbers. */
"PHONE_NUMBER_TYPE_HOME" = "Home";
@ -856,6 +857,9 @@
/* Label for 'Pager' phone numbers. */
"PHONE_NUMBER_TYPE_PAGER" = "Pager";
/* Label for 'Radio' phone numbers. */
"PHONE_NUMBER_TYPE_RADIO" = "Radio";
/* Label used when we don't what kind of phone number it is (e.g. mobile/work/home). */
"PHONE_NUMBER_TYPE_UNKNOWN" = "Unknown";

Loading…
Cancel
Save