From 08f819e33232401d84179ad05c2a9f51190cea2f Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 29 Sep 2015 16:59:10 +0200 Subject: [PATCH] checkbox tv --- Classes/Base.lproj/HistoryListView.xib | 11 ++- Classes/ChatsListTableView.m | 5 -- Classes/ContactDetailsLabelView.m | 5 -- Classes/ContactDetailsTableView.m | 5 -- Classes/ContactsListTableView.m | 5 -- Classes/HistoryListTableView.h | 4 +- Classes/HistoryListTableView.m | 29 ++------ Classes/HistoryListView.m | 12 ++-- .../LinphoneUI/Base.lproj/UIHistoryCell.xib | 20 +++--- Classes/LinphoneUI/UICallPausedCell.h | 4 +- Classes/LinphoneUI/UIChatBubblePhotoCell.h | 3 +- Classes/LinphoneUI/UIChatBubbleTextCell.h | 3 +- Classes/LinphoneUI/UIChatCell.h | 3 +- Classes/LinphoneUI/UICheckBoxTVCell.h | 25 ------- Classes/LinphoneUI/UICheckBoxTVCell.m | 39 ---------- Classes/LinphoneUI/UICheckBoxTVCell.xib | 32 --------- .../UICheckBoxTVTableViewController.h | 18 +++++ .../UICheckBoxTVTableViewController.m | 72 +++++++++++++++++++ Classes/LinphoneUI/UIContactCell.h | 4 +- Classes/LinphoneUI/UIEditableTableViewCell.h | 4 +- Classes/LinphoneUI/UIHistoryCell.h | 8 +-- Classes/LinphoneUI/UIHistoryCell.m | 3 +- Classes/SettingsView.m | 10 --- Classes/Utils/Utils.h | 8 +-- linphone.xcodeproj/project.pbxproj | 18 ++--- 25 files changed, 141 insertions(+), 209 deletions(-) delete mode 100644 Classes/LinphoneUI/UICheckBoxTVCell.h delete mode 100644 Classes/LinphoneUI/UICheckBoxTVCell.m delete mode 100644 Classes/LinphoneUI/UICheckBoxTVCell.xib create mode 100644 Classes/LinphoneUI/UICheckBoxTVTableViewController.h create mode 100644 Classes/LinphoneUI/UICheckBoxTVTableViewController.m diff --git a/Classes/Base.lproj/HistoryListView.xib b/Classes/Base.lproj/HistoryListView.xib index 30f2fd6d8..fc1299356 100644 --- a/Classes/Base.lproj/HistoryListView.xib +++ b/Classes/Base.lproj/HistoryListView.xib @@ -1,8 +1,8 @@ - + - + @@ -92,7 +92,7 @@ - + @@ -129,4 +129,9 @@ + + + + + diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index bf81ce5c7..b68481ece 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -121,11 +121,6 @@ static void chatTable_free_chatrooms(void *data) { UIChatCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[UIChatCell alloc] initWithIdentifier:kCellId]; - - // Background View - UACellBackgroundView *selectedBackgroundView = [[UACellBackgroundView alloc] initWithFrame:CGRectZero]; - cell.selectedBackgroundView = selectedBackgroundView; - [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; } [cell setChatRoom:(LinphoneChatRoom *)ms_list_nth_data(data, (int)[indexPath row])]; diff --git a/Classes/ContactDetailsLabelView.m b/Classes/ContactDetailsLabelView.m index 1e4d03f03..2b0507157 100644 --- a/Classes/ContactDetailsLabelView.m +++ b/Classes/ContactDetailsLabelView.m @@ -88,11 +88,6 @@ static UICompositeViewDescription *compositeDescription = nil; UITableViewCell *cell = [atableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCellId]; - - // Background View - UACellBackgroundView *selectedBackgroundView = [[UACellBackgroundView alloc] initWithFrame:CGRectZero]; - cell.selectedBackgroundView = selectedBackgroundView; - [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; } NSString *key = [[dataList allKeys] objectAtIndex:[indexPath row]]; [cell.textLabel setText:[dataList objectForKey:key]]; diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m index 52052586c..a6a2c5ffb 100644 --- a/Classes/ContactDetailsTableView.m +++ b/Classes/ContactDetailsTableView.m @@ -491,11 +491,6 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe [cell.detailTextField setAutocapitalizationType:UITextAutocapitalizationTypeNone]; [cell.detailTextField setAutocorrectionType:UITextAutocorrectionTypeNo]; [cell setBackgroundColor:[UIColor whiteColor]]; - - // Background View - UACellBackgroundView *selectedBackgroundView = [[UACellBackgroundView alloc] initWithFrame:CGRectZero]; - cell.selectedBackgroundView = selectedBackgroundView; - [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; } NSMutableArray *sectionDict = [self getSectionData:[indexPath section]]; diff --git a/Classes/ContactsListTableView.m b/Classes/ContactsListTableView.m index b9a700d69..9fe75a3b0 100644 --- a/Classes/ContactsListTableView.m +++ b/Classes/ContactsListTableView.m @@ -188,11 +188,6 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info UIContactCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[UIContactCell alloc] initWithIdentifier:kCellId]; - - // Background View - UACellBackgroundView *selectedBackgroundView = [[UACellBackgroundView alloc] initWithFrame:CGRectZero]; - cell.selectedBackgroundView = selectedBackgroundView; - [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; } OrderedDictionary *subDic = [addressBookMap objectForKey:[addressBookMap keyAtIndex:[indexPath section]]]; diff --git a/Classes/HistoryListTableView.h b/Classes/HistoryListTableView.h index 6e5891f53..76107e3d1 100644 --- a/Classes/HistoryListTableView.h +++ b/Classes/HistoryListTableView.h @@ -19,7 +19,9 @@ #import -@interface HistoryListTableView : UITableViewController { +#import "UICheckBoxTVTableViewController.h" + +@interface HistoryListTableView : UICheckBoxTVTableViewController { @private NSMutableArray *callLogs; } diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m index d1c951023..bcb6662fa 100644 --- a/Classes/HistoryListTableView.m +++ b/Classes/HistoryListTableView.m @@ -24,16 +24,13 @@ #import "UACellBackgroundView.h" #import "Utils.h" -@implementation HistoryListTableView { - NSMutableArray *selectedItems; -} +@implementation HistoryListTableView @synthesize missedFilter; #pragma mark - Lifecycle Functions - (void)initHistoryTableViewController { - selectedItems = [[NSMutableArray alloc] init]; callLogs = [[NSMutableArray alloc] init]; missedFilter = false; } @@ -111,7 +108,7 @@ } logs = ms_list_next(logs); } - [[self tableView] reloadData]; + [super loadData]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -127,33 +124,21 @@ UIHistoryCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[UIHistoryCell alloc] initWithIdentifier:kCellId]; - // Background View - UACellBackgroundView *selectedBackgroundView = [[UACellBackgroundView alloc] initWithFrame:CGRectZero]; - cell.selectedBackgroundView = selectedBackgroundView; - [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; } - LinphoneCallLog *log = [[callLogs objectAtIndex:[indexPath row]] pointerValue]; + id logId = [callLogs objectAtIndex:indexPath.row]; + LinphoneCallLog *log = [logId pointerValue]; [cell setCallLog:log]; - + [super accessoryForCell:cell atPath:indexPath]; return cell; } #pragma mark - UITableViewDelegate Functions - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - LinphoneCallLog *callLog = [[callLogs objectAtIndex:[indexPath row]] pointerValue]; - + [super tableView:tableView didSelectRowAtIndexPath:indexPath]; if ([self isEditing]) { - UIHistoryCell *cell = (UIHistoryCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath]; - if ([selectedItems containsObject:indexPath]) { - [selectedItems removeObject:indexPath]; - cell.checkBoxButton.selected = YES; - } else { - [selectedItems addObject:indexPath]; - cell.checkBoxButton.selected = NO; - } - } else { + 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); diff --git a/Classes/HistoryListView.m b/Classes/HistoryListView.m index cd985b6ae..5b08504a2 100644 --- a/Classes/HistoryListView.m +++ b/Classes/HistoryListView.m @@ -89,6 +89,10 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)hideEditIfNeeded { editButton.hidden = ([tableController tableView:tableController.tableView numberOfRowsInSection:0] == 0); + if ([editButton isSelected]) { + [editButton toggle]; + [self onEditClick:nil]; + } } - (void)changeView:(HistoryView)view { @@ -124,13 +128,11 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onDeleteClick:(id)event { - linphone_core_clear_call_logs([LinphoneManager getLc]); + for (id log in tableController.selectedItems) { + linphone_core_remove_call_log([LinphoneManager getLc], (LinphoneCallLog *)[log pointerValue]); + } [tableController loadData]; [self hideEditIfNeeded]; - if ([editButton isSelected]) { - [editButton toggle]; - [self onEditClick:nil]; - } } @end diff --git a/Classes/LinphoneUI/Base.lproj/UIHistoryCell.xib b/Classes/LinphoneUI/Base.lproj/UIHistoryCell.xib index 02afcd696..7fd8eafc7 100644 --- a/Classes/LinphoneUI/Base.lproj/UIHistoryCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIHistoryCell.xib @@ -1,14 +1,13 @@ - + - + - @@ -50,13 +49,7 @@ - -