Skip to content

Commit

Permalink
Feature - "Add contact" button should be added on Room Member list
Browse files Browse the repository at this point in the history
#905

+ Improve the people invite screens #904.
  • Loading branch information
giomfo committed Jan 13, 2017
1 parent da0016c commit 8efbbdf
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 428 deletions.
14 changes: 4 additions & 10 deletions Vector.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
F03BF6DC1D8BF5B1002EF6A7 /* voice_call_icon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F03BF6481D8BF5B1002EF6A7 /* voice_call_icon@3x.png */; };
F03DE2A51D0EFA6A00E8B65C /* AttachmentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03DE2A41D0EFA6A00E8B65C /* AttachmentsViewController.m */; };
F046528D1E250B0A00EA4E77 /* ContactsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F046528C1E250B0A00EA4E77 /* ContactsTableViewController.m */; };
F046528F1E28439E00EA4E77 /* ContactsTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F046528E1E28439E00EA4E77 /* ContactsTableViewController.xib */; };
F047DBB51C576F2200952DA2 /* AuthenticationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F047DBB41C576F2200952DA2 /* AuthenticationViewController.xib */; };
F047DBB91C576F6600952DA2 /* AuthInputsView.m in Sources */ = {isa = PBXBuildFile; fileRef = F047DBB71C576F6600952DA2 /* AuthInputsView.m */; };
F047DBBA1C576F6600952DA2 /* AuthInputsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F047DBB81C576F6600952DA2 /* AuthInputsView.xib */; };
Expand Down Expand Up @@ -385,8 +386,6 @@
F0D2D9881C197DCB007B8C96 /* RoomIncomingTextMsgBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0D2D97F1C197DCB007B8C96 /* RoomIncomingTextMsgBubbleCell.xib */; };
F0D2D9891C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F0D2D9811C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m */; };
F0D2D98A1C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0D2D9821C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.xib */; };
F0DD2C701D1308E800654345 /* HomePeopleSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0DD2C6F1D1308E800654345 /* HomePeopleSearchViewController.m */; };
F0DD2C721D141B0600654345 /* HomePeopleSearchViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0DD2C711D141B0600654345 /* HomePeopleSearchViewController.xib */; };
F0DD2C7B1D18386300654345 /* ContactDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0DD2C791D18386300654345 /* ContactDetailsViewController.m */; };
F0DD2C7C1D18386300654345 /* ContactDetailsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F0DD2C7A1D18386300654345 /* ContactDetailsViewController.xib */; };
F0FE6F7A1D63752A0004E747 /* CallViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0FE6F781D63752A0004E747 /* CallViewController.m */; };
Expand Down Expand Up @@ -644,6 +643,7 @@
F03DE2A41D0EFA6A00E8B65C /* AttachmentsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentsViewController.m; sourceTree = "<group>"; };
F046528B1E250B0A00EA4E77 /* ContactsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactsTableViewController.h; sourceTree = "<group>"; };
F046528C1E250B0A00EA4E77 /* ContactsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactsTableViewController.m; sourceTree = "<group>"; };
F046528E1E28439E00EA4E77 /* ContactsTableViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ContactsTableViewController.xib; sourceTree = "<group>"; };
F047DBB41C576F2200952DA2 /* AuthenticationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AuthenticationViewController.xib; sourceTree = "<group>"; };
F047DBB61C576F6600952DA2 /* AuthInputsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthInputsView.h; sourceTree = "<group>"; };
F047DBB71C576F6600952DA2 /* AuthInputsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AuthInputsView.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -892,9 +892,6 @@
F0D2D9801C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomIncomingTextMsgWithoutSenderInfoBubbleCell.h; sourceTree = "<group>"; };
F0D2D9811C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m; sourceTree = "<group>"; };
F0D2D9821C197DCB007B8C96 /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomIncomingTextMsgWithoutSenderInfoBubbleCell.xib; sourceTree = "<group>"; };
F0DD2C6E1D1308E800654345 /* HomePeopleSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomePeopleSearchViewController.h; sourceTree = "<group>"; };
F0DD2C6F1D1308E800654345 /* HomePeopleSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomePeopleSearchViewController.m; sourceTree = "<group>"; };
F0DD2C711D141B0600654345 /* HomePeopleSearchViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomePeopleSearchViewController.xib; sourceTree = "<group>"; };
F0DD2C781D18386300654345 /* ContactDetailsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactDetailsViewController.h; sourceTree = "<group>"; };
F0DD2C791D18386300654345 /* ContactDetailsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactDetailsViewController.m; sourceTree = "<group>"; };
F0DD2C7A1D18386300654345 /* ContactDetailsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ContactDetailsViewController.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1528,6 +1525,7 @@
children = (
F046528B1E250B0A00EA4E77 /* ContactsTableViewController.h */,
F046528C1E250B0A00EA4E77 /* ContactsTableViewController.m */,
F046528E1E28439E00EA4E77 /* ContactsTableViewController.xib */,
F0AC73461DA2A6130011DAEE /* RoomFilesSearchViewController.h */,
F0AC73471DA2A6130011DAEE /* RoomFilesSearchViewController.m */,
F0AC73481DA2A6130011DAEE /* RoomMessagesSearchViewController.h */,
Expand Down Expand Up @@ -1555,9 +1553,6 @@
F083C49A1D9EB13500E5246C /* HomeFilesSearchViewController.m */,
3235CD831C341FAA0084EA40 /* HomeMessagesSearchViewController.h */,
3235CD841C341FAA0084EA40 /* HomeMessagesSearchViewController.m */,
F0DD2C6E1D1308E800654345 /* HomePeopleSearchViewController.h */,
F0DD2C6F1D1308E800654345 /* HomePeopleSearchViewController.m */,
F0DD2C711D141B0600654345 /* HomePeopleSearchViewController.xib */,
32D200861C16C2B100A4E396 /* HomeViewController.h */,
32D200871C16C2B100A4E396 /* HomeViewController.m */,
F0A1CD201B9F4BBA00F9C15C /* RoomParticipantsViewController.h */,
Expand Down Expand Up @@ -1853,7 +1848,6 @@
F03BF6AF1D8BF5B1002EF6A7 /* plus_icon@3x.png in Resources */,
F03BF6C91D8BF5B1002EF6A7 /* selection_untick@2x.png in Resources */,
71046D601C0C86C600DCA984 /* RoomTitleView.xib in Resources */,
F0DD2C721D141B0600654345 /* HomePeopleSearchViewController.xib in Resources */,
F083C4681D9E9F8800E5246C /* MessagesSearchResultTextMsgBubbleCell.xib in Resources */,
F03BF6D51D8BF5B1002EF6A7 /* upload_icon@2x.png in Resources */,
F03BF6CE1D8BF5B1002EF6A7 /* shrink_icon.png in Resources */,
Expand Down Expand Up @@ -1901,6 +1895,7 @@
F0C34CB21C16269D00C36F09 /* RoomIncomingAttachmentWithPaginationTitleBubbleCell.xib in Resources */,
F083C4661D9E9F8800E5246C /* MessagesSearchResultAttachmentBubbleCell.xib in Resources */,
F03BF6731D8BF5B1002EF6A7 /* camera_switch.png in Resources */,
F046528F1E28439E00EA4E77 /* ContactsTableViewController.xib in Resources */,
F03BF64E1D8BF5B1002EF6A7 /* back_icon@3x.png in Resources */,
F083C4961D9EAFC500E5246C /* file_video_icon.png in Resources */,
F03BF6911D8BF5B1002EF6A7 /* group@3x.png in Resources */,
Expand Down Expand Up @@ -2145,7 +2140,6 @@
32A887211C89B9580037DC17 /* SimpleRoomTitleView.m in Sources */,
F056417B1C7C9FD7002276ED /* TableViewCellWithButton.m in Sources */,
F0CC4DC01C4E26FA003BBE45 /* MediaAlbumTableCell.m in Sources */,
F0DD2C701D1308E800654345 /* HomePeopleSearchViewController.m in Sources */,
F022285B1C64D529000AF23C /* ExpandedRoomTitleView.m in Sources */,
F01214D11DABD69D00755336 /* RoomFilesViewController.m in Sources */,
F0C34B671C15C28300C36F09 /* RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.m in Sources */,
Expand Down
37 changes: 29 additions & 8 deletions Vector/ViewController/ContactsTableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,31 @@
// The contact used to describe the current user.
MXKContact *userContact;

