diff --git a/CHANGES.rst b/CHANGES.rst index 15f800fb6..1da2402d8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,7 @@ Changes to be released in next version * RoomVC: Enable / Disable VoIP feature in Rooms (#4236). * UnifiedSearchRecentsDataSource: Show/Hide public directory (#4242). * DirectoryRecentTableViewCell: Do not use "directory_search_results_more_than" string when there is no rooms and the search is on. + * RoomVC: Show / Hide integrations and actions (#4245). 🐛 Bugfix * PublicRoomsDirectoryDataSource: Fix search when NSFW filter is off. diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index de586d02d..4eea378f5 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -262,6 +262,14 @@ final class BuildSettings: NSObject { static let roomScreenAllowVoIPForDirectRoom: Bool = true static let roomScreenAllowVoIPForNonDirectRoom: Bool = true + static let roomScreenAllowCameraAction: Bool = false + static let roomScreenAllowMediaLibraryAction: Bool = false + static let roomScreenAllowStickerAction: Bool = true + static let roomScreenAllowFilesAction: Bool = true + + // MARK: - Room Info Screen + + static let roomInfoScreenShowIntegrations: Bool = false // MARK: - Room Settings Screen diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 390a9301b..cdb06c773 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -58,6 +58,11 @@ final class RiotSettings: NSObject { static let homeScreenShowCommunitiesTab = "homeScreenShowCommunitiesTab" static let roomScreenAllowVoIPForDirectRoom = "roomScreenAllowVoIPForDirectRoom" static let roomScreenAllowVoIPForNonDirectRoom = "roomScreenAllowVoIPForNonDirectRoom" + static let roomScreenAllowCameraAction = "roomScreenAllowCameraAction" + static let roomScreenAllowMediaLibraryAction = "roomScreenAllowMediaLibraryAction" + static let roomScreenAllowStickerAction = "roomScreenAllowStickerAction" + static let roomScreenAllowFilesAction = "roomScreenAllowFilesAction" + static let roomInfoScreenShowIntegrations = "roomInfoScreenShowIntegrations" static let unifiedSearchScreenShowPublicDirectory = "unifiedSearchScreenShowPublicDirectory" } @@ -271,6 +276,59 @@ final class RiotSettings: NSObject { defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowVoIPForNonDirectRoom) } } + var roomScreenAllowCameraAction: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowCameraAction) != nil else { + return BuildSettings.roomScreenAllowCameraAction + } + return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowCameraAction) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowCameraAction) + } + } + var roomScreenAllowMediaLibraryAction: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowMediaLibraryAction) != nil else { + return BuildSettings.roomScreenAllowMediaLibraryAction + } + return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowMediaLibraryAction) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowMediaLibraryAction) + } + } + var roomScreenAllowStickerAction: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowStickerAction) != nil else { + return BuildSettings.roomScreenAllowStickerAction + } + return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowStickerAction) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowStickerAction) + } + } + var roomScreenAllowFilesAction: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.roomScreenAllowFilesAction) != nil else { + return BuildSettings.roomScreenAllowFilesAction + } + return defaults.bool(forKey: UserDefaultsKeys.roomScreenAllowFilesAction) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.roomScreenAllowFilesAction) + } + } + + // MARK: - Room Info Screen + + var roomInfoScreenShowIntegrations: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.roomInfoScreenShowIntegrations) != nil else { + return BuildSettings.roomInfoScreenShowIntegrations + } + return defaults.bool(forKey: UserDefaultsKeys.roomInfoScreenShowIntegrations) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.roomInfoScreenShowIntegrations) + } + } // MARK: - Room Creation Screen diff --git a/Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewController.swift b/Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewController.swift index 67a75586a..bfc3396bf 100644 --- a/Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewController.swift +++ b/Riot/Modules/Room/RoomInfo/RoomInfoList/RoomInfoListViewController.swift @@ -164,12 +164,17 @@ final class RoomInfoListViewController: UIViewController { self.viewModel.process(viewAction: .navigate(target: .integrations)) } + var rows = [rowSettings] + if (RiotSettings.shared.roomInfoScreenShowIntegrations) + { + rows.append(rowIntegrations) + } + rows.append(rowMembers) + rows.append(rowUploads) + rows.append(rowSearch) + let sectionSettings = Section(header: VectorL10n.roomInfoListSectionOther, - rows: [rowSettings, - rowIntegrations, - rowMembers, - rowUploads, - rowSearch], + rows: rows, footer: nil) let leaveTitle = viewData.basicInfoViewData.isDirect ? diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 10eabeb65..294d123ed 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1731,36 +1731,48 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; RoomInputToolbarView *roomInputView = ((RoomInputToolbarView *) self.inputToolbarView); MXWeakify(self); - roomInputView.actionsBar.actionItems = @[ - [[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_camera"] andAction:^{ + NSMutableArray *actionItems = [NSMutableArray new]; + if (RiotSettings.shared.roomScreenAllowCameraAction) + { + [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_camera"] andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; } [self showCameraControllerAnimated:YES]; - }], - [[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_media_library"] andAction:^{ + }]]; + } + if (RiotSettings.shared.roomScreenAllowMediaLibraryAction) + { + [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_media_library"] andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; } [self showMediaPickerAnimated:YES]; - }], - [[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_sticker"] andAction:^{ + }]]; + } + if (RiotSettings.shared.roomScreenAllowStickerAction) + { + [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_sticker"] andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; } [self roomInputToolbarViewPresentStickerPicker]; - }], - [[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_file"] andAction:^{ + }]]; + } + if (RiotSettings.shared.roomScreenAllowFilesAction) + { + [actionItems addObject:[[RoomActionItem alloc] initWithImage:[UIImage imageNamed:@"action_file"] andAction:^{ MXStrongifyAndReturnIfNil(self); if ([self.inputToolbarView isKindOfClass:RoomInputToolbarView.class]) { ((RoomInputToolbarView *) self.inputToolbarView).actionMenuOpened = NO; } [self roomInputToolbarViewDidTapFileUpload]; - }], - ]; + }]]; + } + roomInputView.actionsBar.actionItems = actionItems; } - (void)roomInputToolbarViewPresentStickerPicker