Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rearrange room info sections and actions.
Signed-off-by: Ivan Sein <[email protected]>
  • Loading branch information
Ivansss committed Jul 22, 2019
commit f159d9471d5f777ad27dc895f0eb032df16b24b5
1 change: 1 addition & 0 deletions VideoCalls/NCSettingsController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern NSString * const kCapabilitySystemMessages;
extern NSString * const kCapabilityMentionFlag;
extern NSString * const kCapabilityNotificationLevels;
extern NSString * const kCapabilityLockedOneToOneRooms;
extern NSString * const kCapabilityWebinaryLobby;

extern NSInteger const kDefaultChatMaxLength;

Expand Down
1 change: 1 addition & 0 deletions VideoCalls/NCSettingsController.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ @implementation NCSettingsController
NSString * const kCapabilityMentionFlag = @"mention-flag";
NSString * const kCapabilityNotificationLevels = @"notification-levels";
NSString * const kCapabilityLockedOneToOneRooms = @"locked-one-to-one-rooms";
NSString * const kCapabilityWebinaryLobby = @"webinary-lobby";

NSInteger const kDefaultChatMaxLength = 1000;

Expand Down
199 changes: 156 additions & 43 deletions VideoCalls/RoomInfoTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@
typedef enum RoomInfoSection {
kRoomInfoSectionName = 0,
kRoomInfoSectionActions,
kRoomInfoSectionPublic,
kRoomInfoSectionWebinar,
kRoomInfoSectionParticipants,
kRoomInfoSectionDestructive,
kRoomInfoSections
kRoomInfoSectionDestructive
} RoomInfoSection;

typedef enum RoomAction {
kRoomActionFavorite = 0,
kRoomActionNotifications,
kRoomActionPublicToggle,
kRoomActionPassword,
kRoomActionSendLink
} RoomAction;

typedef enum PublicAction {
kPublicActionPublicToggle = 0,
kPublicActionPassword
} PublicAction;

typedef enum WebinarAction {
kWebinarActionLobby = 0,
kWebinarActionLobbyTimer,
kWebinarActions
kWebinarActionLobbyTimer
} WebinarAction;

typedef enum DestructiveAction {
Expand Down Expand Up @@ -152,11 +154,43 @@ - (void)getRoomParticipants
{
[[NCAPIController sharedInstance] getParticipantsFromRoom:_room.token withCompletionBlock:^(NSMutableArray *participants, NSError *error) {
_roomParticipants = participants;
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(kRoomInfoSectionParticipants, 1)] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([self getSectionForRoomInfoSection:kRoomInfoSectionParticipants], 1)] withRowAnimation:UITableViewRowAnimationNone];
[self removeModifyingRoomUI];
}];
}

- (NSArray *)getRoomInfoSections
{
NSMutableArray *sections = [[NSMutableArray alloc] init];
// Room name section
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionName]];
// Room actions section
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionActions]];
// Moderator sections
if (_room.canModerate) {
// Public room section
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionPublic]];
// Webinar section
if (_room.type != kNCRoomTypeOneToOne && [[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityWebinaryLobby]) {
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionWebinar]];
}
}
// Participants section
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionParticipants]];
// Destructive actions section
[sections addObject:[NSNumber numberWithInt:kRoomInfoSectionDestructive]];
return [NSArray arrayWithArray:sections];
}

- (NSInteger)getSectionForRoomInfoSection:(RoomInfoSection)section
{
NSInteger sectionNumber = [[self getRoomInfoSections] indexOfObject:[NSNumber numberWithInt:section]];
if(NSNotFound != sectionNumber) {
return sectionNumber;
}
return 0;
}

- (NSArray *)getRoomActions
{
NSMutableArray *actions = [[NSMutableArray alloc] init];
Expand All @@ -169,13 +203,7 @@ - (NSArray *)getRoomActions
[actions addObject:[NSNumber numberWithInt:kRoomActionNotifications]];
}
// Public room actions
if (_room.canModerate) {
[actions addObject:[NSNumber numberWithInt:kRoomActionPublicToggle]];
if (_room.isPublic) {
[actions addObject:[NSNumber numberWithInt:kRoomActionPassword]];
[actions addObject:[NSNumber numberWithInt:kRoomActionSendLink]];
}
} else if (_room.isPublic) {
if (_room.isPublic) {
[actions addObject:[NSNumber numberWithInt:kRoomActionSendLink]];
}
return [NSArray arrayWithArray:actions];
Expand All @@ -191,6 +219,30 @@ - (NSIndexPath *)getIndexPathForRoomAction:(RoomAction)action
return actionIndexPath;
}

- (NSArray *)getPublicActions
{
NSMutableArray *actions = [[NSMutableArray alloc] init];
// Public room toggle
[actions addObject:[NSNumber numberWithInt:kPublicActionPublicToggle]];
// Password protection
if (_room.isPublic) {
[actions addObject:[NSNumber numberWithInt:kPublicActionPassword]];
}
return [NSArray arrayWithArray:actions];
}

- (NSArray *)getWebinarActions
{
NSMutableArray *actions = [[NSMutableArray alloc] init];
// Lobby toggle
[actions addObject:[NSNumber numberWithInt:kWebinarActionLobby]];
// Lobby timer
if (_room.lobbyState == NCRoomLobbyStateModeratorsOnly) {
[actions addObject:[NSNumber numberWithInt:kWebinarActionLobbyTimer]];
}
return [NSArray arrayWithArray:actions];
}

