Auto-size contact cells everywhere.

pull/1/head
Matthew Chen 7 years ago
parent f8e785ef72
commit dd49c6225f

@ -43,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN
[_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinWidthToSuperview];
[_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0];
[_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom];
self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension;
// self.tableView.estimatedRowHeight = 60;
[self updateTableContents]; [self updateTableContents];
} }
@ -78,18 +80,22 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<NSString *> *blockedPhoneNumbers = NSArray<NSString *> *blockedPhoneNumbers =
[helper.blockedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)]; [helper.blockedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)];
for (NSString *phoneNumber in blockedPhoneNumbers) { for (NSString *phoneNumber in blockedPhoneNumbers) {
[blocklistSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [blocklistSection addItem:[OWSTableItem
ContactTableViewCell *cell = [ContactTableViewCell new]; itemWithCustomCellBlock:^{
SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber]; ContactTableViewCell *cell = [ContactTableViewCell new];
if (signalAccount) { SignalAccount *signalAccount =
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [helper signalAccountForRecipientId:phoneNumber];
} else { if (signalAccount) {
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
} contactsManager:helper.contactsManager];
} else {
return cell; [cell configureWithRecipientId:phoneNumber
} contactsManager:helper.contactsManager];
customRowHeight:[ContactTableViewCell rowHeight] }
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber [BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber
fromViewController:weakSelf fromViewController:weakSelf

@ -248,7 +248,6 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
statusLabel.adjustsFontSizeToFitWidth = true statusLabel.adjustsFontSizeToFitWidth = true
statusLabel.sizeToFit() statusLabel.sizeToFit()
cell.accessoryView = statusLabel cell.accessoryView = statusLabel
cell.autoSetDimension(.height, toSize: ContactTableViewCell.rowHeight())
cell.setContentHuggingLow() cell.setContentHuggingLow()
cell.isUserInteractionEnabled = false cell.isUserInteractionEnabled = false
groupRows.append(cell) groupRows.append(cell)

@ -284,12 +284,6 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Table Contents #pragma mark - Table Contents
- (CGFloat)actionCellHeight
{
return ScaleFromIPhone5To7Plus(round((kOWSTable_DefaultCellHeight + [ContactTableViewCell rowHeight]) * 0.5f),
[ContactTableViewCell rowHeight]);
}
- (void)updateTableContents - (void)updateTableContents
{ {
OWSTableContents *contents = [OWSTableContents new]; OWSTableContents *contents = [OWSTableContents new];
@ -307,7 +301,7 @@ NS_ASSUME_NONNULL_BEGIN
[staticSection [staticSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER",
@"A label the cell that lets you add a new member to a group.") @"A label the cell that lets you add a new member to a group.")
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NewNonContactConversationViewController *viewController = NewNonContactConversationViewController *viewController =
[NewNonContactConversationViewController new]; [NewNonContactConversationViewController new];
@ -322,7 +316,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON", disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON",
@"Label for the cell that presents the 'invite contacts' workflow.") @"Label for the cell that presents the 'invite contacts' workflow.")
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf presentInviteFlow]; [weakSelf presentInviteFlow];
}]]; }]];
@ -382,7 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem softCenterLabelItemWithText: addItem:[OWSTableItem softCenterLabelItemWithText:
NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS", NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS",
@"A label that indicates the user has no Signal contacts.") @"A label that indicates the user has no Signal contacts.")
customRowHeight:self.actionCellHeight]]; customRowHeight:UITableViewAutomaticDimension]];
} else { } else {
UITableViewCell *loadingCell = [UITableViewCell new]; UITableViewCell *loadingCell = [UITableViewCell new];
OWSAssert(loadingCell.contentView); OWSAssert(loadingCell.contentView);
@ -481,34 +475,37 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(phoneNumber.length > 0); OWSAssert(phoneNumber.length > 0);
if ([self.nonContactAccountSet containsObject:phoneNumber]) { if ([self.nonContactAccountSet containsObject:phoneNumber]) {
[phoneNumbersSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [phoneNumbersSection
ContactTableViewCell *cell = [ContactTableViewCell new]; addItem:[OWSTableItem
BOOL isBlocked = [helper isRecipientIdBlocked:phoneNumber]; itemWithCustomCellBlock:^{
if (isBlocked) { ContactTableViewCell *cell = [ContactTableViewCell new];
cell.accessoryMessage = NSLocalizedString( BOOL isBlocked = [helper isRecipientIdBlocked:phoneNumber];
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); if (isBlocked) {
} cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber]; }
if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber];
} else { if (signalAccount) {
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
} contactsManager:helper.contactsManager];
} else {
return cell; [cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
} }
customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{ return cell;
[weakSelf newConversationWithRecipientId:phoneNumber]; }
}]]; customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
[weakSelf newConversationWithRecipientId:phoneNumber];
}]];
} else { } else {
NSString *text = [NSString stringWithFormat:NSLocalizedString(@"SEND_INVITE_VIA_SMS_BUTTON_FORMAT", NSString *text = [NSString stringWithFormat:NSLocalizedString(@"SEND_INVITE_VIA_SMS_BUTTON_FORMAT",
@"Text for button to send a Signal invite via SMS. %@ is " @"Text for button to send a Signal invite via SMS. %@ is "
@"placeholder for the recipient's phone number."), @"placeholder for the recipient's phone number."),
phoneNumber]; phoneNumber];
[phoneNumbersSection addItem:[OWSTableItem disclosureItemWithText:text [phoneNumbersSection addItem:[OWSTableItem disclosureItemWithText:text
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf sendTextToPhoneNumber:phoneNumber]; [weakSelf sendTextToPhoneNumber:phoneNumber];
}]]; }]];
@ -533,22 +530,24 @@ NS_ASSUME_NONNULL_BEGIN
// results. // results.
continue; continue;
} }
[contactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [contactsSection
ContactTableViewCell *cell = [ContactTableViewCell new]; addItem:[OWSTableItem
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId]; itemWithCustomCellBlock:^{
if (isBlocked) { ContactTableViewCell *cell = [ContactTableViewCell new];
cell.accessoryMessage BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); if (isBlocked) {
} cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; }
return cell; [cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
}
customRowHeight:[ContactTableViewCell rowHeight] return cell;
actionBlock:^{ }
[weakSelf newConversationWithRecipientId:signalAccount.recipientId]; customRowHeight:UITableViewAutomaticDimension
}]]; actionBlock:^{
[weakSelf newConversationWithRecipientId:signalAccount.recipientId];
}]];
} }
if (filteredSignalAccounts.count > 0) { if (filteredSignalAccounts.count > 0) {
[sections addObject:contactsSection]; [sections addObject:contactsSection];
@ -562,12 +561,13 @@ NS_ASSUME_NONNULL_BEGIN
for (TSGroupThread *thread in filteredGroupThreads) { for (TSGroupThread *thread in filteredGroupThreads) {
hasSearchResults = YES; hasSearchResults = YES;
[groupSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [groupSection addItem:[OWSTableItem
GroupTableViewCell *cell = [GroupTableViewCell new]; itemWithCustomCellBlock:^{
[cell configureWithThread:thread contactsManager:helper.contactsManager]; GroupTableViewCell *cell = [GroupTableViewCell new];
return cell; [cell configureWithThread:thread contactsManager:helper.contactsManager];
} return cell;
customRowHeight:[ContactTableViewCell rowHeight] }
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf newConversationWithThread:thread]; [weakSelf newConversationWithThread:thread];
}]]; }]];
@ -597,7 +597,7 @@ NS_ASSUME_NONNULL_BEGIN
@"placeholder for the recipient's phone number."), @"placeholder for the recipient's phone number."),
displayName]; displayName];
[inviteeSection addItem:[OWSTableItem disclosureItemWithText:text [inviteeSection addItem:[OWSTableItem disclosureItemWithText:text
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf sendTextToPhoneNumber:phoneNumber.toE164]; [weakSelf sendTextToPhoneNumber:phoneNumber.toE164];
}]]; }]];
@ -614,7 +614,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem softCenterLabelItemWithText: addItem:[OWSTableItem softCenterLabelItemWithText:
NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_SEARCH_RESULTS", NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_SEARCH_RESULTS",
@"A label that indicates the user's search has no matching results.") @"A label that indicates the user's search has no matching results.")
customRowHeight:self.actionCellHeight]]; customRowHeight:UITableViewAutomaticDimension]];
[sections addObject:noResultsSection]; [sections addObject:noResultsSection];
} }

