Merge branch 'charlesmchen/blocking9'
This commit is contained in:
commit
c597bacdca
|
@ -222,8 +222,8 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
|
|||
|
||||
UILabel *label = [UILabel new];
|
||||
label.text = text;
|
||||
label.font = [UIFont ows_boldFontWithSize:20.f];
|
||||
label.textColor = [UIColor colorWithWhite:0.2f alpha:1.f];
|
||||
label.font = [UIFont ows_mediumFontWithSize:20.f];
|
||||
label.textColor = [UIColor colorWithWhite:0.3f alpha:1.f];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[row addSubview:label];
|
||||
[label autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:20.f];
|
||||
|
@ -489,7 +489,7 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
|
|||
UITableViewCell *cell = [UITableViewCell new];
|
||||
cell.textLabel.text = NSLocalizedString(
|
||||
@"SETTINGS_BLOCK_LIST_NO_CONTACTS", @"A label that indicates the user has no Signal contacts.");
|
||||
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
|
||||
cell.textLabel.font = [UIFont ows_regularFontWithSize:15.f];
|
||||
cell.textLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
|
||||
cell.textLabel.textAlignment = NSTextAlignmentCenter;
|
||||
return cell;
|
||||
|
@ -519,6 +519,16 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
|
|||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.hasNoContacts) {
|
||||
// Don't let user select the "you have no contacts" cell.
|
||||
return nil;
|
||||
}
|
||||
|
||||
return indexPath;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
|
|
|
@ -96,12 +96,11 @@ typedef NS_ENUM(NSInteger, BlockListViewControllerSection) {
|
|||
}
|
||||
}
|
||||
|
||||
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
||||
- (nullable NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
|
||||
{
|
||||
switch (section) {
|
||||
case BlockListViewControllerSection_Add:
|
||||
return NSLocalizedString(
|
||||
@"SETTINGS_BLOCK_LIST_HEADER_TITLE", @"A header title for the block list table.");
|
||||
return NSLocalizedString(@"SETTINGS_BLOCK_LIST_FOOTER_TITLE", @"A footer title for the block list table.");
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
//
|
||||
|
||||
#import "MessageComposeTableViewController.h"
|
||||
|
||||
#import <MessageUI/MessageUI.h>
|
||||
|
||||
#import "BlockListUIUtils.h"
|
||||
#import "ContactTableViewCell.h"
|
||||
#import "ContactsUpdater.h"
|
||||
#import "Environment.h"
|
||||
|
@ -13,6 +11,7 @@
|
|||
#import "Signal-Swift.h"
|
||||
#import "UIColor+OWS.h"
|
||||
#import "UIUtil.h"
|
||||
#import <MessageUI/MessageUI.h>
|
||||
#import <SignalServiceKit/OWSBlockingManager.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
@ -536,6 +535,11 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
: MessageComposeTableViewControllerSection_Count);
|
||||
}
|
||||
|
||||
- (BOOL)hasNoContacts
|
||||
{
|
||||
return self.contacts.count == 0;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
// This logic will determine which one (if any) of the following special controls
|
||||
// should be shown. No more than one should be shown at a time.
|
||||
|
@ -566,6 +570,9 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
if (self.searchController.active) {
|
||||
return (NSInteger)[self.searchResults count];
|
||||
} else {
|
||||
if (self.hasNoContacts) {
|
||||
return 1;
|
||||
}
|
||||
return (NSInteger)[self.contacts count];
|
||||
}
|
||||
}
|
||||
|
@ -599,11 +606,24 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
return self.inviteCell;
|
||||
} else {
|
||||
OWSAssert(indexPath.section == MessageComposeTableViewControllerSectionContacts)
|
||||
|
||||
|
||||
if (!self.searchController.active && self.hasNoContacts)
|
||||
{
|
||||
UITableViewCell *cell = [UITableViewCell new];
|
||||
cell.textLabel.text = NSLocalizedString(
|
||||
@"SETTINGS_BLOCK_LIST_NO_CONTACTS", @"A label that indicates the user has no Signal contacts.");
|
||||
cell.textLabel.font = [UIFont ows_regularFontWithSize:15.f];
|
||||
cell.textLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
|
||||
cell.textLabel.textAlignment = NSTextAlignmentCenter;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ContactTableViewCell *cell = (ContactTableViewCell *)[tableView
|
||||
dequeueReusableCellWithIdentifier:MessageComposeTableViewControllerCellContact];
|
||||
|
||||
[cell configureWithContact:[self contactForIndexPath:indexPath] contactsManager:self.contactsManager];
|
||||
Contact *contact = [self contactForIndexPath:indexPath];
|
||||
cell.isBlocked = [self isContactBlocked:contact];
|
||||
[cell configureWithContact:contact contactsManager:self.contactsManager];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
@ -611,6 +631,17 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
|
||||
#pragma mark - Table View delegate
|
||||
|
||||
- (nullable NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == MessageComposeTableViewControllerSectionContacts && !self.searchController.active
|
||||
&& self.hasNoContacts) {
|
||||
// Don't let user select the "you have no contacts" cell.
|
||||
return nil;
|
||||
}
|
||||
|
||||
return indexPath;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
||||
if (indexPath.section == MessageComposeTableViewControllerSectionInviteNonContactConversation) {
|
||||
|
@ -654,11 +685,17 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
} else {
|
||||
OWSAssert(indexPath.section == MessageComposeTableViewControllerSectionContacts)
|
||||
|
||||
NSString *identifier = [[[self contactForIndexPath:indexPath] textSecureIdentifiers] firstObject];
|
||||
if (!self.searchController.active && self.hasNoContacts)
|
||||
{
|
||||
// TODO: We could do something here, like show the "invite contacts" UI.
|
||||
return;
|
||||
}
|
||||
|
||||
Contact *contact = [self contactForIndexPath:indexPath];
|
||||
NSString *contactIdentifier = [[contact textSecureIdentifiers] firstObject];
|
||||
[self dismissViewControllerAnimated:YES
|
||||
completion:^() {
|
||||
[Environment messageIdentifier:identifier withCompose:YES];
|
||||
[Environment messageIdentifier:contactIdentifier withCompose:YES];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
@ -683,13 +720,23 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (BOOL)isContactBlockedOrHidden:(Contact *)contact
|
||||
- (BOOL)isContactHidden:(Contact *)contact
|
||||
{
|
||||
if (contact.parsedPhoneNumbers.count < 1) {
|
||||
// Hide contacts without any valid phone numbers.
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isContactBlocked:(Contact *)contact
|
||||
{
|
||||
if (contact.parsedPhoneNumbers.count < 1) {
|
||||
// Hide contacts without any valid phone numbers.
|
||||
return NO;
|
||||
}
|
||||
|
||||
for (PhoneNumber *phoneNumber in contact.parsedPhoneNumbers) {
|
||||
if ([_blockedPhoneNumbers containsObject:phoneNumber.toE164]) {
|
||||
return YES;
|
||||
|
@ -703,7 +750,7 @@ NSString *const MessageComposeTableViewControllerCellContact = @"ContactTableVie
|
|||
{
|
||||
NSMutableArray<Contact *> *result = [NSMutableArray new];
|
||||
for (Contact *contact in self.contactsManager.signalContacts) {
|
||||
if (![self isContactBlockedOrHidden:contact]) {
|
||||
if (![self isContactHidden:contact]) {
|
||||
[result addObject:contact];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ typedef enum {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
|
||||
|
|
|
@ -75,13 +75,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
blockedLabel.textAlignment = NSTextAlignmentRight;
|
||||
blockedLabel.text
|
||||
= NSLocalizedString(@"CONTACT_BLOCKED_INDICATOR", @"An indicator that a contact has been blocked.");
|
||||
blockedLabel.font = [UIFont ows_mediumFontWithSize:self.nameLabel.font.pointSize];
|
||||
blockedLabel.textColor = [UIColor blackColor];
|
||||
[self addSubview:blockedLabel];
|
||||
blockedLabel.font = [UIFont ows_mediumFontWithSize:13.f];
|
||||
blockedLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
|
||||
[blockedLabel sizeToFit];
|
||||
[blockedLabel autoVCenterInSuperview];
|
||||
[blockedLabel autoPinEdgeToSuperviewMargin:ALEdgeRight];
|
||||
[blockedLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.textLabel];
|
||||
|
||||
self.accessoryView = blockedLabel;
|
||||
}
|
||||
|
|
|
@ -313,8 +313,8 @@
|
|||
/* Error mesage indicating that message send is disabled due to prekey update failures */
|
||||
"ERROR_DESCRIPTION_MESSAGE_SEND_DISABLED_PREKEY_UPDATE_FAILURES" = "Unable to send due to stale privacy data.";
|
||||
|
||||
/* Error mesage indicating that message send failed due to block list */
|
||||
"ERROR_DESCRIPTION_MESSAGE_SEND_FAILED_DUE_TO_BLOCK_LIST" = "Failed to send message because you have blocked the user.";
|
||||
/* Error mesage indicating that message send failed due to blocklist */
|
||||
"ERROR_DESCRIPTION_MESSAGE_SEND_FAILED_DUE_TO_BLOCKLIST" = "ERROR_DESCRIPTION_MESSAGE_SEND_FAILED_DUE_TO_BLOCKLIST";
|
||||
|
||||
/* 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.";
|
||||
|
@ -866,10 +866,10 @@
|
|||
"SETTINGS_ADVANCED_TITLE" = "Advanced";
|
||||
|
||||
/* A label for the 'add phone number' button in the block list table. */
|
||||
"SETTINGS_BLOCK_LIST_ADD_BUTTON" = "Add Phone Number";
|
||||
"SETTINGS_BLOCK_LIST_ADD_BUTTON" = "Add…";
|
||||
|
||||
/* A header title for the block list table. */
|
||||
"SETTINGS_BLOCK_LIST_HEADER_TITLE" = "Blocked Phone Numbers";
|
||||
/* A footer title for the block list table. */
|
||||
"SETTINGS_BLOCK_LIST_FOOTER_TITLE" = "Blocked users will not be able to call you or send you messages.";
|
||||
|
||||
/* A label that indicates the user has no Signal contacts. */
|
||||
"SETTINGS_BLOCK_LIST_NO_CONTACTS" = "You have no contacts on Signal.";
|
||||
|
|
Loading…
Reference in New Issue