diff --git a/Classes/Base.lproj/HistoryListView.xib b/Classes/Base.lproj/HistoryListView.xib index 84392e4bf..6c802f30d 100644 --- a/Classes/Base.lproj/HistoryListView.xib +++ b/Classes/Base.lproj/HistoryListView.xib @@ -8,8 +8,6 @@ - - @@ -32,25 +30,12 @@ - - + - + + + @@ -110,25 +137,32 @@ + + + + + + + diff --git a/Classes/DialerView.m b/Classes/DialerView.m index dc4a95e1b..a419cde3d 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -397,7 +397,6 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions - (IBAction)onAddContactClick:(id)event { - [ContactSelection setSelectionMode:ContactSelectionModeEdit]; [ContactSelection setAddAddress:[addressField text]]; [ContactSelection setSipFilter:nil]; [ContactSelection setNameOrEmailFilter:nil]; diff --git a/Classes/HistoryListView.h b/Classes/HistoryListView.h index b40e370b0..aa70c8daf 100644 --- a/Classes/HistoryListView.h +++ b/Classes/HistoryListView.h @@ -30,12 +30,11 @@ @property(nonatomic, strong) IBOutlet UIButton *allButton; @property(nonatomic, strong) IBOutlet UIButton *missedButton; -@property(nonatomic, strong) IBOutlet UIToggleButton *editButton; -@property(nonatomic, strong) IBOutlet UIButton *deleteButton; - (IBAction)onAllClick:(id)event; - (IBAction)onMissedClick:(id)event; -- (IBAction)onEditClick:(id)event; - (IBAction)onDeleteClick:(id)event; +- (IBAction)onEditClick:(id)sender; +- (IBAction)onCancelClick:(id)sender; @end diff --git a/Classes/HistoryListView.m b/Classes/HistoryListView.m index a950a36b5..aaac0d49e 100644 --- a/Classes/HistoryListView.m +++ b/Classes/HistoryListView.m @@ -58,9 +58,8 @@ static UICompositeViewDescription *compositeDescription = nil; if ([_tableController isEditing]) { [_tableController setEditing:FALSE animated:FALSE]; } - [_deleteButton setHidden:TRUE]; - [_editButton setOff]; [self changeView:History_All]; + [self updateTopBar]; // Reset missed call linphone_core_reset_missed_calls_count([LinphoneManager getLc]); @@ -68,26 +67,8 @@ static UICompositeViewDescription *compositeDescription = nil; [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self]; } -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [self hideEditIfNeeded]; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - [self changeView:History_All]; -} - #pragma mark - -- (void)hideEditIfNeeded { - _editButton.hidden = ([_tableController tableView:_tableController.tableView numberOfRowsInSection:0] == 0); - if ([_editButton isSelected]) { - [_editButton toggle]; - [self onEditClick:nil]; - } -} - - (void)changeView:(HistoryView)view { if (view == History_All) { _allButton.selected = TRUE; @@ -102,7 +83,6 @@ static UICompositeViewDescription *compositeDescription = nil; } else { _missedButton.selected = FALSE; } - [self hideEditIfNeeded]; } #pragma mark - Action Functions @@ -115,9 +95,8 @@ static UICompositeViewDescription *compositeDescription = nil; [self changeView:History_Missed]; } -- (IBAction)onEditClick:(id)event { - [_tableController setEditing:!_tableController.isEditing animated:TRUE]; - _deleteButton.hidden = !_tableController.isEditing; +- (void)updateTopBar { + _allButton.hidden = _missedButton.hidden = self.tableController.isEditing; } - (IBAction)onDeleteClick:(id)event { @@ -125,12 +104,22 @@ static UICompositeViewDescription *compositeDescription = nil; [NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d history?", nil), _tableController.selectedItems.count]; [UIConfirmationDialog ShowWithMessage:msg - onCancelClick:nil - onConfirmationClick:^() { - [_tableController removeSelection]; - [_tableController loadData]; - [self hideEditIfNeeded]; - }]; + onCancelClick:^() { + [self updateTopBar]; + } + onConfirmationClick:^() { + [_tableController removeSelection]; + [_tableController loadData]; + [self updateTopBar]; + }]; +} + +- (IBAction)onEditClick:(id)sender { + [self updateTopBar]; +} + +- (IBAction)onCancelClick:(id)sender { + [self updateTopBar]; } @end diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index c17753366..95ab59bae 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -867,7 +867,7 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { // let the wizard handle its own errors - if ([PhoneMainView.instance currentView] != WizardViewController.compositeViewDescription) { + if ([PhoneMainView.instance currentView] != AssistantView.compositeViewDescription) { static DTAlertView *alertView = nil; // avoid having multiple popups @@ -900,7 +900,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char LOGE(@"Could not find auth info associated with %s@%s, going to settings!", username, domain); [[PhoneMainView instance] - changeCurrentView:[SettingsViewController compositeViewDescription]]; + changeCurrentView:SettingsView.compositeViewDescription]; } }]; [alertView show]; diff --git a/Classes/LinphoneUI/TabBarView.m b/Classes/LinphoneUI/TabBarView.m index c73635f7f..894372b76 100644 --- a/Classes/LinphoneUI/TabBarView.m +++ b/Classes/LinphoneUI/TabBarView.m @@ -240,7 +240,6 @@ static NSString *const kDisappearAnimation = @"disappear"; } - (IBAction)onContactsClick:(id)event { - [ContactSelection setSelectionMode:ContactSelectionModeNone]; [ContactSelection setAddAddress:nil]; [ContactSelection setSipFilter:nil]; [ContactSelection enableEmailFilter:FALSE]; diff --git a/Classes/LinphoneUI/UICheckBoxTVTableViewController.h b/Classes/LinphoneUI/UICheckBoxTVTableViewController.h index 07d9155a7..7a667158d 100644 --- a/Classes/LinphoneUI/UICheckBoxTVTableViewController.h +++ b/Classes/LinphoneUI/UICheckBoxTVTableViewController.h @@ -13,11 +13,15 @@ @property(nonatomic, readonly) NSMutableArray *selectedItems; @property(weak, nonatomic) IBOutlet UIButton *deleteButton; @property(weak, nonatomic) IBOutlet UIButton *editButton; +@property(weak, nonatomic) IBOutlet UIButton *cancelButton; +@property(weak, nonatomic) IBOutlet UIButton *toggleSelectionButton; - (void)loadData; - (void)accessoryForCell:(UITableViewCell *)cell atPath:(NSIndexPath *)indexPath; - (void)removeSelection; - (IBAction)onSelectionToggle:(id)sender; +- (IBAction)onEditClick:(id)sender; +- (IBAction)onCancelClick:(id)sender; @end diff --git a/Classes/LinphoneUI/UICheckBoxTVTableViewController.m b/Classes/LinphoneUI/UICheckBoxTVTableViewController.m index 3a1ed9df8..324a3587d 100644 --- a/Classes/LinphoneUI/UICheckBoxTVTableViewController.m +++ b/Classes/LinphoneUI/UICheckBoxTVTableViewController.m @@ -18,6 +18,7 @@ */ #import "UICheckBoxTVTableViewController.h" +#import "Utils.h" @implementation UICheckBoxTVTableViewController @@ -35,6 +36,11 @@ #pragma mark - UITableViewDelegate Functions +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + _editButton.enabled = [self tableView:self.tableView numberOfRowsInSection:0] != 0; +} + - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:NO]; @@ -76,11 +82,15 @@ cell.accessoryType = UITableViewCellAccessoryNone; } _deleteButton.enabled = (_selectedItems.count != 0); + _editButton.enabled = [self tableView:self.tableView numberOfRowsInSection:0] != 0; } - (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; + _editButton.hidden = editing; + _deleteButton.hidden = _cancelButton.hidden = _toggleSelectionButton.hidden = !editing; + // when switching editing mode, we must reload all cells to remove/add checkboxes [self loadData]; } @@ -104,10 +114,25 @@ } - (void)onSelectionToggle:(id)sender { - if (_selectedItems.count == 0) { - [self table] - } else { + [_selectedItems removeAllObjects]; + UIButton *button = (UIButton *)sender; + for (int i = 0; i < [self numberOfSectionsInTableView:self.tableView]; i++) { + for (int j = 0; j < [self tableView:self.tableView numberOfRowsInSection:i]; j++) { + NSIndexPath *idx = [NSIndexPath indexPathForRow:j inSection:i]; + UITableViewCell *cell = [self tableView:self.tableView cellForRowAtIndexPath:idx]; + cell.accessoryType = (button.state == UIControlStateSelected) ? UITableViewRowAnimationNone + : UITableViewCellAccessoryCheckmark; + [self accessoryForCell:cell atPath:idx]; + } } } +- (IBAction)onEditClick:(id)sender { + [self setEditing:YES animated:YES]; +} + +- (IBAction)onCancelClick:(id)sender { + [self setEditing:NO animated:YES]; +} + @end