contacts reminder in compose view

// FREEBIE
This commit is contained in:
Michael Kirk 2017-05-05 18:05:14 -04:00
parent bf5b6d1e63
commit 0b6962cdd0
4 changed files with 49 additions and 20 deletions

View File

@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) OWSTableViewController *tableViewController;
@property (nonatomic, readonly) UISearchBar *searchBar;
@property (nonatomic, readonly) NSLayoutConstraint *hideContactsPermissionReminderViewConstraint;
// A list of possible phone numbers parsed from the search text as
// E164 values.
@ -59,6 +60,18 @@ NS_ASSUME_NONNULL_BEGIN
_contactsViewHelper.delegate = self;
_nonContactAccountSet = [NSMutableSet set];
ReminderView *contactsPermissionReminderView = [[ReminderView alloc]
initWithText:NSLocalizedString(@"COMPOSE_SCREEN_MISSING_CONTACTS_PERMISSION",
@"Multiline label explaining why compose-screen contact picker is empty.")
tapAction:^{
[[UIApplication sharedApplication] openSystemSettings];
}];
[self.view addSubview:contactsPermissionReminderView];
[contactsPermissionReminderView autoPinWidthToSuperview];
[contactsPermissionReminderView autoPinEdgeToSuperviewMargin:ALEdgeTop];
_hideContactsPermissionReminderViewConstraint =
[contactsPermissionReminderView autoSetDimension:ALDimensionHeight toSize:0];
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self
@ -87,7 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
_tableViewController.tableViewStyle = UITableViewStylePlain;
[self.view addSubview:self.tableViewController.view];
[_tableViewController.view autoPinWidthToSuperview];
[_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeTop];
[_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:contactsPermissionReminderView];
[_tableViewController.view autoPinToBottomLayoutGuideOfViewController:self withInset:0];
_tableViewController.tableView.tableHeaderView = searchBar;
@ -101,6 +115,11 @@ NS_ASSUME_NONNULL_BEGIN
[self updateTableContents];
}
- (void)showContactsPermissionReminder:(BOOL)flag
{
_hideContactsPermissionReminderViewConstraint.active = !flag;
}
- (UIView *)createNoSignalContactsView
{
UIView *view = [UIView new];
@ -357,18 +376,20 @@ NS_ASSUME_NONNULL_BEGIN
if (!hasSearchText && helper.signalAccounts.count < 1) {
// No Contacts
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
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;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
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;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
customRowHeight:kActionCellHeight
actionBlock:nil]];
}
customRowHeight:kActionCellHeight
actionBlock:nil]];
}
if (hasSearchText && !hasSearchResults) {
@ -420,12 +441,15 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showNoContactsModeIfNecessary
{
if (!self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) {
return;
if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) {
BOOL hasNoContacts = self.contactsViewHelper.signalAccounts.count < 1;
self.isNoContactsModeActive = (hasNoContacts && ![[Environment preferences] hasDeclinedNoContactsView]);
[self showContactsPermissionReminder:NO];
} else {
// don't show "no signal contacts", show "no contact access"
self.isNoContactsModeActive = NO;
[self showContactsPermissionReminder:YES];
}
BOOL hasNoContacts = self.contactsViewHelper.signalAccounts.count < 1;
self.isNoContactsModeActive = (hasNoContacts && ![[Environment preferences] hasDeclinedNoContactsView]);
}
- (void)setIsNoContactsModeActive:(BOOL)isNoContactsModeActive

View File

@ -168,7 +168,8 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button");
self.missingContactsPermissionView.text = NSLocalizedString(@"INBOX_VIEW_MISSING_CONTACTS_PERMISSION", @"Multi line label explainging how to show names instead of phone numbers in your inbox");
self.missingContactsPermissionView.text = NSLocalizedString(@"INBOX_VIEW_MISSING_CONTACTS_PERMISSION",
@"Multiline label explaining how to show names instead of phone numbers in your inbox");
self.missingContactsPermissionView.tapAction = ^{
[[UIApplication sharedApplication] openSystemSettings];
};

View File

@ -41,8 +41,9 @@ class ReminderView: UIView {
setupSubviews()
}
convenience init(tapAction: @escaping () -> Void) {
convenience init(text: String, tapAction: @escaping () -> Void) {
self.init(frame: .zero)
self.text = text
self.tapAction = tapAction
}

View File

@ -217,6 +217,9 @@
/* Activity Sheet label */
"COMPARE_SAFETY_NUMBER_ACTION" = "Compare with Clipboard";
/* Multiline label explaining why compose-screen contact picker is empty. */
"COMPOSE_SCREEN_MISSING_CONTACTS_PERMISSION" = "To see which of your contacts are Signal users, enable contacts access in your system settings.";
/* No comment provided by engineer. */
"CONFIRM_ACCOUNT_DESTRUCTION_TEXT" = "This will reset the application by deleting your messages and unregister you with the server. The app will close after deletion of data.";
@ -562,7 +565,7 @@
/* Call setup status label */
"IN_CALL_TERMINATED" = "Call Ended.";
/* Multi line label explainging how to show names instead of phone numbers in your inbox */
/* Multiline label explaining how to show names instead of phone numbers in your inbox */
"INBOX_VIEW_MISSING_CONTACTS_PERMISSION" = "To see the names of your contacts, update your sytem settings to allow contact access.";
/* notification body */