Provide default labels for custom contact fields.

This commit is contained in:
Matthew Chen 2018-05-02 15:47:16 -04:00
parent 72102cd5fa
commit b37588fc4c
3 changed files with 26 additions and 36 deletions

View file

@ -285,6 +285,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
}
[self updateBarButtonItems];
dispatch_async(dispatch_get_main_queue(), ^{
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
});
}
- (void)applyDefaultBackButton

View file

@ -406,6 +406,9 @@
/* Generic button text to proceed with an action */
"CONFIRMATION_TITLE" = "Confirm";
/* Label for a contact's postal address. */
"CONTACT_ADDRESS" = "Address";
/* An indicator that a contact has been blocked. */
"CONTACT_CELL_IS_BLOCKED" = "Blocked";
@ -415,6 +418,12 @@
/* No comment provided by engineer. */
"CONTACT_DETAIL_COMM_TYPE_INSECURE" = "Unregistered Number";
/* Label for a contact's email address. */
"CONTACT_EMAIL" = "Email";
/* Label for a contact's phone number. */
"CONTACT_PHONE" = "Phone";
/* table cell subtitle when contact card has no email */
"CONTACT_PICKER_NO_EMAILS_AVAILABLE" = "No email available.";

View file

@ -49,18 +49,7 @@ NSString *NSStringForContactPhoneType(OWSContactPhoneType value)
DDLogWarn(@"%@ invalid phone number; not e164: %@.", self.logTag, self.phoneNumber);
return NO;
}
switch (self.phoneType) {
case OWSContactPhoneType_Home:
case OWSContactPhoneType_Mobile:
case OWSContactPhoneType_Work:
return YES;
case OWSContactPhoneType_Custom:
if (self.label.ows_stripped.length < 1) {
DDLogWarn(@"%@ invalid phone number; missing custom label: %@.", self.logTag, self.label);
return NO;
}
return YES;
}
return YES;
}
- (NSString *)localizedLabel
@ -73,7 +62,10 @@ NSString *NSStringForContactPhoneType(OWSContactPhoneType value)
case OWSContactPhoneType_Work:
return [CNLabeledValue localizedStringForLabel:CNLabelWork];
default:
return self.label;
if (self.label.ows_stripped.length < 1) {
return NSLocalizedString(@"CONTACT_PHONE", @"Label for a contact's phone number.");
}
return self.label.ows_stripped;
}
}
@ -130,18 +122,7 @@ NSString *NSStringForContactEmailType(OWSContactEmailType value)
DDLogWarn(@"%@ invalid email: %@.", self.logTag, self.email);
return NO;
}
switch (self.emailType) {
case OWSContactEmailType_Home:
case OWSContactEmailType_Mobile:
case OWSContactEmailType_Work:
return YES;
case OWSContactEmailType_Custom:
if (self.label.ows_stripped.length < 1) {
DDLogWarn(@"%@ invalid email; missing custom label: %@.", self.logTag, self.label);
return NO;
}
return YES;
}
}
- (NSString *)localizedLabel
@ -154,7 +135,10 @@ NSString *NSStringForContactEmailType(OWSContactEmailType value)
case OWSContactEmailType_Work:
return [CNLabeledValue localizedStringForLabel:CNLabelWork];
default:
return self.label;
if (self.label.ows_stripped.length < 1) {
return NSLocalizedString(@"CONTACT_EMAIL", @"Label for a contact's email address.");
}
return self.label.ows_stripped;
}
}
@ -217,17 +201,7 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
DDLogWarn(@"%@ invalid address; empty.", self.logTag);
return NO;
}
switch (self.addressType) {
case OWSContactAddressType_Home:
case OWSContactAddressType_Work:
return YES;
case OWSContactAddressType_Custom:
if (self.label.ows_stripped.length < 1) {
DDLogWarn(@"%@ invalid address; missing custom label: %@.", self.logTag, self.label);
return NO;
}
return YES;
}
}
- (NSString *)localizedLabel
@ -238,7 +212,10 @@ NSString *NSStringForContactAddressType(OWSContactAddressType value)
case OWSContactAddressType_Work:
return [CNLabeledValue localizedStringForLabel:CNLabelWork];
default:
return self.label;
if (self.label.ows_stripped.length < 1) {
return NSLocalizedString(@"CONTACT_ADDRESS", @"Label for a contact's postal address.");
}
return self.label.ows_stripped;
}
}