mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-25 10:18:34 +00:00
sort create chat room view alphabetically
This commit is contained in:
parent
2a595c83a2
commit
5b821df4ea
1 changed files with 17 additions and 21 deletions
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
@interface ChatConversationCreateTableView ()
|
@interface ChatConversationCreateTableView ()
|
||||||
|
|
||||||
@property(nonatomic, strong) NSMutableDictionary *contacts;
|
@property(nonatomic, strong) NSMutableArray *addresses;
|
||||||
@property(nonatomic, strong) NSDictionary *allContacts;
|
@property(nonatomic, strong) NSDictionary *allContacts;
|
||||||
@property(nonatomic, strong) NSMutableArray *contactsAddresses;
|
@property(nonatomic, strong) NSMutableArray *contactsAddresses;
|
||||||
@property(nonatomic, strong) NSArray *sortedAddresses;
|
@property(nonatomic, strong) NSArray *sortedAddresses;
|
||||||
|
|
@ -32,24 +32,23 @@
|
||||||
else
|
else
|
||||||
return [[first.firstName lowercaseString] compare:[second.firstName lowercaseString]];
|
return [[first.firstName lowercaseString] compare:[second.firstName lowercaseString]];
|
||||||
}];
|
}];
|
||||||
self.contacts = [[NSMutableDictionary alloc] initWithCapacity:_allContacts.count];
|
|
||||||
self.contactsAddresses = [NSMutableArray array];
|
self.contactsAddresses = [NSMutableArray array];
|
||||||
[_searchBar becomeFirstResponder];
|
_addresses = [[NSMutableArray alloc] initWithCapacity:_sortedAddresses.count];
|
||||||
[_searchBar setText:@""];
|
[_searchBar setText:@""];
|
||||||
[self searchBar:_searchBar textDidChange:_searchBar.text];
|
[self searchBar:_searchBar textDidChange:_searchBar.text];
|
||||||
self.tableView.accessibilityIdentifier = @"Suggested addresses";
|
self.tableView.accessibilityIdentifier = @"Suggested addresses";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadDataWithFilter:(NSString *)filter {
|
- (void)reloadDataWithFilter:(NSString *)filter {
|
||||||
[_contacts removeAllObjects];
|
[_addresses removeAllObjects];
|
||||||
[_contactsAddresses removeAllObjects];
|
[_contactsAddresses removeAllObjects];
|
||||||
for (NSString* key in _sortedAddresses){
|
for (NSString* key in _sortedAddresses){
|
||||||
NSString *address = (NSString *)key;
|
NSString *address = (NSString *)key;
|
||||||
NSString *name = [FastAddressBook displayNameForContact:[_allContacts objectForKey:key]];
|
NSString *name = [FastAddressBook displayNameForContact:[_allContacts objectForKey:key]];
|
||||||
if ((filter.length == 0) || ([name.lowercaseString containsSubstring:filter.lowercaseString]) ||
|
if ((filter.length == 0) || ([name.lowercaseString containsSubstring:filter.lowercaseString]) ||
|
||||||
([address.lowercaseString containsSubstring:filter.lowercaseString])) {
|
([address.lowercaseString containsSubstring:filter.lowercaseString])) {
|
||||||
[_contacts setObject:name forKey:address] ;
|
[_addresses addObject:key];
|
||||||
[_contactsAddresses insertObject:address atIndex:[_contactsAddresses count]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// also add current entry, if not listed
|
// also add current entry, if not listed
|
||||||
|
|
@ -61,10 +60,10 @@
|
||||||
ms_free(uri);
|
ms_free(uri);
|
||||||
linphone_address_destroy(addr);
|
linphone_address_destroy(addr);
|
||||||
}
|
}
|
||||||
if (nsuri.length > 0 && [_contacts valueForKey:nsuri] == nil) {
|
|
||||||
[_contacts setObject:filter forKey:nsuri] ;
|
if (nsuri.length > 0 && ![_addresses containsObject:nsuri])
|
||||||
[_contactsAddresses insertObject:nsuri atIndex:[_contactsAddresses count]];
|
[_addresses addObject:nsuri];
|
||||||
}
|
|
||||||
[self.tableView reloadData];
|
[self.tableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,7 +72,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||||
return [self.contacts count];
|
return _addresses.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
|
|
@ -81,14 +80,11 @@
|
||||||
UIChatCreateCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
|
UIChatCreateCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
|
||||||
if (cell == nil) {
|
if (cell == nil) {
|
||||||
cell = [[UIChatCreateCell alloc] initWithIdentifier:kCellId];
|
cell = [[UIChatCreateCell alloc] initWithIdentifier:kCellId];
|
||||||
}
|
|
||||||
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:[_contactsAddresses objectAtIndex:indexPath.row]];
|
NSString *key = [_addresses objectAtIndex:indexPath.row];
|
||||||
cell.displayNameLabel.text = [_contacts objectForKey:[_contactsAddresses objectAtIndex:indexPath.row]];
|
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:key];
|
||||||
if (addr) {
|
cell.displayNameLabel.text = [FastAddressBook displayNameForAddress:addr];
|
||||||
cell.addressLabel.text = [NSString stringWithUTF8String:linphone_address_as_string(addr)];
|
cell.addressLabel.text = [NSString stringWithUTF8String:linphone_address_as_string(addr)];
|
||||||
} else {
|
|
||||||
cell.addressLabel.text = [_contacts.allKeys objectAtIndex:indexPath.row];
|
|
||||||
}
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,7 +95,7 @@
|
||||||
if (addr) {
|
if (addr) {
|
||||||
uri = [NSString stringWithUTF8String:linphone_address_as_string(addr)];
|
uri = [NSString stringWithUTF8String:linphone_address_as_string(addr)];
|
||||||
} else {
|
} else {
|
||||||
uri = [_contacts.allKeys objectAtIndex:indexPath.row];
|
uri = [_addresses objectAtIndex:indexPath.row];
|
||||||
}
|
}
|
||||||
LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, uri.UTF8String);
|
LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, uri.UTF8String);
|
||||||
if (!room) {
|
if (!room) {
|
||||||
|
|
@ -108,7 +104,7 @@
|
||||||
message:NSLocalizedString(@"Please specify the entire SIP address for the chat",
|
message:NSLocalizedString(@"Please specify the entire SIP address for the chat",
|
||||||
nil)
|
nil)
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
|
||||||
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
|
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
|
||||||
style:UIAlertActionStyleDefault
|
style:UIAlertActionStyleDefault
|
||||||
handler:^(UIAlertAction * action) {}];
|
handler:^(UIAlertAction * action) {}];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue