diff --git a/Classes/Base.lproj/CallView.xib b/Classes/Base.lproj/CallView.xib
index b93eb19b6..0edcae9f7 100644
--- a/Classes/Base.lproj/CallView.xib
+++ b/Classes/Base.lproj/CallView.xib
@@ -144,7 +144,7 @@
-
+
diff --git a/Classes/Base.lproj/ContactDetailsView.xib b/Classes/Base.lproj/ContactDetailsView.xib
index 47f0c8974..239e01980 100644
--- a/Classes/Base.lproj/ContactDetailsView.xib
+++ b/Classes/Base.lproj/ContactDetailsView.xib
@@ -11,6 +11,7 @@
+
@@ -97,8 +98,36 @@
+
-
+
diff --git a/Classes/Base.lproj/HistoryListView.xib b/Classes/Base.lproj/HistoryListView.xib
index 8e8e365ea..818d4839f 100644
--- a/Classes/Base.lproj/HistoryListView.xib
+++ b/Classes/Base.lproj/HistoryListView.xib
@@ -1,6 +1,7 @@
+
@@ -118,7 +119,7 @@
-
+
diff --git a/Classes/ContactDetailsTableView.h b/Classes/ContactDetailsTableView.h
index 35bf74d1a..e521dc505 100644
--- a/Classes/ContactDetailsTableView.h
+++ b/Classes/ContactDetailsTableView.h
@@ -21,7 +21,6 @@
#import
#import "ContactDetailsDelegate.h"
-#import "ContactDetailsLabelView.h"
typedef enum _ContactSections {
ContactSections_None = 0, // first section is empty because we cannot set header for first section
@@ -33,7 +32,7 @@ typedef enum _ContactSections {
ContactSections_MAX
} ContactSections_e;
-@interface ContactDetailsTableView : UITableViewController {
+@interface ContactDetailsTableView : UITableViewController {
@private
NSMutableArray *dataCache;
NSMutableArray *labelArray;
diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m
index 5190a58a7..1426e4bfa 100644
--- a/Classes/ContactDetailsTableView.m
+++ b/Classes/ContactDetailsTableView.m
@@ -486,7 +486,8 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (contactSections[section] == ContactSections_First_Name ||
contactSections[section] == ContactSections_Last_Name) {
- return 1;
+ return 0;
+ // return (self.tableView.isEditing) ? 1 : 0 /*no first and last name when not editting */;
} else {
return [[self getSectionData:section] count];
}
@@ -640,11 +641,6 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {
}
if (key != nil) {
editingIndexPath = indexPath;
- ContactDetailsLabelView *view = VIEW(ContactDetailsLabelView);
- [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE];
- [view setDataList:[self getLocalizedLabels]];
- [view setSelectedData:key];
- [view setDelegate:self];
}
}
}
@@ -722,9 +718,9 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
NSString *text = nil;
- if (contactSections[section] == ContactSections_First_Name) {
+ if (contactSections[section] == ContactSections_First_Name && self.tableView.isEditing) {
text = NSLocalizedString(@"First name", nil);
- } else if (contactSections[section] == ContactSections_Last_Name) {
+ } else if (contactSections[section] == ContactSections_Last_Name && self.tableView.isEditing) {
text = NSLocalizedString(@"Last name", nil);
} else if ([self getSectionData:section].count > 0) {
if (contactSections[section] == ContactSections_Number) {
@@ -842,8 +838,10 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- if (section == 0)
+ if (section == 0 || (!self.tableView.isEditing && (contactSections[section] == ContactSections_First_Name ||
+ contactSections[section] == ContactSections_Last_Name))) {
return 1e-5;
+ }
return [self tableView:tableView viewForHeaderInSection:section].frame.size.height;
}
diff --git a/Classes/ContactDetailsView.h b/Classes/ContactDetailsView.h
index 8e6f8f272..24593e564 100644
--- a/Classes/ContactDetailsView.h
+++ b/Classes/ContactDetailsView.h
@@ -38,6 +38,7 @@
@property(nonatomic, strong) IBOutlet UIButton *backButton;
@property(nonatomic, strong) IBOutlet UIButton *cancelButton;
@property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
+@property(weak, nonatomic) IBOutlet UILabel *nameLabel;
- (IBAction)onBackClick:(id)event;
- (IBAction)onCancelClick:(id)event;
diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m
index 10d6f5014..4584b3d19 100644
--- a/Classes/ContactDetailsView.m
+++ b/Classes/ContactDetailsView.m
@@ -113,6 +113,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
[self resetData];
_contact = acontact;
_avatarImage.image = [FastAddressBook getContactImage:_contact thumbnail:NO];
+ [ContactDisplay setDisplayNameLabel:_nameLabel forContact:acontact];
[_tableController setContact:_contact];
if (reload) {
diff --git a/Classes/HistoryDetailsTableView.h b/Classes/HistoryDetailsTableView.h
index 5f5537942..025561893 100644
--- a/Classes/HistoryDetailsTableView.h
+++ b/Classes/HistoryDetailsTableView.h
@@ -8,9 +8,12 @@
#import
+#import "linphone/linphonecore.h"
+
@interface HistoryDetailsTableView : UITableViewController {
@private
NSMutableArray *callLogs;
}
-- (void)loadData;
+- (void)loadDataForAddress:(const LinphoneAddress *)peer;
+
@end
diff --git a/Classes/HistoryDetailsTableView.m b/Classes/HistoryDetailsTableView.m
index f3a041db9..3c2d98f54 100644
--- a/Classes/HistoryDetailsTableView.m
+++ b/Classes/HistoryDetailsTableView.m
@@ -12,13 +12,13 @@
@implementation HistoryDetailsTableView
-- (void)loadData {
+- (void)loadDataForAddress:(const LinphoneAddress *)peer {
if (callLogs == nil) {
callLogs = [[NSMutableArray alloc] init];
} else {
[callLogs removeAllObjects];
}
- const MSList *logs = linphone_core_get_call_logs([LinphoneManager getLc]);
+ const MSList *logs = linphone_core_get_call_history_for_address([LinphoneManager getLc], peer);
while (logs != NULL) {
LinphoneCallLog *log = (LinphoneCallLog *)logs->data;
[callLogs addObject:[NSValue valueWithPointer:log]];
diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m
index 7b1b6a015..ea48c72f5 100644
--- a/Classes/HistoryDetailsView.m
+++ b/Classes/HistoryDetailsView.m
@@ -82,7 +82,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- [_tableView loadData];
+ [_tableView loadDataForAddress:(callLog ? linphone_call_log_get_remote_address(callLog) : NULL)];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(update)
diff --git a/Classes/HistoryListTableView.h b/Classes/HistoryListTableView.h
index 230fcb15c..dfae042e0 100644
--- a/Classes/HistoryListTableView.h
+++ b/Classes/HistoryListTableView.h
@@ -24,9 +24,9 @@
@interface HistoryListTableView : UICheckBoxTVTableViewController {
}
-- (void)loadData;
-
-@property(nonatomic, readonly) NSMutableArray *callLogs;
@property(nonatomic, assign) BOOL missedFilter;
+@property(strong, nonatomic) NSMutableDictionary *sections;
+@property(strong, nonatomic) NSArray *sortedDays;
+
@end
diff --git a/Classes/HistoryListTableView.m b/Classes/HistoryListTableView.m
index 0e64a0c86..768b00464 100644
--- a/Classes/HistoryListTableView.m
+++ b/Classes/HistoryListTableView.m
@@ -31,7 +31,6 @@
#pragma mark - Lifecycle Functions
- (void)initHistoryTableViewController {
- _callLogs = [[NSMutableArray alloc] init];
missedFilter = false;
}
@@ -94,29 +93,75 @@
#pragma mark - UITableViewDataSource Functions
+- (NSDate *)dateAtBeginningOfDayForDate:(NSDate *)inputDate {
+ NSCalendar *calendar = [NSCalendar currentCalendar];
+ NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
+ [calendar setTimeZone:timeZone];
+ NSDateComponents *dateComps =
+ [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:inputDate];
+ dateComps.hour = dateComps.minute = dateComps.second = 0;
+ return [calendar dateFromComponents:dateComps];
+}
+
- (void)loadData {
- [_callLogs removeAllObjects];
const MSList *logs = linphone_core_get_call_logs([LinphoneManager getLc]);
+ self.sections = [NSMutableDictionary dictionary];
while (logs != NULL) {
LinphoneCallLog *log = (LinphoneCallLog *)logs->data;
- if (missedFilter) {
- if (linphone_call_log_get_status(log) == LinphoneCallMissed) {
- [_callLogs addObject:[NSValue valueWithPointer:log]];
+ if (!missedFilter || linphone_call_log_get_status(log) == LinphoneCallMissed) {
+ NSDate *startDate = [self
+ dateAtBeginningOfDayForDate:[NSDate
+ dateWithTimeIntervalSince1970:linphone_call_log_get_start_date(log)]];
+ NSMutableArray *eventsOnThisDay = [self.sections objectForKey:startDate];
+ if (eventsOnThisDay == nil) {
+ eventsOnThisDay = [NSMutableArray array];
+ [self.sections setObject:eventsOnThisDay forKey:startDate];
}
- } else {
- [_callLogs addObject:[NSValue valueWithPointer:log]];
+
+ [eventsOnThisDay addObject:[NSValue valueWithPointer:log]];
}
logs = ms_list_next(logs);
}
+
+ NSArray *unsortedDays = [self.sections allKeys];
+ self.sortedDays = [unsortedDays sortedArrayUsingComparator:^NSComparisonResult(NSDate *d1, NSDate *d2) {
+ return ![d1 compare:d2]; // reverse order
+ }];
+
[super loadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
+ return _sortedDays.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return [_callLogs count];
+ NSArray *logs = [_sections objectForKey:_sortedDays[section]];
+ return logs.count;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
+ UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 300, 244)];
+ tempView.backgroundColor = [UIColor clearColor];
+
+ UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 300, 44)];
+ tempLabel.backgroundColor = [UIColor clearColor];
+ tempLabel.textColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A"]];
+ NSDate *eventDate = _sortedDays[section];
+ NSDate *currentDate = [self dateAtBeginningOfDayForDate:[NSDate date]];
+ if ([eventDate isEqualToDate:currentDate]) {
+ tempLabel.text = NSLocalizedString(@"TODAY", nil);
+ } else if ([eventDate isEqualToDate:[currentDate dateByAddingTimeInterval:-3600 * 24]]) {
+ tempLabel.text = NSLocalizedString(@"YESTERDAY", nil);
+ } else {
+ tempLabel.text =
+ [LinphoneUtils timeToString:eventDate.timeIntervalSince1970 withStyle:NSDateFormatterMediumStyle];
+ }
+ tempLabel.textAlignment = NSTextAlignmentCenter;
+ tempLabel.font = [UIFont boldSystemFontOfSize:17];
+ [tempView addSubview:tempLabel];
+
+ return tempView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -126,7 +171,7 @@
cell = [[UIHistoryCell alloc] initWithIdentifier:kCellId];
}
- id logId = [_callLogs objectAtIndex:indexPath.row];
+ id logId = [_sections objectForKey:_sortedDays[indexPath.section]][indexPath.row];
LinphoneCallLog *log = [logId pointerValue];
[cell setCallLog:log];
[super accessoryForCell:cell atPath:indexPath];
@@ -138,7 +183,8 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[super tableView:tableView didSelectRowAtIndexPath:indexPath];
if (![self isEditing]) {
- LinphoneCallLog *callLog = [[_callLogs objectAtIndex:[indexPath row]] pointerValue];
+ id log = [_sections objectForKey:_sortedDays[indexPath.section]][indexPath.row];
+ LinphoneCallLog *callLog = [log 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);
@@ -155,9 +201,14 @@
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[tableView beginUpdates];
- LinphoneCallLog *callLog = [[_callLogs objectAtIndex:[indexPath row]] pointerValue];
+ id log = [_sections objectForKey:_sortedDays[indexPath.section]][indexPath.row];
+ LinphoneCallLog *callLog = [log pointerValue];
linphone_core_remove_call_log([LinphoneManager getLc], callLog);
- [_callLogs removeObjectAtIndex:[indexPath row]];
+ [[_sections objectForKey:_sortedDays[indexPath.section]] removeObject:log];
+ if (((NSArray *)[_sections objectForKey:_sortedDays[indexPath.section]]).count == 0) {
+ [_sections removeObjectForKey:_sortedDays[indexPath.section]];
+ }
+
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
diff --git a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib
index b5646d11e..1d290c85b 100644
--- a/Classes/LinphoneUI/Base.lproj/UIContactCell.xib
+++ b/Classes/LinphoneUI/Base.lproj/UIContactCell.xib
@@ -113,10 +113,9 @@