From 8ea799e1f6fc93aca7bcb95a2034f3ee84c12b0d Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Tue, 8 Feb 2022 14:28:10 +0100 Subject: [PATCH] =?UTF-8?q?Fixes=20in=20the=20contact=20editing=20menu=20:?= =?UTF-8?q?=20no=20longer=20destroy=20the=20=E2=80=9Cbackup=E2=80=9D=20con?= =?UTF-8?q?tact=20when=20going=20into=20the=20ImagePickerView,=20and=20pro?= =?UTF-8?q?perly=20allow=20the=20=E2=80=9Ccancel=E2=80=9D=20of=20modificat?= =?UTF-8?q?ions=20after=20changing=20a=20contact=20avatar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/ContactDetailsView.h | 2 ++ Classes/ContactDetailsView.m | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Classes/ContactDetailsView.h b/Classes/ContactDetailsView.h index cc43758ad..e546c1bee 100644 --- a/Classes/ContactDetailsView.h +++ b/Classes/ContactDetailsView.h @@ -49,6 +49,8 @@ - (IBAction)onDeleteClick:(id)sender; - (IBAction)onAvatarClick:(id)sender; + +- (void)updateBackOrCancelButton; - (void)newContact; - (void)newContact:(NSString *)address; - (void)editContact:(Contact *)contact; diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 8036b7180..22a98fa24 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -232,6 +232,18 @@ #pragma mark - ViewController Functions +- (void)updateBackOrCancelButton { + if (self.tableController.isEditing) { + _backButton.hidden = TRUE; + _cancelButton.hidden = FALSE; + } else { + if (!IPAD) { + _backButton.hidden = FALSE; + } + _cancelButton.hidden = TRUE; + } +} + - (void)viewDidLoad { [super viewDidLoad]; @@ -262,7 +274,7 @@ [ContactSelection getSelectionMode] != ContactSelectionModeNone); [_tableController.tableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL]; _tableController.waitView = _waitView; - if (!IPAD) + if (!IPAD && !self.tableController.isEditing) self.tmpContact = NULL; [[NSNotificationCenter defaultCenter] addObserver: self @@ -282,6 +294,8 @@ } } [_editButton setImage:[UIImage imageNamed:@"valid_default.png"] forState:UIControlStateSelected]; + + [self updateBackOrCancelButton]; } - (void)deviceOrientationDidChange:(NSNotification*)notif { @@ -296,15 +310,7 @@ } } - if (self.tableController.isEditing) { - _backButton.hidden = TRUE; - _cancelButton.hidden = FALSE; - } else { - if (!IPAD) { - _backButton.hidden = FALSE; - } - _cancelButton.hidden = TRUE; - } + [self updateBackOrCancelButton]; [self recomputeTableViewSize:_editButton.hidden]; } @@ -315,7 +321,9 @@ } [super viewWillDisappear:animated]; PhoneMainView.instance.currentName = NULL; - [self resetContact]; + if (!_tableController.isEditing) { + [self resetContact]; + } BOOL rm = TRUE; for (NSString *sip in _contact.sipAddresses) { @@ -433,6 +441,9 @@ static UICompositeViewDescription *compositeDescription = nil; if (!_isAdding) { _contact.firstName = _tmpContact.firstName.copy; _contact.lastName = _tmpContact.lastName.copy; + _contact.avatar = _tmpContact.avatar.copy; + [_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES]; + while (_contact.sipAddresses.count > 0) { [_contact removeSipAddressAtIndex:0]; } @@ -503,7 +514,7 @@ static UICompositeViewDescription *compositeDescription = nil; } NSString* previous = [PhoneMainView.instance getPreviousViewName]; - if ([previous isEqualToString:@"ContactsListView"]) { + if ([previous isEqualToString:@"ContactsListView"] || [previous isEqualToString:@"ImagePickerView"]) { ContactsListView *view = VIEW(ContactsListView); [PhoneMainView.instance popToView:view.compositeViewDescription]; } else {