Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent f71ec9f7cb
commit 26f69b0063

@ -3074,7 +3074,15 @@ typedef enum : NSUInteger {
- (void)popAllConversationSettingsViews
{
if (self.presentedViewController) {
[self.presentedViewController
dismissViewControllerAnimated:YES
completion:^{
[self.navigationController popToViewController:self animated:YES];
}];
} else {
[self.navigationController popToViewController:self animated:YES];
}
}
#pragma mark - Class methods

@ -10,9 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) id<OWSConversationSettingsViewDelegate> delegate;
@property (nonatomic) BOOL shouldEditGroupNameOnAppear;
@property (nonatomic) BOOL shouldEditAvatarOnAppear;
@end
NS_ASSUME_NONNULL_END

@ -8,7 +8,6 @@
#import "ContactsViewHelper.h"
#import "Environment.h"
#import "GroupViewHelper.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSContactsManager.h"
#import "OWSTableViewController.h"
#import "SecurityUtils.h"
@ -45,6 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSMutableSet<NSString *> *memberRecipientIds;
@property (nonatomic) BOOL hasUnsavedChanges;
@property (nonatomic) BOOL hasAppeared;
@end
@ -93,13 +93,12 @@ NS_ASSUME_NONNULL_BEGIN
{
[super loadView];
self.title = NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"The title for the 'new group' view.");
self.title = NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"The navbar title for the 'new group' view.");
self.navigationItem.leftBarButtonItem =
[self createOWSBackButtonWithTarget:self selector:@selector(backButtonPressed:)];
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"add-conversation"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:NSLocalizedString(@"NEW_GROUP_CREATE_BUTTON", @"The title for the 'create group' button.")
style:UIBarButtonItemStylePlain
target:self
action:@selector(createGroup)];
@ -152,7 +151,8 @@ NS_ASSUME_NONNULL_BEGIN
_groupNameTextField = groupNameTextField;
groupNameTextField.textColor = [UIColor blackColor];
groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font];
groupNameTextField.placeholder = NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"");
groupNameTextField.placeholder
= NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"Placeholder text for group name field");
groupNameTextField.delegate = self;
[groupNameTextField addTarget:self
action:@selector(groupNameDidChange:)
@ -162,8 +162,8 @@ NS_ASSUME_NONNULL_BEGIN
[groupNameTextField autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:avatarView withOffset:16.f];
[groupNameTextField autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16.f];
[avatarView addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc] initWithTarget:self
action:@selector(avatarTouched:)]];
[avatarView
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTouched:)]];
avatarView.userInteractionEnabled = YES;
return firstSectionHeader;
@ -315,8 +315,8 @@ NS_ASSUME_NONNULL_BEGIN
__weak NewGroupViewController *weakSelf = self;
return [OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.textLabel.text = NSLocalizedString(
@"NEW_GROUP_ADD_NON_CONTACT", @"A label the cell that lets you add a new non-contact member to a group.");
cell.textLabel.text = NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT",
@"A label for the cell that lets you add a new non-contact member to a group.");
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
@ -361,13 +361,10 @@ NS_ASSUME_NONNULL_BEGIN
{
[super viewDidAppear:animated];
if (self.shouldEditGroupNameOnAppear) {
if (!self.hasAppeared) {
[self.groupNameTextField becomeFirstResponder];
} else if (self.shouldEditAvatarOnAppear) {
[self showChangeGroupAvatarUI];
self.hasAppeared = YES;
}
self.shouldEditGroupNameOnAppear = NO;
self.shouldEditAvatarOnAppear = NO;
}
#pragma mark - Actions

@ -6,7 +6,6 @@
#import "BlockListUIUtils.h"
#import "Environment.h"
#import "FingerprintViewController.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSAvatarBuilder.h"
#import "OWSBlockingManager.h"
#import "OWSContactsManager.h"
@ -529,7 +528,7 @@ NS_ASSUME_NONNULL_BEGIN
}
[firstSectionHeader
addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc] initWithTarget:self
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(conversationNameTouched:)]];
firstSectionHeader.userInteractionEnabled = YES;

@ -7,7 +7,6 @@
#import "ContactsViewHelper.h"
#import "CountryCodeViewController.h"
#import "Environment.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSContactsManager.h"
#import "OWSTableViewController.h"
#import "PhoneNumber.h"

