Clean up ahead of PR.

pull/1/head
Matthew Chen 6 years ago
parent 7a9acce504
commit fd93bf677e

@ -338,26 +338,8 @@ typedef enum : NSUInteger {
OWSAssertIsOnMainThread();
[self ensureDynamicInteractions];
// [self tryToShowContactShareUI];
}
//- (void)tryToShowContactShareUI
//{
// OWSAssertIsOnMainThread();
//
// Contact *_Nullable firstContact = self.contactsManager.allContacts.firstObject;
// DDLogInfo(@"%@ firstContact: %@ %d", self.logTag, firstContact, firstContact.cnContact != nil);
// [DDLog flushLog];
// if (!firstContact.cnContact) {
// return;
// }
// static dispatch_once_t onceToken;
// dispatch_once(&onceToken, ^{
// [self contactsPicker:nil didSelectContact:firstContact];
// });
//}
- (void)otherUsersProfileDidChange:(NSNotification *)notification
{
OWSAssertIsOnMainThread();
@ -508,11 +490,6 @@ typedef enum : NSUInteger {
[self addNotificationListeners];
[self loadDraftInCompose];
dispatch_async(dispatch_get_main_queue(), ^{
[self showPhonyContactShareApproval];
// [self tryToShowContactShareUI];
});
}
- (void)loadView
@ -4948,79 +4925,6 @@ interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransiti
#pragma mark - ContactsPickerDelegate
- (void)showPhonyContactShareApproval
{
ApproveContactShareViewController *approveContactShare =
[[ApproveContactShareViewController alloc] initWithContactShare:self.makePhonyContact
contactsManager:self.contactsManager
delegate:self];
// contactsPicker.title
// = NSLocalizedString(@"CONTACT_PICKER_TITLE", @"navbar title for contact picker when sharing a contact");
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:approveContactShare];
[self dismissKeyBoard];
[self presentViewController:navigationController animated:YES completion:nil];
// [self contactsPicker:nil didSelectContact:self.makePhonyContact];
}
- (OWSContact *)makePhonyContact
{
OWSContact *contact = [OWSContact new];
contact.givenName = @"Alice";
contact.familyName = @"Carol";
contact.middleName = @"Bob";
contact.namePrefix = @"Ms.";
contact.nameSuffix = @"Esq.";
contact.organizationName = @"Falafel Hut";
OWSContactPhoneNumber *phoneNumber1 = [OWSContactPhoneNumber new];
phoneNumber1.phoneType = OWSContactPhoneType_Home;
phoneNumber1.phoneNumber = @"+13213214321";
OWSContactPhoneNumber *phoneNumber2 = [OWSContactPhoneNumber new];
phoneNumber2.phoneType = OWSContactPhoneType_Custom;
phoneNumber2.label = @"Carphone";
phoneNumber2.phoneNumber = @"+13332221111";
contact.phoneNumbers = @[
phoneNumber1,
phoneNumber2,
];
NSMutableArray<OWSContactEmail *> *emails = [NSMutableArray new];
for (NSUInteger i = 0; i < 16; i++) {
OWSContactEmail *email = [OWSContactEmail new];
email.emailType = OWSContactEmailType_Home;
email.email = [NSString stringWithFormat:@"a%zd@b.com", i];
[emails addObject:email];
}
contact.emails = emails;
OWSContactAddress *address1 = [OWSContactAddress new];
address1.addressType = OWSContactAddressType_Home;
address1.street = @"123 home st.";
address1.neighborhood = @"round the bend.";
address1.city = @"homeville";
address1.region = @"HO";
address1.postcode = @"12345";
address1.country = @"USA";
OWSContactAddress *address2 = [OWSContactAddress new];
address2.addressType = OWSContactAddressType_Custom;
address2.label = @"Otra casa";
address2.pobox = @"caja 123";
address2.street = @"123 casa calle";
address2.city = @"barrio norte";
address2.region = @"AB";
address2.postcode = @"53421";
address2.country = @"MX";
contact.addresses = @[
address1,
address2,
];
// TODO: Avatar
return contact;
}
- (void)contactsPickerDidCancel:(ContactsPicker *)contactsPicker
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
@ -5044,16 +4948,11 @@ interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransiti
return;
}
// TODO actually build contact message.
// self.inputToolbar.messageText = contact.fullName;
// TODO: We should probably show this in the same navigation view controller.
ApproveContactShareViewController *approveContactShare =
[[ApproveContactShareViewController alloc] initWithContactShare:contactShare
contactsManager:self.contactsManager
delegate:self];
// contactsPicker.title
// = NSLocalizedString(@"CONTACT_PICKER_TITLE", @"navbar title for contact picker when sharing a contact");
UINavigationController *navigationController =
[[UINavigationController alloc] initWithRootViewController:approveContactShare];

@ -54,9 +54,7 @@ class ContactSharePhoneNumber: ContactShareField {
assert(isIncluded())
var values = [OWSContactPhoneNumber]()
if let oldValues = contact.phoneNumbers {
values += oldValues
}
values += contact.phoneNumbers
values.append(value)
contact.phoneNumbers = values
}
@ -82,9 +80,7 @@ class ContactShareEmail: ContactShareField {
assert(isIncluded())
var values = [OWSContactEmail]()
if let oldValues = contact.emails {
values += oldValues
}
values += contact.emails
values.append(value)
contact.emails = values
}
@ -110,9 +106,7 @@ class ContactShareAddress: ContactShareField {
assert(isIncluded())
var values = [OWSContactAddress]()
if let oldValues = contact.addresses {
values += oldValues
}
values += contact.addresses
values.append(value)
contact.addresses = values
}
@ -237,37 +231,29 @@ public class ApproveContactShareViewController: OWSViewController, EditContactSh
// TODO: Avatar
if let phoneNumbers = contactShare.phoneNumbers {
for phoneNumber in phoneNumbers {
let field = ContactSharePhoneNumber(phoneNumber)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forPhoneNumber: phoneNumber)
})
fieldViews.append(fieldView)
}
for phoneNumber in contactShare.phoneNumbers {
let field = ContactSharePhoneNumber(phoneNumber)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forPhoneNumber: phoneNumber)
})
fieldViews.append(fieldView)
}
if let emails = contactShare.emails {
for email in emails {
let field = ContactShareEmail(email)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forEmail: email)
})
fieldViews.append(fieldView)
}
for email in contactShare.emails {
let field = ContactShareEmail(email)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forEmail: email)
})
fieldViews.append(fieldView)
}
if let addresses = contactShare.addresses {
for address in addresses {
let field = ContactShareAddress(address)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forAddress: address)
})
fieldViews.append(fieldView)
}
for address in contactShare.addresses {
let field = ContactShareAddress(address)
let fieldView = ContactShareFieldView(field: field, previewViewBlock: { [weak self] _ in
guard let strongSelf = self else { return UIView() }
return strongSelf.previewView(forAddress: address)
})
fieldViews.append(fieldView)
}
self.fieldViews = fieldViews
@ -467,7 +453,7 @@ public class ApproveContactShareViewController: OWSViewController, EditContactSh
func previewView(forPhoneNumber phoneNumber: OWSContactPhoneNumber) -> UIView {
let label = UILabel()
label.text = PhoneNumber.bestEffortFormatE164(asLocalizedPhoneNumber: phoneNumber.phoneNumber)
label.text = PhoneNumber.bestEffortLocalizedPhoneNumber(withE164: phoneNumber.phoneNumber)
label.font = UIFont.ows_dynamicTypeCaption1
label.textColor = UIColor.ows_materialBlue
label.lineBreakMode = .byTruncatingTail

Loading…
Cancel
Save