From 972aabfe051e4d61d0d765a98b7d5ce8a13fbe5d Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Tue, 7 Apr 2020 18:17:22 +0200 Subject: [PATCH] fix ipad: add contact from HistoryDetailsView --- Classes/ContactDetailsView.h | 1 + Classes/ContactDetailsView.m | 67 ++++++++++++++++++--------------- Classes/ContactsListTableView.m | 4 ++ 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/Classes/ContactDetailsView.h b/Classes/ContactDetailsView.h index b5f1a2292..931445d0d 100644 --- a/Classes/ContactDetailsView.h +++ b/Classes/ContactDetailsView.h @@ -54,4 +54,5 @@ - (void)editContact:(Contact *)contact; - (void)editContact:(Contact *)contact address:(NSString *)address; - (void)setContact:(Contact *)contact; +- (void)resetContact; @end diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index c8897156d..7ff75b9a4 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -197,6 +197,39 @@ [self selectContact:acontact andReload:NO]; } +- (void)resetContact { + if (self.tmpContact) { + _contact.firstName = _tmpContact.firstName.copy; + _contact.lastName = _tmpContact.lastName.copy; + while (_contact.sipAddresses.count > 0) { + [_contact removeSipAddressAtIndex:0]; + } + NSInteger nbSipAd = 0; + while (_tmpContact.sipAddresses.count > nbSipAd) { + [_contact addSipAddress:_tmpContact.sipAddresses[nbSipAd]]; + nbSipAd++; + } + while (_contact.phones.count > 0) { + [_contact removePhoneNumberAtIndex:0]; + } + NSInteger nbPhone = 0; + while (_tmpContact.phones.count > nbPhone) { + [_contact addPhoneNumber:_tmpContact.phones[nbPhone]]; + nbPhone++; + } + while (_contact.emails.count > 0) { + [_contact removeEmailAtIndex:0]; + } + NSInteger nbEmail = 0; + while (_tmpContact.emails.count > nbEmail) { + [_contact addEmail:_tmpContact.emails[nbEmail]]; + nbEmail++; + } + self.tmpContact = NULL; + [self saveData]; + } +} + #pragma mark - ViewController Functions - (void)viewDidLoad { @@ -229,7 +262,8 @@ [ContactSelection getSelectionMode] != ContactSelectionModeNone); [_tableController.tableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL]; _tableController.waitView = _waitView; - self.tmpContact = NULL; + if (!IPAD) + self.tmpContact = NULL; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(deviceOrientationDidChange:) @@ -281,36 +315,7 @@ } [super viewWillDisappear:animated]; PhoneMainView.instance.currentName = NULL; - if (self.tmpContact) { - _contact.firstName = _tmpContact.firstName.copy; - _contact.lastName = _tmpContact.lastName.copy; - while (_contact.sipAddresses.count > 0) { - [_contact removeSipAddressAtIndex:0]; - } - NSInteger nbSipAd = 0; - while (_tmpContact.sipAddresses.count > nbSipAd) { - [_contact addSipAddress:_tmpContact.sipAddresses[nbSipAd]]; - nbSipAd++; - } - while (_contact.phones.count > 0) { - [_contact removePhoneNumberAtIndex:0]; - } - NSInteger nbPhone = 0; - while (_tmpContact.phones.count > nbPhone) { - [_contact addPhoneNumber:_tmpContact.phones[nbPhone]]; - nbPhone++; - } - while (_contact.emails.count > 0) { - [_contact removeEmailAtIndex:0]; - } - NSInteger nbEmail = 0; - while (_tmpContact.emails.count > nbEmail) { - [_contact addEmail:_tmpContact.emails[nbEmail]]; - nbEmail++; - } - self.tmpContact = NULL; - [self saveData]; - } + [self resetContact]; BOOL rm = TRUE; for (NSString *sip in _contact.sipAddresses) { diff --git a/Classes/ContactsListTableView.m b/Classes/ContactsListTableView.m index 905b91f93..b7c599d1d 100644 --- a/Classes/ContactsListTableView.m +++ b/Classes/ContactsListTableView.m @@ -398,6 +398,10 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) { if (([ContactSelection getSelectionMode] != ContactSelectionModeEdit) || !([ContactSelection getAddAddress])) { [view setContact:contact]; } else { + if (IPAD) { + [view resetContact]; + view.isAdding = FALSE; + } [view editContact:contact address:[ContactSelection getAddAddress]]; } }