@ -216,35 +216,39 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
[nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) { [nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[nonContactsSection [nonContactsSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
NewGroupViewController *strongSelf = weakSelf; itemWithCustomCellBlock:^{
OWSCAssert(strongSelf); NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId]; SignalAccount *signalAccount =
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; [contactsViewHelper signalAccountForRecipientId:recipientId];
if (isCurrentMember) { BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
// In the "contacts" section, we label members as such when editing an existing group. BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
cell.accessoryMessage = NSLocalizedString( if (isCurrentMember) {
@"NEW_GROUP_MEMBER_LABEL", @"An indicator that a user is a member of the new group."); // In the "contacts" section, we label members as such when editing an existing
} else if (isBlocked) { // group.
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(@"NEW_GROUP_MEMBER_LABEL",
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"An indicator that a user is a member of the new group.");
} else { } else if (isBlocked) {
OWSAssert(cell.accessoryMessage == nil); cell.accessoryMessage = NSLocalizedString(
} @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
if (signalAccount) { OWSAssert(cell.accessoryMessage == nil);
[cell configureWithSignalAccount:signalAccount }
contactsManager:contactsViewHelper.contactsManager];
} else { if (signalAccount) {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager]; [cell configureWithSignalAccount:signalAccount
} contactsManager:contactsViewHelper.contactsManager];
} else {
return cell; [cell configureWithRecipientId:recipientId
} contactsManager:contactsViewHelper.contactsManager];
customRowHeight:[ContactTableViewCell rowHeight] }
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
@ -309,31 +313,34 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
for (SignalAccount *signalAccount in signalAccounts) { for (SignalAccount *signalAccount in signalAccounts) {
[signalAccountSection [signalAccountSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
NewGroupViewController *strongSelf = weakSelf; itemWithCustomCellBlock:^{
OWSCAssert(strongSelf); NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
ContactTableViewCell *cell = [ContactTableViewCell new];
NSString *recipientId = signalAccount.recipientId;
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId]; NSString *recipientId = signalAccount.recipientId;
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
if (isCurrentMember) { BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
// In the "contacts" section, we label members as such when editing an existing group. if (isCurrentMember) {
cell.accessoryMessage = NSLocalizedString( // In the "contacts" section, we label members as such when editing an existing
@"NEW_GROUP_MEMBER_LABEL", @"An indicator that a user is a member of the new group."); // group.
} else if (isBlocked) { cell.accessoryMessage = NSLocalizedString(@"NEW_GROUP_MEMBER_LABEL",
cell.accessoryMessage = NSLocalizedString( @"An indicator that a user is a member of the new group.");
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } else if (isBlocked) {
} else { cell.accessoryMessage = NSLocalizedString(
OWSAssert(cell.accessoryMessage == nil); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} } else {
OWSAssert(cell.accessoryMessage == nil);
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager]; }
return cell; [cell configureWithSignalAccount:signalAccount
} contactsManager:contactsViewHelper.contactsManager];
customRowHeight:[ContactTableViewCell rowHeight]
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NSString *recipientId = signalAccount.recipientId; NSString *recipientId = signalAccount.recipientId;
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
@ -392,7 +399,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
return [OWSTableItem return [OWSTableItem
disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT", disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT",
@"A label for the cell that lets you add a new non-contact member to a group.") @"A label for the cell that lets you add a new non-contact member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
AddToGroupViewController *viewController = [AddToGroupViewController new]; AddToGroupViewController *viewController = [AddToGroupViewController new];
viewController.addToGroupDelegate = weakSelf; viewController.addToGroupDelegate = weakSelf;

@ -138,7 +138,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED",
@"Label for the button that clears all verification " @"Label for the button that clears all verification "
@"errors in the 'group members' view.") @"errors in the 'group members' view.")
customRowHeight:ContactTableViewCell.rowHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf offerResetAllNoLongerVerified]; [weakSelf offerResetAllNoLongerVerified];
}]]; }]];
@ -171,40 +171,42 @@ NS_ASSUME_NONNULL_BEGIN
return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB]; return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB];
}]; }];
for (NSString *recipientId in sortedRecipientIds) { for (NSString *recipientId in sortedRecipientIds) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [section addItem:[OWSTableItem
ShowGroupMembersViewController *strongSelf = weakSelf; itemWithCustomCellBlock:^{
OWSCAssert(strongSelf); ShowGroupMembersViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId]; ContactTableViewCell *cell = [ContactTableViewCell new];
OWSVerificationState verificationState = SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]; OWSVerificationState verificationState =
BOOL isVerified = verificationState == OWSVerificationStateVerified; [[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId];
BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified; BOOL isVerified = verificationState == OWSVerificationStateVerified;
BOOL isBlocked = [helper isRecipientIdBlocked:recipientId]; BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified;
if (isNoLongerVerified) { BOOL isBlocked = [helper isRecipientIdBlocked:recipientId];
cell.accessoryMessage = NSLocalizedString( if (isNoLongerVerified) {
@"CONTACT_CELL_IS_NO_LONGER_VERIFIED", @"An indicator that a contact is no longer verified."); cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_NO_LONGER_VERIFIED",
} else if (isBlocked) { @"An indicator that a contact is no longer verified.");
cell.accessoryMessage } else if (isBlocked) {
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); cell.accessoryMessage = NSLocalizedString(
} @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
}
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
} else { contactsManager:helper.contactsManager];
[cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager]; } else {
} [cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
}
if (isVerified) { if (isVerified) {
cell.subtitle.attributedText = cell.verifiedSubtitle; cell.subtitle.attributedText = cell.verifiedSubtitle;
} else { } else {
cell.subtitle.attributedText = nil; cell.subtitle.attributedText = nil;
} }
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
if (useVerifyAction) { if (useVerifyAction) {
[weakSelf showSafetyNumberView:recipientId]; [weakSelf showSafetyNumberView:recipientId];

@ -245,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem [section addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"EDIT_GROUP_MEMBERS_ADD_MEMBER", disclosureItemWithText:NSLocalizedString(@"EDIT_GROUP_MEMBERS_ADD_MEMBER",
@"Label for the cell that lets you add a new member to a group.") @"Label for the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
AddToGroupViewController *viewController = [AddToGroupViewController new]; AddToGroupViewController *viewController = [AddToGroupViewController new];
viewController.addToGroupDelegate = weakSelf; viewController.addToGroupDelegate = weakSelf;
@ -256,39 +256,43 @@ NS_ASSUME_NONNULL_BEGIN
[memberRecipientIds removeObject:[contactsViewHelper localNumber]]; [memberRecipientIds removeObject:[contactsViewHelper localNumber]];
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) { for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[section [section
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
UpdateGroupViewController *strongSelf = weakSelf; itemWithCustomCellBlock:^{
OWSCAssert(strongSelf); UpdateGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId]; SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId];
if (isPreviousMember) { BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isBlocked) { if (isPreviousMember) {
cell.accessoryMessage = NSLocalizedString( if (isBlocked) {
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); cell.accessoryMessage = NSLocalizedString(
} else { @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
cell.selectionStyle = UITableViewCellSelectionStyleNone; } else {
} cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else { }
// In the "members" section, we label "new" members as such when editing an existing group. } else {
// // In the "members" section, we label "new" members as such when editing an existing
// The only way a "new" member could be blocked is if we blocked them on a linked device // group.
// while in this dialog. We don't need to worry about that edge case. //
cell.accessoryMessage = NSLocalizedString( // The only way a "new" member could be blocked is if we blocked them on a linked device
@"EDIT_GROUP_NEW_MEMBER_LABEL", @"An indicator that a user is a new member of the group."); // while in this dialog. We don't need to worry about that edge case.
} cell.accessoryMessage = NSLocalizedString(@"EDIT_GROUP_NEW_MEMBER_LABEL",
@"An indicator that a user is a new member of the group.");
if (signalAccount) { }
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager];
} else { if (signalAccount) {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager]; [cell configureWithSignalAccount:signalAccount
} contactsManager:contactsViewHelper.contactsManager];
} else {
return cell; [cell configureWithRecipientId:recipientId
} contactsManager:contactsViewHelper.contactsManager];
customRowHeight:[ContactTableViewCell rowHeight] }
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId]; BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId];