// The dictionary of the ignored local contacts, the keys are their email. Empty by default.
NSMutableDictionary<NSString*, MXKContact*> *ignoredContactsByEmail;

//The dictionary of the ignored matrix contacts, the keys are their matrix identifier. Empty by default.
NSMutableDictionary<NSString*, MXKContact*> *ignoredContactsByMatrixId;

// Search results
NSString *currentSearchText;
NSMutableArray<MXKContact*> *filteredLocalContacts;
NSMutableArray<MXKContact*> *filteredMatrixContacts;

MXKAlert *currentAlert;
}

/**
Returns the `UINib` object initialized for a `ContactsTableViewController`.
@return The initialized `UINib` object or `nil` if there were errors during initialization
or the nib file could not be located.
*/
+ (UINib *)nib;

/**
Creates and returns a new `ContactsTableViewController` object.
@discussion This is the designated initializer for programmatic instantiation.
@return An initialized `ContactsTableViewController` object if successful, `nil` otherwise.
*/
+ (instancetype)contactsTableViewController;

/**
The contacts table view.
*/
@property (weak, nonatomic) IBOutlet UITableView *tableView;

/**
Expand All @@ -73,6 +84,16 @@
*/
@property (nonatomic) BOOL forceMatrixIdInDisplayName;

/**
The dictionary of the ignored local contacts, the keys are their email. Empty by default.
*/
@property (nonatomic) NSMutableDictionary<NSString*, MXKContact*> *ignoredContactsByEmail;

