History: do not display the same user multiple times when consecutive calls

This commit is contained in:
Gautier Pelloux-Prayer 2015-12-01 13:52:22 +01:00
parent d1245a3fb9
commit 2216c12e85
3 changed files with 18 additions and 2 deletions

View file

@ -118,7 +118,17 @@
[self.sections setObject:eventsOnThisDay forKey:startDate];
}
[eventsOnThisDay addObject:[NSValue valueWithPointer:log]];
// if this contact was already the previous entry, do not add it twice
LinphoneCallLog *prev = [eventsOnThisDay lastObject] ? [[eventsOnThisDay lastObject] pointerValue] : NULL;
if (prev && linphone_address_weak_equal(linphone_call_log_get_remote_address(prev),
linphone_call_log_get_remote_address(log))) {
long value = (long)linphone_call_log_get_user_data(prev);
value++;
linphone_call_log_set_user_data(prev, (void *)value);
} else {
linphone_call_log_set_user_data(log, (void *)1);
[eventsOnThisDay addObject:[NSValue valueWithPointer:log]];
}
}
logs = ms_list_next(logs);
}

View file

@ -38,7 +38,6 @@
<accessibility key="accessibilityConfiguration" label="History"/>
<state key="normal" image="footer_history_default.png"/>
<state key="disabled" image="footer_history_disabled.png"/>
<state key="selected" backgroundImage="color_A.png"/>
<state key="highlighted" backgroundImage="color_A.png"/>
<connections>
<action selector="onHistoryClick:" destination="-1" eventType="touchUpInside" id="22"/>

View file

@ -95,6 +95,13 @@
_stateImage.image = image;
[ContactDisplay setDisplayNameLabel:displayNameLabel forAddress:addr];
long count = (long)(linphone_call_log_get_user_data(callLog) ?: 0);
if (count > 1) {
displayNameLabel.text =
[displayNameLabel.text stringByAppendingString:[NSString stringWithFormat:@" (%ld)", count]];
}
[_avatarImage setImage:[FastAddressBook imageForAddress:addr thumbnail:YES] bordered:NO withRoundedRadius:YES];
}