diff --git a/Classes/Base.lproj/ChatConversationView.xib b/Classes/Base.lproj/ChatConversationView.xib index b68877f92..845056e97 100644 --- a/Classes/Base.lproj/ChatConversationView.xib +++ b/Classes/Base.lproj/ChatConversationView.xib @@ -1,5 +1,5 @@ - + @@ -8,9 +8,10 @@ - + + @@ -86,33 +87,63 @@ - + - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -168,27 +199,42 @@ - + - + + + + + + + + + + + + + + + + - - - + + + - - + + - - + + diff --git a/Classes/ChatConversationSearchTableView.h b/Classes/ChatConversationSearchTableView.h new file mode 100644 index 000000000..1fac7618a --- /dev/null +++ b/Classes/ChatConversationSearchTableView.h @@ -0,0 +1,13 @@ +// +// ChatConversationSearchTableView.h +// linphone +// +// Created by Gautier Pelloux-Prayer on 30/09/15. +// +// + +#import + +@interface ChatConversationSearchTableView : UITableViewController + +@end diff --git a/Classes/ChatConversationSearchTableView.m b/Classes/ChatConversationSearchTableView.m new file mode 100644 index 000000000..afeda8ad7 --- /dev/null +++ b/Classes/ChatConversationSearchTableView.m @@ -0,0 +1,366 @@ +// +// MyTableViewController.m +// UISearchDisplayController +// +// Created by Phillip Harris on 4/19/14. +// Copyright (c) 2014 Phillip Harris. All rights reserved. +// + +#import "ChatConversationSearchTableView.h" + +@interface ChatConversationSearchTableView () + +@property(nonatomic, strong) NSArray *names; +@property(nonatomic, strong) NSArray *searchResults; +@property(nonatomic, strong) UISearchDisplayController *searchController; + +@end + +@implementation ChatConversationSearchTableView + +//=============================================== +#pragma mark - +#pragma mark Initialization +//=============================================== + +- (id)initWithStyle:(UITableViewStyle)style { + self = [super initWithStyle:style]; + if (self) { + [self commonInit]; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)coder { + self = [super initWithCoder:coder]; + if (self) { + [self commonInit]; + } + return self; +} + +- (void)commonInit { + _names = @[ + @"Aaliyah", + @"Aaron", + @"Abigail", + @"Adam", + @"Addison", + @"Adrian", + @"Aiden", + @"Alex", + @"Alexa", + @"Alexander", + @"Alexandra", + @"Alexis", + @"Allison", + @"Alyssa", + @"Amelia", + @"Andrea", + @"Andrew", + @"Angel", + @"Anna", + @"Annabelle", + @"Anthony", + @"Aria", + @"Ariana", + @"Arianna", + @"Ashley", + @"Aubree", + @"Aubrey", + @"Audrey", + @"Austin", + @"Autumn", + @"Ava", + @"Avery", + @"Ayden", + @"Bailey", + @"Bella", + @"Benjamin", + @"Bentley", + @"Blake", + @"Brandon", + @"Brayden", + @"Brianna", + @"Brody", + @"Brooklyn", + @"Bryson", + @"Caleb", + @"Cameron", + @"Camila", + @"Carlos", + @"Caroline", + @"Carson", + @"Carter", + @"Charles", + @"Charlotte", + @"Chase", + @"Chloe", + @"Christian", + @"Christopher", + @"Claire", + @"Colton", + @"Connor", + @"Cooper", + @"Damian", + @"Daniel", + @"David", + @"Dominic", + @"Dylan", + @"Easton", + @"Eli", + @"Elijah", + @"Elizabeth", + @"Ella", + @"Ellie", + @"Emily", + @"Emma", + @"Ethan", + @"Eva", + @"Evan", + @"Evelyn", + @"Faith", + @"Gabriel", + @"Gabriella", + @"Gavin", + @"Genesis", + @"Gianna", + @"Grace", + @"Grayson", + @"Hailey", + @"Hannah", + @"Harper", + @"Henry", + @"Hudson", + @"Hunter", + @"Ian", + @"Isaac", + @"Isabella", + @"Isaiah", + @"Jace", + @"Jack", + @"Jackson", + @"Jacob", + @"James", + @"Jasmine", + @"Jason", + @"Jaxon", + @"Jayden", + @"Jeremiah", + @"Jocelyn", + @"John", + @"Jonathan", + @"Jordan", + @"Jose", + @"Joseph", + @"Joshua", + @"Josiah", + @"Juan", + @"Julia", + @"Julian", + @"Justin", + @"Katherine", + @"Kayden", + @"Kayla", + @"Kaylee", + @"Kennedy", + @"Kevin", + @"Khloe", + @"Kimberly", + @"Kylie", + @"Landon", + @"Lauren", + @"Layla", + @"Leah", + @"Levi", + @"Liam", + @"Lillian", + @"Lily", + @"Logan", + @"London", + @"Lucas", + @"Lucy", + @"Luis", + @"Luke", + @"Lydia", + @"Mackenzie", + @"Madeline", + @"Madelyn", + @"Madison", + @"Makayla", + @"Mason", + @"Matthew", + @"Maya", + @"Melanie", + @"Mia", + @"Michael", + @"Molly", + @"Morgan", + @"Naomi", + @"Natalie", + @"Nathan", + @"Nathaniel", + @"Nevaeh", + @"Nicholas", + @"Noah", + @"Nolan", + @"Oliver", + @"Olivia", + @"Owen", + @"Parker", + @"Peyton", + @"Piper", + @"Reagan", + @"Riley", + @"Robert", + @"Ryan", + @"Ryder", + @"Samantha", + @"Samuel", + @"Sarah", + @"Savannah", + @"Scarlett", + @"Sebastian", + @"Serenity", + @"Skylar", + @"Sofia", + @"Sophia", + @"Sophie", + @"Stella", + @"Sydney", + @"Taylor", + @"Thomas", + @"Trinity", + @"Tristan", + @"Tyler", + @"Victoria", + @"Violet", + @"William", + @"Wyatt", + @"Xavier", + @"Zachary", + @"Zoe", + @"Zoey" + ]; +} + +//=============================================== +#pragma mark - +#pragma mark View Methods +//=============================================== + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self configureTableView:self.tableView]; +} + +//=============================================== +#pragma mark - +#pragma mark Helper +//=============================================== + +- (void)configureTableView:(UITableView *)tableView { + + tableView.separatorInset = UIEdgeInsetsZero; + + [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellId"]; + + UIView *tableFooterViewToGetRidOfBlankRows = [[UIView alloc] initWithFrame:CGRectZero]; + tableFooterViewToGetRidOfBlankRows.backgroundColor = [UIColor clearColor]; + tableView.tableFooterView = tableFooterViewToGetRidOfBlankRows; +} + +//=============================================== +#pragma mark - +#pragma mark UITableView +//=============================================== + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + if (tableView == self.tableView) { + return [self.names count]; + } else { + return [self.searchResults count]; + } +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath]; + + NSString *name = (tableView == self.tableView) ? self.names[indexPath.row] : self.searchResults[indexPath.row]; + + cell.textLabel.text = name; + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + [tableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +//=============================================== +#pragma mark - +#pragma mark UISearchDisplayDelegate +//=============================================== + +- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller { + NSLog(@"🔦 | will begin search"); +} +- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { + NSLog(@"🔦 | did begin search"); +} +- (void)searchDisplayControllerWillEndSearch:(UISearchDisplayController *)controller { + NSLog(@"🔦 | will end search"); +} +- (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller { + NSLog(@"🔦 | did end search"); +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + didLoadSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | did load table"); + [self configureTableView:tableView]; +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + willUnloadSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | will unload table"); +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + willShowSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | will show table"); +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + didShowSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | did show table"); +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + willHideSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | will hide table"); +} +- (void)searchDisplayController:(UISearchDisplayController *)controller + didHideSearchResultsTableView:(UITableView *)tableView { + NSLog(@"🔦 | did hide table"); +} +- (BOOL)searchDisplayController:(UISearchDisplayController *)controller + shouldReloadTableForSearchString:(NSString *)searchString { + NSLog(@"🔦 | should reload table for search string?"); + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF CONTAINS[cd] %@", searchString]; + self.searchResults = [self.names filteredArrayUsingPredicate:predicate]; + + return YES; +} +- (BOOL)searchDisplayController:(UISearchDisplayController *)controller +shouldReloadTableForSearchScope:(NSInteger)searchOption { + NSLog(@"🔦 | should reload table for search scope?"); + return YES; +} + +@end diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index 11d241a0c..71638813c 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -48,8 +48,8 @@ @property(nonatomic, strong) IBOutlet UISwipeGestureRecognizer *listSwipeGestureRecognizer; @property(strong, nonatomic) IBOutlet UILabel *composeLabel; @property(strong, nonatomic) IBOutlet UIView *composeIndicatorView; - @property(nonatomic, strong) IBOutlet UIButton *pictureButton; +@property(weak, nonatomic) IBOutlet UIView *createChatView; - (IBAction)onBackClick:(id)event; - (IBAction)onEditClick:(id)event; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 25880bce1..0a294454c 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -163,12 +163,18 @@ static UICompositeViewDescription *compositeDescription = nil; chatRoom = room; [messageField setText:@""]; [tableController setChatRoom:room]; + if (chatRoom != NULL) { + _createChatView.hidden = YES; + chatView.hidden = NO; [self update]; linphone_chat_room_mark_as_read(chatRoom); [self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0]; + [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; + } else { + _createChatView.hidden = NO; + chatView.hidden = YES; } - [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; } - (void)applicationWillEnterForeground:(NSNotification *)notif { diff --git a/Classes/ChatsListView.h b/Classes/ChatsListView.h index e3a11b6d0..ec82cd363 100644 --- a/Classes/ChatsListView.h +++ b/Classes/ChatsListView.h @@ -24,12 +24,11 @@ #import "ChatsListTableView.h" #import "UICompositeView.h" -@interface ChatsListView : UIViewController { +@interface ChatsListView : UIViewController { } @property(nonatomic, strong) IBOutlet ChatsListTableView *tableController; @property(nonatomic, strong) IBOutlet UIButton *editButton; -@property(nonatomic, strong) IBOutlet UITextField *addressField; @property(weak, nonatomic) IBOutlet UIButton *toggleSelectionButton; @property(weak, nonatomic) IBOutlet UIButton *backButton; @property(weak, nonatomic) IBOutlet UIButton *addButton; diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index b2007f321..5c45b6bd5 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -73,36 +73,10 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions -- (void)startChatRoom { - // Push ChatRoom - LinphoneChatRoom *room = - linphone_core_get_chat_room_from_uri([LinphoneManager getLc], [_addressField.text UTF8String]); - if (room != nil) { - ChatConversationView *view = VIEW(ChatConversationView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; - [view setChatRoom:room]; - } else { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid address", nil) - message:@"Please specify the entire SIP address for the chat" - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [alert show]; - } - _addressField.text = @""; -} - - (IBAction)onAddClick:(id)event { - if (_addressField.text.length == 0) { // if no address is manually set, lauch address book - [ContactSelection setSelectionMode:ContactSelectionModeMessage]; - [ContactSelection setAddAddress:nil]; - [ContactSelection setSipFilter:[LinphoneManager instance].contactFilter]; - [ContactSelection enableEmailFilter:FALSE]; - [ContactSelection setNameOrEmailFilter:nil]; - [PhoneMainView.instance changeCurrentView:ContactsListView.compositeViewDescription push:TRUE]; - } else { - [self startChatRoom]; - } + ChatConversationView *view = VIEW(ChatConversationView); + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; + [view setChatRoom:NULL]; } - (void)setEditing:(BOOL)editing { @@ -118,12 +92,4 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onSelectionToggle:(id)sender { } -#pragma mark - UITextFieldDelegate Functions - -- (BOOL)textFieldShouldReturn:(UITextField *)textField { - [_addressField resignFirstResponder]; - if (_addressField.text.length > 0) - [self startChatRoom]; - return YES; -} @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 2c2f2bf3e..82cff1014 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ 633756391B67BAF400E21BAD /* SideMenuTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 633756381B67BAF400E21BAD /* SideMenuTableView.m */; }; 633756451B67D2B200E21BAD /* SideMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 633756431B67D2B100E21BAD /* SideMenuView.m */; }; 633756461B67D2B200E21BAD /* SideMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 633756441B67D2B100E21BAD /* SideMenuView.xib */; }; + 6341807C1BBC103100F71761 /* ChatConversationSearchTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6341807B1BBC103100F71761 /* ChatConversationSearchTableView.m */; }; 634610061B61330300548952 /* UILabel+Boldify.m in Sources */ = {isa = PBXBuildFile; fileRef = 634610051B61330300548952 /* UILabel+Boldify.m */; }; 6346100F1B61409800548952 /* CallOutgoingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6346100E1B61409800548952 /* CallOutgoingView.m */; }; 634610121B6140A500548952 /* CallOutgoingView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 634610101B6140A500548952 /* CallOutgoingView.xib */; }; @@ -704,6 +705,8 @@ 633756431B67D2B100E21BAD /* SideMenuView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SideMenuView.m; sourceTree = ""; }; 633756441B67D2B100E21BAD /* SideMenuView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SideMenuView.xib; sourceTree = ""; }; 633E388219FFB0F400936D1C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 6341807A1BBC103100F71761 /* ChatConversationSearchTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatConversationSearchTableView.h; sourceTree = ""; }; + 6341807B1BBC103100F71761 /* ChatConversationSearchTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatConversationSearchTableView.m; sourceTree = ""; }; 634610041B61330300548952 /* UILabel+Boldify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+Boldify.h"; sourceTree = ""; }; 634610051B61330300548952 /* UILabel+Boldify.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Boldify.m"; sourceTree = ""; }; 6346100D1B61409800548952 /* CallOutgoingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallOutgoingView.h; sourceTree = ""; }; @@ -1350,6 +1353,8 @@ D3F83EE91582021700336684 /* CallView.h */, D3F83EEA1582021700336684 /* CallView.m */, D381881C15FE3FCA00C3EDCA /* CallView.xib */, + 6341807A1BBC103100F71761 /* ChatConversationSearchTableView.h */, + 6341807B1BBC103100F71761 /* ChatConversationSearchTableView.m */, D32B6E2715A5BC430033019F /* ChatConversationTableView.h */, D32B6E2815A5BC430033019F /* ChatConversationTableView.m */, D3F795D315A582800077328B /* ChatConversationView.h */, @@ -2646,6 +2651,7 @@ D3549816158761D0000081D8 /* ContactsListTableView.m in Sources */, D35498211587716B000081D8 /* StatusBarView.m in Sources */, D3A55FBC15877E5E003FD403 /* UIContactCell.m in Sources */, + 6341807C1BBC103100F71761 /* ChatConversationSearchTableView.m in Sources */, D326483815887D5200930C67 /* OrderedDictionary.m in Sources */, D32648441588F6FC00930C67 /* UIToggleButton.m in Sources */, D36FB2D51589EF7C0036F6F2 /* UIPauseButton.m in Sources */,