@ -26,8 +26,6 @@ extern const CGFloat kContactTableViewCellAvatarTextMargin;
+ (NSString *)reuseIdentifier; + (NSString *)reuseIdentifier;
+ (CGFloat)rowHeight;
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;

@ -49,16 +49,6 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12;
return NSStringFromClass(self.class); return NSStringFromClass(self.class);
} }
- (CGSize)intrinsicContentSize
{
return CGSizeMake(self.width, ContactTableViewCell.rowHeight);
}
+ (CGFloat)rowHeight
{
return 60.f;
}
- (void)configureProgrammatically - (void)configureProgrammatically
{ {
OWSAssert(!self.nameLabel); OWSAssert(!self.nameLabel);

@ -521,33 +521,37 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
// Contacts // Contacts
for (SignalAccount *signalAccount in signalAccounts) { for (SignalAccount *signalAccount in signalAccounts) {
[contactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [contactsSection
SelectRecipientViewController *strongSelf = weakSelf; addItem:[OWSTableItem
OWSCAssert(strongSelf); itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf;
ContactTableViewCell *cell = [ContactTableViewCell new]; OWSCAssert(strongSelf);
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) { ContactTableViewCell *cell = [ContactTableViewCell new];
cell.accessoryMessage = NSLocalizedString( BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); if (isBlocked) {
} else { cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED",
cell.accessoryMessage = [weakSelf.delegate accessoryMessageForSignalAccount:signalAccount]; @"An indicator that a contact has been blocked.");
} } else {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; cell.accessoryMessage =
[weakSelf.delegate accessoryMessageForSignalAccount:signalAccount];
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { }
cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell configureWithSignalAccount:signalAccount
} contactsManager:helper.contactsManager];
return cell; if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
} cell.selectionStyle = UITableViewCellSelectionStyleNone;
customRowHeight:[ContactTableViewCell rowHeight] }
actionBlock:^{
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { return cell;
return; }
} customRowHeight:UITableViewAutomaticDimension
[weakSelf.delegate signalAccountWasSelected:signalAccount]; actionBlock:^{
}]]; if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
return;
}
[weakSelf.delegate signalAccountWasSelected:signalAccount];
}]];
} }
} }
[contents addSection:contactsSection]; [contents addSection:contactsSection];

