contacts reminder in compose view

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent bf5b6d1e63
commit 0b6962cdd0

@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) OWSTableViewController *tableViewController; @property (nonatomic, readonly) OWSTableViewController *tableViewController;
@property (nonatomic, readonly) UISearchBar *searchBar; @property (nonatomic, readonly) UISearchBar *searchBar;
@property (nonatomic, readonly) NSLayoutConstraint *hideContactsPermissionReminderViewConstraint;
// A list of possible phone numbers parsed from the search text as // A list of possible phone numbers parsed from the search text as
// E164 values. // E164 values.
@ -59,6 +60,18 @@ NS_ASSUME_NONNULL_BEGIN
_contactsViewHelper.delegate = self; _contactsViewHelper.delegate = self;
_nonContactAccountSet = [NSMutableSet set]; _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 = self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
target:self target:self
@ -87,7 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
_tableViewController.tableViewStyle = UITableViewStylePlain; _tableViewController.tableViewStyle = UITableViewStylePlain;
[self.view addSubview:self.tableViewController.view]; [self.view addSubview:self.tableViewController.view];
[_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinWidthToSuperview];
[_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeTop];
[_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:contactsPermissionReminderView];
[_tableViewController.view autoPinToBottomLayoutGuideOfViewController:self withInset:0]; [_tableViewController.view autoPinToBottomLayoutGuideOfViewController:self withInset:0];
_tableViewController.tableView.tableHeaderView = searchBar; _tableViewController.tableView.tableHeaderView = searchBar;
@ -101,6 +115,11 @@ NS_ASSUME_NONNULL_BEGIN
[self updateTableContents]; [self updateTableContents];
} }
- (void)showContactsPermissionReminder:(BOOL)flag
{
_hideContactsPermissionReminderViewConstraint.active = !flag;
}
- (UIView *)createNoSignalContactsView - (UIView *)createNoSignalContactsView
{ {
UIView *view = [UIView new]; UIView *view = [UIView new];
@ -357,6 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!hasSearchText && helper.signalAccounts.count < 1) { if (!hasSearchText && helper.signalAccounts.count < 1) {
// No Contacts // No Contacts
if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [section addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [UITableViewCell new];
cell.textLabel.text = NSLocalizedString( cell.textLabel.text = NSLocalizedString(
@ -370,6 +390,7 @@ NS_ASSUME_NONNULL_BEGIN
customRowHeight:kActionCellHeight customRowHeight:kActionCellHeight
actionBlock:nil]]; actionBlock:nil]];
} }
}
if (hasSearchText && !hasSearchResults) { if (hasSearchText && !hasSearchResults) {
// No Search Results // No Search Results
@ -420,12 +441,15 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showNoContactsModeIfNecessary - (void)showNoContactsModeIfNecessary
{ {
if (!self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) { if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) {
return;
}
BOOL hasNoContacts = self.contactsViewHelper.signalAccounts.count < 1; BOOL hasNoContacts = self.contactsViewHelper.signalAccounts.count < 1;
self.isNoContactsModeActive = (hasNoContacts && ![[Environment preferences] hasDeclinedNoContactsView]); 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];
}
} }
- (void)setIsNoContactsModeActive:(BOOL)isNoContactsModeActive - (void)setIsNoContactsModeActive:(BOOL)isNoContactsModeActive

@ -168,7 +168,8 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button"); @"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 = ^{ self.missingContactsPermissionView.tapAction = ^{
[[UIApplication sharedApplication] openSystemSettings]; [[UIApplication sharedApplication] openSystemSettings];
}; };

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

@ -217,6 +217,9 @@
/* Activity Sheet label */ /* Activity Sheet label */
"COMPARE_SAFETY_NUMBER_ACTION" = "Compare with Clipboard"; "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. */ /* 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."; "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 */ /* Call setup status label */
"IN_CALL_TERMINATED" = "Call Ended."; "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."; "INBOX_VIEW_MISSING_CONTACTS_PERMISSION" = "To see the names of your contacts, update your sytem settings to allow contact access.";
/* notification body */ /* notification body */

Loading…
Cancel
Save