- (NSArray *)getRoomDestructiveActions
{
NSMutableArray *actions = [[NSMutableArray alloc] init];
Expand Down Expand Up @@ -577,7 +629,7 @@ - (void)deleteRoom
}];
}

#pragma mark - Participant options
#pragma mark - Webinar options

- (void)enableLobby
{
Expand Down Expand Up @@ -785,18 +837,24 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return kRoomInfoSections;
return [self getRoomInfoSections].count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection infoSection = [[sections objectAtIndex:section] intValue];
switch (infoSection) {
case kRoomInfoSectionActions:
return [self getRoomActions].count;
break;

case kRoomInfoSectionPublic:
return [self getPublicActions].count;
break;

case kRoomInfoSectionWebinar:
return kWebinarActions;
return [self getWebinarActions].count;
break;

case kRoomInfoSectionParticipants:
Expand All @@ -806,27 +864,53 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
case kRoomInfoSectionDestructive:
return [self getRoomDestructiveActions].count;
break;
default:
break;
}

return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection infoSection = [[sections objectAtIndex:indexPath.section] intValue];
switch (infoSection) {
case kRoomInfoSectionName:
return 80;
break;
case kRoomInfoSectionParticipants:
return kContactsTableCellHeight;
break;
default:
break;
}
return 48;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection infoSection = [[sections objectAtIndex:section] intValue];
switch (infoSection) {
case kRoomInfoSectionPublic:
return @"Guests";
break;
case kRoomInfoSectionWebinar:
return @"Webinar";
break;
default:
break;
}

return nil;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
switch (section) {
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection infoSection = [[sections objectAtIndex:section] intValue];
switch (infoSection) {
case kRoomInfoSectionParticipants:
{
NSString *title = [NSString stringWithFormat:@"%lu participants", (unsigned long)_roomParticipants.count];
Expand All @@ -838,6 +922,8 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
return _headerView;
}
break;
default:
break;
}

return nil;
Expand All @@ -849,6 +935,10 @@ - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteg
case kRoomInfoSectionActions:
return 10;
break;
case kRoomInfoSectionPublic:
case kRoomInfoSectionWebinar:
return 36;
break;
case kRoomInfoSectionParticipants:
return 40;
break;
Expand All @@ -869,7 +959,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
static NSString *leaveRoomCellIdentifier = @"LeaveRoomCellIdentifier";
static NSString *deleteRoomCellIdentifier = @"DeleteRoomCellIdentifier";

switch (indexPath.section) {
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection section = [[sections objectAtIndex:indexPath.section] intValue];
switch (section) {
case kRoomInfoSectionName:
{
RoomNameTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kRoomNameCellIdentifier];
Expand Down Expand Up @@ -965,7 +1057,28 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
return cell;
}
break;
case kRoomActionPublicToggle:
case kRoomActionSendLink:
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:sendLinkCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:sendLinkCellIdentifier];
}

cell.textLabel.text = @"Send conversation link";
[cell.imageView setImage:[UIImage imageNamed:@"share-settings"]];

return cell;
}
break;
}
}
break;
case kRoomInfoSectionPublic:
{
NSArray *actions = [self getPublicActions];
PublicAction action = [[actions objectAtIndex:indexPath.row] intValue];
switch (action) {
case kPublicActionPublicToggle:
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:shareLinkCellIdentifier];
if (!cell) {
Expand All @@ -982,7 +1095,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}
break;

case kRoomActionPassword:
case kPublicActionPassword:
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:passwordCellIdentifier];
if (!cell) {
Expand All @@ -992,20 +1105,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textLabel.text = (_room.hasPassword) ? @"Change password" : @"Set password";
[cell.imageView setImage:(_room.hasPassword) ? [UIImage imageNamed:@"privacy"] : [UIImage imageNamed:@"no-password-settings"]];

return cell;
}
break;

case kRoomActionSendLink:
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:sendLinkCellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:sendLinkCellIdentifier];
}

cell.textLabel.text = @"Send conversation link";
[cell.imageView setImage:[UIImage imageNamed:@"share-settings"]];

return cell;
}
break;
Expand All @@ -1014,7 +1113,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
break;
case kRoomInfoSectionWebinar:
{
switch (indexPath.row) {
NSArray *actions = [self getWebinarActions];
WebinarAction action = [[actions objectAtIndex:indexPath.row] intValue];
switch (action) {
case kWebinarActionLobby:
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:lobbyCellIdentifier];
Expand Down Expand Up @@ -1133,7 +1234,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
NSArray *sections = [self getRoomInfoSections];
RoomInfoSection section = [[sections objectAtIndex:indexPath.section] intValue];
switch (section) {
case kRoomInfoSectionName:
break;
case kRoomInfoSectionActions:
Expand All @@ -1151,17 +1254,27 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
case kRoomActionNotifications:
[self presentNotificationLevelSelector];
break;
case kRoomActionPublicToggle:
case kRoomActionSendLink:
[self shareRoomLink];
break;
case kRoomActionPassword:
}
}
break;
case kRoomInfoSectionPublic:
{
NSArray *actions = [self getPublicActions];
PublicAction action = [[actions objectAtIndex:indexPath.row] intValue];
switch (action) {
case kPublicActionPassword:
[self showPasswordOptions];
break;
case kRoomActionSendLink:
[self shareRoomLink];
default:
break;
}
}
break;
case kRoomInfoSectionWebinar:
break;
case kRoomInfoSectionParticipants:
{
NCRoomParticipant *participant = [_roomParticipants objectAtIndex:indexPath.row];
Expand Down