@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
[findByPhoneSection [findByPhoneSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER",
@"A label the cell that lets you add a new member to a group.") @"A label the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NewNonContactConversationViewController *viewController = NewNonContactConversationViewController *viewController =
[NewNonContactConversationViewController new]; [NewNonContactConversationViewController new];
@ -186,74 +186,77 @@ NS_ASSUME_NONNULL_BEGIN
recentChatsSection.headerTitle = NSLocalizedString( recentChatsSection.headerTitle = NSLocalizedString(
@"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE", @"Table section header for recently active conversations"); @"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE", @"Table section header for recently active conversations");
for (TSThread *thread in [self filteredThreadsWithSearchText]) { for (TSThread *thread in [self filteredThreadsWithSearchText]) {
[recentChatsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [recentChatsSection
SelectThreadViewController *strongSelf = weakSelf; addItem:[OWSTableItem
OWSCAssert(strongSelf); itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
// To be consistent with the threads (above), we use ContactTableViewCell OWSCAssert(strongSelf);
// instead of HomeViewCell to present contacts and threads.
ContactTableViewCell *cell = [ContactTableViewCell new]; // To be consistent with the threads (above), we use ContactTableViewCell
// instead of HomeViewCell to present contacts and threads.
if ([thread isKindOfClass:[TSContactThread class]]) { ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked) { if ([thread isKindOfClass:[TSContactThread class]]) {
cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
} if (isBlocked) {
} cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
[cell configureWithThread:thread contactsManager:helper.contactsManager]; }
}
if (cell.accessoryView == nil) {
// Don't add a disappearing messages indicator if we've already added a "blocked" label. [cell configureWithThread:thread contactsManager:helper.contactsManager];
__block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { if (cell.accessoryView == nil) {
disappearingMessagesConfiguration = // Don't add a disappearing messages indicator if we've already added a "blocked" label.
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId __block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
transaction:transaction]; [self.uiDatabaseConnection
}]; readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
disappearingMessagesConfiguration = [OWSDisappearingMessagesConfiguration
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) { fetchObjectWithUniqueID:thread.uniqueId
DisappearingTimerConfigurationView *disappearingTimerConfigurationView = transaction:transaction];
[[DisappearingTimerConfigurationView alloc] }];
initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds];
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) {
disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44); DisappearingTimerConfigurationView *disappearingTimerConfigurationView =
disappearingTimerConfigurationView.tintColor = [UIColor colorWithWhite:0.5f alpha:1.f]; [[DisappearingTimerConfigurationView alloc]
initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds];
cell.accessoryView = disappearingTimerConfigurationView;
} disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44);
} disappearingTimerConfigurationView.tintColor =
[UIColor colorWithWhite:0.5f alpha:1.f];
return cell;
} cell.accessoryView = disappearingTimerConfigurationView;
customRowHeight:[ContactTableViewCell rowHeight] }
actionBlock:^{ }
typeof(self) strongSelf = weakSelf;
if (!strongSelf) { return cell;
return; }
} customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
if ([thread isKindOfClass:[TSContactThread class]]) { typeof(self) strongSelf = weakSelf;
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier]; if (!strongSelf) {
if (isBlocked return;
&& ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) { }
[BlockListUIUtils
showUnblockPhoneNumberActionSheet:thread.contactIdentifier if ([thread isKindOfClass:[TSContactThread class]]) {
fromViewController:strongSelf BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
blockingManager:helper.blockingManager if (isBlocked && ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) {
contactsManager:helper.contactsManager [BlockListUIUtils showUnblockPhoneNumberActionSheet:thread.contactIdentifier
completionBlock:^(BOOL isStillBlocked) { fromViewController:strongSelf
if (!isStillBlocked) { blockingManager:helper.blockingManager
[strongSelf.selectThreadViewDelegate contactsManager:helper.contactsManager
threadWasSelected:thread]; completionBlock:^(BOOL isStillBlocked) {
} if (!isStillBlocked) {
}]; [strongSelf.selectThreadViewDelegate
return; threadWasSelected:thread];
} }
} }];
return;
[strongSelf.selectThreadViewDelegate threadWasSelected:thread]; }
}]]; }
[strongSelf.selectThreadViewDelegate threadWasSelected:thread];
}]];
} }
if (recentChatsSection.itemCount > 0) { if (recentChatsSection.itemCount > 0) {
@ -266,25 +269,27 @@ NS_ASSUME_NONNULL_BEGIN
@"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE", @"Table section header for conversations you haven't recently used."); @"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE", @"Table section header for conversations you haven't recently used.");
NSArray<SignalAccount *> *filteredSignalAccounts = [self filteredSignalAccountsWithSearchText]; NSArray<SignalAccount *> *filteredSignalAccounts = [self filteredSignalAccountsWithSearchText];
for (SignalAccount *signalAccount in filteredSignalAccounts) { for (SignalAccount *signalAccount in filteredSignalAccounts) {
[otherContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [otherContactsSection
SelectThreadViewController *strongSelf = weakSelf; addItem:[OWSTableItem
OWSCAssert(strongSelf); itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
ContactTableViewCell *cell = [ContactTableViewCell new]; OWSCAssert(strongSelf);
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) { ContactTableViewCell *cell = [ContactTableViewCell new];
cell.accessoryMessage BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); if (isBlocked) {
} else { cell.accessoryMessage = NSLocalizedString(
OWSAssert(cell.accessoryMessage == nil); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} } else {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; OWSAssert(cell.accessoryMessage == nil);
return cell; }
} [cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
customRowHeight:[ContactTableViewCell rowHeight] return cell;
actionBlock:^{ }
[weakSelf signalAccountWasSelected:signalAccount]; customRowHeight:UITableViewAutomaticDimension
}]]; actionBlock:^{
[weakSelf signalAccountWasSelected:signalAccount];
}]];
} }
if (otherContactsSection.itemCount > 0) { if (otherContactsSection.itemCount > 0) {

@ -450,7 +450,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (result == nil) { if (result == nil) {
OWSFail(@"%@ Unable to build thumnail for attachmentId: %@", self.logTag, self.uniqueId); DDLogError(@"%@ Unable to build thumbnail for attachmentId: %@", self.logTag, self.uniqueId);
return; return;
} }

Loading…
Cancel
Save