@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
@class Contact;
@class SignalRecipient;
@class YapDatabaseReadTransaction;
// This class represents a single valid Signal account.
//
@ -32,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
// For contacts with more than one signal account,
// this is a label for the account.
@property (nonatomic) NSString *multipleAccountLabel;
@property (nonatomic) NSString *multipleAccountLabelText;
- (instancetype)init NS_UNAVAILABLE;
@ -41,11 +42,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithRecipientId:(NSString *)recipientId;
// In most cases this should be non-null. This should only
// be non-null in the case where the SignalRecipient was
// be null in the case where the SignalRecipient was
// deleted before this property was accessed.
//
// NOTE: This may create a database transaction.
- (nullable SignalRecipient *)signalRecipient;
- (nullable SignalRecipient *)signalRecipientWithTransaction:(YapDatabaseReadTransaction *)transaction;
@end

@ -10,10 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface SignalAccount ()
@property (nonatomic, nullable) SignalRecipient *signalRecipient;
// This property may be modified after construction, so it should
// only be modified on the main thread.
@property (nonatomic) NSString *recipientId;
@end
@ -27,7 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
if (self = [super init]) {
OWSAssert(signalRecipient);
_signalRecipient = signalRecipient;
_recipientId = signalRecipient.uniqueId;
}
return self;
@ -43,18 +38,12 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (nullable SignalRecipient *)signalRecipient
- (nullable SignalRecipient *)signalRecipientWithTransaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert([NSThread isMainThread]);
OWSAssert(transaction);
if (!_signalRecipient) {
[[TSStorageManager sharedManager].dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
_signalRecipient =
[SignalRecipient recipientWithTextSecureIdentifier:self.recipientId withTransaction:transaction];
}];
}
return _signalRecipient;
return [SignalRecipient recipientWithTextSecureIdentifier:self.recipientId withTransaction:transaction];
}
@end