/**
The dictionary of the ignored matrix contacts, the keys are their matrix identifier. Empty by default.
*/
@property (nonatomic) NSMutableDictionary<NSString*, MXKContact*> *ignoredContactsByMatrixId;

/**
Filter the contacts list, by keeping only the contacts who have the search pattern
as prefix in their display name, their matrix identifiers and/or their contact methods (emails, phones).
Expand Down
111 changes: 91 additions & 20 deletions Vector/ViewController/ContactsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import "ContactsTableViewController.h"

#import "UIViewController+VectorSearch.h"

#import "RageShakeManager.h"

#import "AppDelegate.h"
Expand All @@ -42,6 +44,20 @@ @interface ContactsTableViewController ()

@implementation ContactsTableViewController

#pragma mark - Class methods

+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([ContactsTableViewController class])
bundle:[NSBundle bundleForClass:[ContactsTableViewController class]]];
}

+ (instancetype)contactsTableViewController
{
return [[[self class] alloc] initWithNibName:NSStringFromClass([ContactsTableViewController class])
bundle:[NSBundle bundleForClass:[ContactsTableViewController class]]];
}

#pragma mark -

- (void)finalizeInit
Expand All @@ -60,8 +76,8 @@ - (void)finalizeInit
searchProcessingLocalContacts = nil;
searchProcessingMatrixContacts = nil;

ignoredContactsByEmail = [NSMutableDictionary dictionary];
ignoredContactsByMatrixId = [NSMutableDictionary dictionary];
_ignoredContactsByEmail = [NSMutableDictionary dictionary];
_ignoredContactsByMatrixId = [NSMutableDictionary dictionary];

isMultiUseNameByDisplayName = [NSMutableDictionary dictionary];

Expand All @@ -72,6 +88,16 @@ - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

// Check whether the view controller has been pushed via storyboard
if (!self.tableView)
{
// Instantiate view controller objects
[[[self class] nib] instantiateWithOwner:self options:nil];
}

// Hide line separators of empty cells
self.tableView.tableFooterView = [[UIView alloc] init];
}

- (void)didReceiveMemoryWarning
Expand All @@ -85,17 +111,11 @@ - (void)destroy
filteredLocalContacts = nil;
filteredMatrixContacts = nil;

ignoredContactsByEmail = nil;
ignoredContactsByMatrixId = nil;
_ignoredContactsByEmail = nil;
_ignoredContactsByMatrixId = nil;

userContact = nil;

if (currentAlert)
{
[currentAlert dismiss:NO];
currentAlert = nil;
}

searchProcessingQueue = nil;
searchProcessingLocalContacts = nil;
searchProcessingMatrixContacts = nil;
Expand All @@ -118,6 +138,23 @@ - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

// Screen tracking (via Google Analytics)
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];
if (tracker)
{
[tracker set:kGAIScreenName value:@"ContactsTable"];
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];
}

// Check whether the access to the local contacts has not been already asked.
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
{
// Allow by default the local contacts sync in order to discover matrix users.
// This setting change will trigger the loading of the local contacts, which will automatically
// ask user permission to access their local contacts.
[MXKAppSettings standardAppSettings].syncLocalContacts = YES;
}

// Observe kAppDelegateDidTapStatusBarNotification.
kAppDelegateDidTapStatusBarNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kAppDelegateDidTapStatusBarNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {

Expand All @@ -135,12 +172,6 @@ - (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];

if (currentAlert)
{
[currentAlert dismiss:NO];
currentAlert = nil;
}

if (kAppDelegateDidTapStatusBarNotificationObserver)
{
[[NSNotificationCenter defaultCenter] removeObserver:kAppDelegateDidTapStatusBarNotificationObserver];
Expand Down Expand Up @@ -303,7 +334,7 @@ - (void)onContactManagerDidUpdate:(NSNotification *)notif
NSArray *identifiers = contact.matrixIdentifiers;
if (identifiers.count)
{
if ([ignoredContactsByMatrixId objectForKey:identifiers.firstObject])
if ([_ignoredContactsByMatrixId objectForKey:identifiers.firstObject])
{
[unfilteredLocalContacts removeObjectAtIndex:index];
continue;
Expand All @@ -315,7 +346,7 @@ - (void)onContactManagerDidUpdate:(NSNotification *)notif
if (emails.count)
{
MXKEmail *email = emails.firstObject;
if ([ignoredContactsByEmail objectForKey:email.emailAddress])
if ([_ignoredContactsByEmail objectForKey:email.emailAddress])
{
[unfilteredLocalContacts removeObjectAtIndex:index];
continue;
Expand All @@ -342,7 +373,7 @@ - (void)onContactManagerDidUpdate:(NSNotification *)notif
{
for (NSString *userId in identifiers)
{
if ([ignoredContactsByMatrixId objectForKey:userId] == nil)
if ([_ignoredContactsByMatrixId objectForKey:userId] == nil)
{
MXKContact *splitContact = [[MXKContact alloc] initMatrixContactWithDisplayName:contact.displayName andMatrixID:userId];
[unfilteredMatrixContacts addObject:splitContact];
Expand All @@ -352,7 +383,7 @@ - (void)onContactManagerDidUpdate:(NSNotification *)notif
else if (identifiers.count)
{
NSString *userId = identifiers.firstObject;
if ([ignoredContactsByMatrixId objectForKey:userId] == nil)
if ([_ignoredContactsByMatrixId objectForKey:userId] == nil)
{
[unfilteredMatrixContacts addObject:contact];
}
Expand Down Expand Up @@ -579,4 +610,44 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - UISearchBar delegate

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
[self searchWithPattern:searchText forceReset:NO];
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
// "Done" key has been pressed.

// Check whether the current search input is a valid email or a Matrix user ID
if (currentSearchText.length && ([MXTools isEmailAddress:currentSearchText] || [MXTools isMatrixUserIdentifier:currentSearchText]))
{
// Select the contact related to the search input, rather than having to hit +
if (searchInputSection != -1)
{
[self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:searchInputSection]];
return;
}

}

// Dismiss keyboard
[searchBar resignFirstResponder];
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
searchBar.text = nil;

// Reset filtering
[self searchWithPattern:nil forceReset:NO];

// Leave search
[searchBar resignFirstResponder];

[self withdrawViewControllerAnimated:YES completion:nil];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomePeopleSearchViewController">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ContactsTableViewController">
<connections>
<outlet property="tableView" destination="orV-HH-88x" id="wUr-Sm-kc8"/>
<outlet property="view" destination="iN0-l3-epB" id="NUQ-LI-M61"/>
Expand All @@ -24,7 +24,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="HomePeopleSearchVCTableView"/>
<userDefinedRuntimeAttribute type="string" keyPath="accessibilityIdentifier" value="ContactsTableVCTableView"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="dataSource" destination="-1" id="kQG-Hx-LNM"/>
Expand Down

0 comments on commit 8efbbdf

Please sign in to comment.