From bacaabac609292b29a94ce25e9dcb9e872f37e69 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 30 Sep 2015 11:01:19 +0200 Subject: [PATCH] history list rm --- Classes/ContactsListView.m | 5 - Classes/HistoryListTableView.h | 4 +- Classes/HistoryListTableView.m | 18 +- Classes/HistoryListView.m | 15 +- .../UICheckBoxTVTableViewController.h | 1 + .../UICheckBoxTVTableViewController.m | 21 + Classes/LinphoneUI/ar.lproj/UICallCell.xib | 480 ------------------ .../ar.lproj/HistoryDetailsViewController.xib | 266 ---------- 8 files changed, 43 insertions(+), 767 deletions(-) delete mode 100644 Classes/LinphoneUI/ar.lproj/UICallCell.xib delete mode 100644 Classes/ar.lproj/HistoryDetailsViewController.xib diff --git a/Classes/ContactsListView.m b/Classes/ContactsListView.m index 839e08018..6c9cee329 100644 --- a/Classes/ContactsListView.m +++ b/Classes/ContactsListView.m @@ -136,11 +136,6 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - // cannot change search bar icon nor text font from the interface builder... - // [_searchBar setImage:[UIImage imageNamed:@"contact_search.png" ] forSearchBarIcon:UISearchBarIconSearch - // state:UIControlStateNormal]; - // UITextField *searchText = [_searchBar valueForKey:@"_searchField"]; - // [searchText setFont:[UIFont fontWithName:@"CustomFont" size:12]]; _searchBar.showsCancelButton = (_searchBar.text.length > 0); CGRect frame = _searchBar.frame; frame.origin.y = topBar.frame.origin.y + topBar.frame.size.height; diff --git a/Classes/HistoryListTableView.h b/Classes/HistoryListTableView.h index 76107e3d1..230fcb15c 100644 --- a/Classes/HistoryListTableView.h +++ b/Classes/HistoryListTableView.h @@ -22,11 +22,11 @@ #import "UICheckBoxTVTableViewController.h" @interface HistoryListTableView : UICheckBoxTVTableViewController { - @private - NSMutableArray *callLogs; } + - (void)loadData; +@property(nonatomic, readonly) NSMutableArray *callLogs; @property(nonatomic, assign) BOOL missedFilter; @end diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m index bcb6662fa..7a1c193c1 100644 --- a/Classes/HistoryListTableView.m +++ b/Classes/HistoryListTableView.m @@ -31,7 +31,7 @@ #pragma mark - Lifecycle Functions - (void)initHistoryTableViewController { - callLogs = [[NSMutableArray alloc] init]; + _callLogs = [[NSMutableArray alloc] init]; missedFilter = false; } @@ -95,16 +95,16 @@ #pragma mark - UITableViewDataSource Functions - (void)loadData { - [callLogs removeAllObjects]; + [_callLogs removeAllObjects]; const MSList *logs = linphone_core_get_call_logs([LinphoneManager getLc]); while (logs != NULL) { LinphoneCallLog *log = (LinphoneCallLog *)logs->data; if (missedFilter) { if (linphone_call_log_get_status(log) == LinphoneCallMissed) { - [callLogs addObject:[NSValue valueWithPointer:log]]; + [_callLogs addObject:[NSValue valueWithPointer:log]]; } } else { - [callLogs addObject:[NSValue valueWithPointer:log]]; + [_callLogs addObject:[NSValue valueWithPointer:log]]; } logs = ms_list_next(logs); } @@ -116,7 +116,7 @@ } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return [callLogs count]; + return [_callLogs count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -126,7 +126,7 @@ cell = [[UIHistoryCell alloc] initWithIdentifier:kCellId]; } - id logId = [callLogs objectAtIndex:indexPath.row]; + id logId = [_callLogs objectAtIndex:indexPath.row]; LinphoneCallLog *log = [logId pointerValue]; [cell setCallLog:log]; [super accessoryForCell:cell atPath:indexPath]; @@ -138,7 +138,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [super tableView:tableView didSelectRowAtIndexPath:indexPath]; if ([self isEditing]) { - LinphoneCallLog *callLog = [[callLogs objectAtIndex:[indexPath row]] pointerValue]; + LinphoneCallLog *callLog = [[_callLogs objectAtIndex:[indexPath row]] pointerValue]; if (callLog != NULL && linphone_call_log_get_call_id(callLog) != NULL) { LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); char *uri = linphone_address_as_string(addr); @@ -164,9 +164,9 @@ forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { [tableView beginUpdates]; - LinphoneCallLog *callLog = [[callLogs objectAtIndex:[indexPath row]] pointerValue]; + LinphoneCallLog *callLog = [[_callLogs objectAtIndex:[indexPath row]] pointerValue]; linphone_core_remove_call_log([LinphoneManager getLc], callLog); - [callLogs removeObjectAtIndex:[indexPath row]]; + [_callLogs removeObjectAtIndex:[indexPath row]]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView endUpdates]; diff --git a/Classes/HistoryListView.m b/Classes/HistoryListView.m index 5b08504a2..32a8c6811 100644 --- a/Classes/HistoryListView.m +++ b/Classes/HistoryListView.m @@ -128,11 +128,16 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onDeleteClick:(id)event { - for (id log in tableController.selectedItems) { - linphone_core_remove_call_log([LinphoneManager getLc], (LinphoneCallLog *)[log pointerValue]); - } - [tableController loadData]; - [self hideEditIfNeeded]; + NSString *msg = + [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]; + }]; } @end diff --git a/Classes/LinphoneUI/UICheckBoxTVTableViewController.h b/Classes/LinphoneUI/UICheckBoxTVTableViewController.h index f9f0544b0..7fec2f82d 100644 --- a/Classes/LinphoneUI/UICheckBoxTVTableViewController.h +++ b/Classes/LinphoneUI/UICheckBoxTVTableViewController.h @@ -14,5 +14,6 @@ - (void)loadData; - (void)accessoryForCell:(UITableViewCell *)cell atPath:(NSIndexPath *)indexPath; +- (void)removeSelection; @end diff --git a/Classes/LinphoneUI/UICheckBoxTVTableViewController.m b/Classes/LinphoneUI/UICheckBoxTVTableViewController.m index e86c696ec..602f1a5e1 100644 --- a/Classes/LinphoneUI/UICheckBoxTVTableViewController.m +++ b/Classes/LinphoneUI/UICheckBoxTVTableViewController.m @@ -21,6 +21,12 @@ @implementation UICheckBoxTVTableViewController +- (instancetype)initWithCoder:(NSCoder *)aDecoder { + self = [super initWithCoder:aDecoder]; + _selectedItems = [[NSMutableArray alloc] init]; + return self; +} + - (instancetype)init { self = [super init]; _selectedItems = [[NSMutableArray alloc] init]; @@ -61,6 +67,8 @@ - (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; + + // when switching editing mode, we must reload all cells to remove/add checkboxes [self loadData]; } @@ -69,4 +77,17 @@ [self.tableView reloadData]; } +- (void)removeSelection { + // we must iterate through selected items in reverse order + [_selectedItems sortUsingComparator:^(NSIndexPath *obj1, NSIndexPath *obj2) { + return [obj1 compare:obj2]; + }]; + for (NSIndexPath *indexPath in _selectedItems) { + [self tableView:self.tableView + commitEditingStyle:UITableViewCellEditingStyleDelete + forRowAtIndexPath:indexPath]; + } + [_selectedItems removeAllObjects]; +} + @end diff --git a/Classes/LinphoneUI/ar.lproj/UICallCell.xib b/Classes/LinphoneUI/ar.lproj/UICallCell.xib deleted file mode 100644 index be7cfac55..000000000 --- a/Classes/LinphoneUI/ar.lproj/UICallCell.xib +++ /dev/null @@ -1,480 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Classes/ar.lproj/HistoryDetailsViewController.xib b/Classes/ar.lproj/HistoryDetailsViewController.xib deleted file mode 100644 index 11e9f2bb0..000000000 --- a/Classes/ar.lproj/HistoryDetailsViewController.xib +++ /dev/null @@ -1,266 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file