@ -9,7 +9,6 @@
#import "ContactsViewHelper.h"
#import "Environment.h"
#import "GroupViewHelper.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSContactsManager.h"
#import "OWSTableViewController.h"
#import "SecurityUtils.h"
@ -103,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.memberRecipientIds addObjectsFromArray:self.thread.groupModel.groupMemberIds];
self.previousMemberRecipientIds = [NSSet setWithArray:self.thread.groupModel.groupMemberIds];
self.title = NSLocalizedString(@"EDIT_GROUP_DEFAULT_TITLE", @"The default title for the 'update group' view.");
self.title = NSLocalizedString(@"EDIT_GROUP_DEFAULT_TITLE", @"The navbar title for the 'update group' view.");
self.navigationItem.leftBarButtonItem =
[self createOWSBackButtonWithTarget:self selector:@selector(backButtonPressed:)];
@ -132,6 +131,24 @@ NS_ASSUME_NONNULL_BEGIN
[self.navigationController.navigationBar setTranslucent:NO];
}
- (void)setHasUnsavedChanges:(BOOL)hasUnsavedChanges
{
_hasUnsavedChanges = hasUnsavedChanges;
[self updateNavigationBar];
}
- (void)updateNavigationBar
{
self.navigationItem.rightBarButtonItem = (self.hasUnsavedChanges
? [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"EDIT_GROUP_UPDATE_BUTTON",
@"The title for the 'update group' button.")
style:UIBarButtonItemStylePlain
target:self
action:@selector(updateGroupPressed)]
: nil);
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
@ -183,7 +200,8 @@ NS_ASSUME_NONNULL_BEGIN
}
groupNameTextField.textColor = [UIColor blackColor];
groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font];
groupNameTextField.placeholder = NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"");
groupNameTextField.placeholder
= NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"Placeholder text for group name field");
groupNameTextField.delegate = self;
[groupNameTextField addTarget:self
action:@selector(groupNameDidChange:)
@ -193,8 +211,8 @@ NS_ASSUME_NONNULL_BEGIN
[groupNameTextField autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:avatarView withOffset:16.f];
[groupNameTextField autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:16.f];
[avatarView addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc] initWithTarget:self
action:@selector(avatarTouched:)]];
[avatarView
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTouched:)]];
avatarView.userInteractionEnabled = YES;
return firstSectionHeader;
@ -227,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.textLabel.text = NSLocalizedString(
@"EDIT_GROUP_MEMBERS_ADD_MEMBER", @"A label the cell that lets you add a new member to a group.");
@"EDIT_GROUP_MEMBERS_ADD_MEMBER", @"Label for the cell that lets you add a new member to a group.");
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
@ -431,6 +449,14 @@ NS_ASSUME_NONNULL_BEGIN
[self presentViewController:controller animated:YES completion:nil];
}
- (void)updateGroupPressed
{
OWSAssert(self.conversationSettingsViewDelegate);
[self updateGroup];
[self.conversationSettingsViewDelegate popAllConversationSettingsViews];
}
- (void)groupNameDidChange:(id)sender
{

@ -29,7 +29,7 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification;
@property (atomic, readonly) NSDictionary<NSString *, SignalAccount *> *signalAccountMap;
@property (atomic, readonly) NSArray<SignalAccount *> *signalAccounts;
- (nullable SignalAccount *)signalAccountForRecipientId:(nullable NSString *)recipientId;
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId;
- (Contact *)getOrBuildContactForPhoneIdentifier:(NSString *)identifier;
@ -42,10 +42,9 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification;
- (NSString *)displayNameForPhoneIdentifier:(nullable NSString *)identifier;
- (NSString *)displayNameForContact:(Contact *)contact;
- (NSString *_Nonnull)displayNameForSignalAccount:(SignalAccount *)signalAccount;
- (NSString *)displayNameForSignalAccount:(SignalAccount *)signalAccount;
- (nullable UIImage *)imageForPhoneIdentifier:(nullable NSString *)identifier;
- (NSAttributedString *_Nonnull)formattedDisplayNameForSignalAccount:(SignalAccount *)signalAccount
font:(UIFont *_Nonnull)font;
- (NSAttributedString *)formattedDisplayNameForSignalAccount:(SignalAccount *)signalAccount font:(UIFont *_Nonnull)font;
- (NSAttributedString *)formattedFullNameForContact:(Contact *)contact font:(UIFont *)font;
- (NSAttributedString *)formattedFullNameForRecipientId:(NSString *)recipientId font:(UIFont *)font;

@ -82,7 +82,6 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
- (void)handleAddressBookChanged
{
[self.avatarCache removeAllObjects];
[self pullLatestAddressBook];
}
@ -193,6 +192,8 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
self.allContacts = contacts;
self.allContactsMap = [allContactsMap copy];
[self.avatarCache removeAllObjects];
[self intersectContacts];
[self updateSignalAccounts];
@ -215,7 +216,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
signalAccount.contact = contact;
if (signalRecipients.count > 1) {
signalAccount.hasMultipleAccountContact = YES;
signalAccount.multipleAccountLabel =
signalAccount.multipleAccountLabelText =
[[self class] accountLabelForContact:contact recipientId:signalRecipient.recipientId];
}
if (signalAccountMap[signalAccount.recipientId]) {
@ -277,7 +278,8 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_PAGER", @"Label for 'Pager' phone numbers.");
break;
case OWSPhoneNumberTypeUnknown:
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_UNKNOWN", @"Label for 'Unknown' phone numbers.");
phoneNumberLabel = NSLocalizedString(@"PHONE_NUMBER_TYPE_UNKNOWN",
@"Label used when we don't what kind of phone number it is (e.g. mobile/work/home).");
break;
}
@ -562,9 +564,9 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
NSString *baseName = (signalAccount.contact ? [self displayNameForContact:signalAccount.contact]
: [self displayNameForPhoneIdentifier:signalAccount.recipientId]);
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
if (signalAccount.multipleAccountLabel) {
return [NSString stringWithFormat:@"%@ (%@)", baseName, signalAccount.multipleAccountLabel];
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabelText != nil));
if (signalAccount.multipleAccountLabelText) {
return [NSString stringWithFormat:@"%@ (%@)", baseName, signalAccount.multipleAccountLabelText];
} else {
return baseName;
}
@ -577,15 +579,16 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
OWSAssert(font);
NSAttributedString *baseName = [self formattedFullNameForContact:signalAccount.contact font:font];
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
if (signalAccount.multipleAccountLabel) {
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabelText != nil));
if (signalAccount.multipleAccountLabelText) {
NSMutableAttributedString *result = [NSMutableAttributedString new];
[result appendAttributedString:baseName];
[result appendAttributedString:[[NSAttributedString alloc] initWithString:@" ("
attributes:@{
NSFontAttributeName : font,
}]];
[result appendAttributedString:[[NSAttributedString alloc] initWithString:signalAccount.multipleAccountLabel]];
[result
appendAttributedString:[[NSAttributedString alloc] initWithString:signalAccount.multipleAccountLabelText]];
[result appendAttributedString:[[NSAttributedString alloc] initWithString:@")"
attributes:@{
NSFontAttributeName : font,
@ -656,7 +659,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
attributes:normalFontAttributes];
}
- (nullable SignalAccount *)signalAccountForRecipientId:(nullable NSString *)recipientId
- (nullable SignalAccount *)signalAccountForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);

@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
SignalAccount *signalAccount = [contactsManager signalAccountForRecipientId:contactThread.contactIdentifier];
SignalAccount *signalAccount = contactsManager.signalAccountMap[contactThread.contactIdentifier];
if (signalAccount) {
// Only create block offers for non-contacts.
return;

@ -337,10 +337,10 @@
/* a title for the contacts section of the 'new/update group' view. */
"EDIT_GROUP_CONTACTS_SECTION_TITLE" = "Contacts";
/* The default title for the 'update group' view. */
/* The navbar title for the 'update group' view. */
"EDIT_GROUP_DEFAULT_TITLE" = "Edit Group";
/* A label 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. */
"EDIT_GROUP_MEMBERS_ADD_MEMBER" = "Add…";
/* a title for the members section of the 'new/update group' view. */
@ -349,14 +349,8 @@
/* An indicator that a user is a new member of the group. */
"EDIT_GROUP_NEW_MEMBER_LABEL" = "Added";
/* A format for the message of the alert confirming whether user wants to remove a user from a group. Embeds {{the user's name or phone number}}. */
"EDIT_GROUP_REMOVE_MEMBER_ALERT_MESSAGE_FORMAT" = "Would you like to remove %@ from this group?";
/* A title of the alert confirming whether user wants to remove a user from a group. */
"EDIT_GROUP_REMOVE_MEMBER_ALERT_TITLE" = "Remove Group Member?";
/* A title of the button that confirms user wants to remove a user from a group. */
"EDIT_GROUP_REMOVE_MEMBER_BUTTON" = "Remove";
/* The title for the 'update group' button. */
"EDIT_GROUP_UPDATE_BUTTON" = "Update";
/* The alert message if user tries to exit update group view without saving changes. */
"EDIT_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE" = "You've changed this group. Would you like to save these changes?";
@ -753,19 +747,22 @@
/* Text for button to start a new conversation with a non-contact */
"NEW_CONVERSATION_FOR_NON_CONTACT_FORMAT" = "New conversation with %@";
/* A label 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. */
"NEW_GROUP_ADD_NON_CONTACT" = "Add by phone number…";
/* Action Sheet title prompting the user for a group avatar */
"NEW_GROUP_ADD_PHOTO_ACTION" = "Set Group Photo";
/* The title for the 'new group' view. */
/* The title for the 'create group' button. */
"NEW_GROUP_CREATE_BUTTON" = "Create";
/* The navbar title for the 'new group' view. */
"NEW_GROUP_DEFAULT_TITLE" = "New Group";
/* An indicator that a user is a member of the new group. */
"NEW_GROUP_MEMBER_LABEL" = "Member";
/* No comment provided by engineer. */
/* Placeholder text for group name field */
"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT" = "Name this group chat";
/* a title for the non-contacts section of the 'new group' view. */
@ -853,7 +850,7 @@
/* Label for 'Pager' phone numbers. */
"PHONE_NUMBER_TYPE_PAGER" = "Pager";
/* Label for 'Unknown' phone numbers. */
/* Label used when we don't what kind of phone number it is (e.g. mobile/work/home). */
"PHONE_NUMBER_TYPE_UNKNOWN" = "Unknown";
/* Label for 'Work FAX' phone numbers. */

Loading…
Cancel
Save