mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
MESSENGER-2762 Initial Merge
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright (c) 2021 BWI GmbH
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -52,6 +53,8 @@ enum
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_TOPIC,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_TAG,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_DIRECT_CHAT,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME_INFO,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_MUTE_NOTIFICATIONS,
|
||||
ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE
|
||||
};
|
||||
@@ -62,7 +65,8 @@ enum
|
||||
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE_APART_FROM_GUEST,
|
||||
ROOM_SETTINGS_ROOM_ACCESS_SECTION_ROW_ANYONE,
|
||||
ROOM_SETTINGS_ROOM_ACCESS_DIRECTORY_VISIBILITY,
|
||||
ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING
|
||||
ROOM_SETTINGS_ROOM_ACCESS_MISSING_ADDRESS_WARNING,
|
||||
ROOM_SETTINGS_ROOM_ACCESS_BW
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -103,6 +107,7 @@ NSString *const kRoomSettingsNameKey = @"kRoomSettingsNameKey";
|
||||
NSString *const kRoomSettingsTopicKey = @"kRoomSettingsTopicKey";
|
||||
NSString *const kRoomSettingsTagKey = @"kRoomSettingsTagKey";
|
||||
NSString *const kRoomSettingsMuteNotifKey = @"kRoomSettingsMuteNotifKey";
|
||||
NSString *const kRoomSettingsWorkTimeNotifKey = @"kRoomSettingsWorkTimeNotifKey";
|
||||
NSString *const kRoomSettingsDirectChatKey = @"kRoomSettingsDirectChatKey";
|
||||
NSString *const kRoomSettingsJoinRuleKey = @"kRoomSettingsJoinRuleKey";
|
||||
NSString *const kRoomSettingsGuestAccessKey = @"kRoomSettingsGuestAccessKey";
|
||||
@@ -482,6 +487,10 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
|
||||
- (void)updateSections
|
||||
{
|
||||
if(mxRoom.isPersonalNotesRoom) {
|
||||
[self updateSectionsAsPersonalNotes];
|
||||
return;
|
||||
}
|
||||
// update local data
|
||||
// Refresh here the room addresses list.
|
||||
[roomAddresses removeAllObjects];
|
||||
@@ -529,10 +538,16 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_NAME];
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_TOPIC];
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_TAG];
|
||||
|
||||
if (RiotSettings.shared.roomSettingsScreenShowDirectChatOption)
|
||||
{
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_DIRECT_CHAT];
|
||||
}
|
||||
if (BuildSettings.featureWorkTime)
|
||||
{
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME];
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME_INFO];
|
||||
}
|
||||
if (!BuildSettings.showNotificationsV2)
|
||||
{
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_MUTE_NOTIFICATIONS];
|
||||
@@ -540,6 +555,12 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE];
|
||||
[tmpSections addObject:sectionMain];
|
||||
|
||||
if (!BuildSettings.roomSettingsScreenRemoveLeave) {
|
||||
Section *sectionLeave = [Section sectionWithTag:SECTION_TAG_MAIN];
|
||||
[sectionLeave addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE];
|
||||
[tmpSections addObject:sectionLeave];
|
||||
}
|
||||
|
||||
if (RiotSettings.shared.roomSettingsScreenAllowChangingAccessSettings)
|
||||
{
|
||||
Section *sectionAccess = [Section sectionWithTag:SECTION_TAG_ACCESS];
|
||||
@@ -573,6 +594,10 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
[tmpSections addObject:sectionAccess];
|
||||
}
|
||||
|
||||
if ( BuildSettings.roomSettingsScreenShowAccessSettingsBW && !mxRoom.isDirect ){
|
||||
[tmpSections addObject:[self sectionForAccessSwitch]];
|
||||
}
|
||||
|
||||
if (RiotSettings.shared.roomSettingsScreenAllowChangingHistorySettings)
|
||||
{
|
||||
Section *sectionHistory = [Section sectionWithTag:SECTION_TAG_HISTORY];
|
||||
@@ -2227,6 +2252,12 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
|
||||
cell = roomNotifCell;
|
||||
}
|
||||
else if( row == ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME) {
|
||||
cell = [self cellForWorkTimeSwitch:tableView indexPath:indexPath];
|
||||
}
|
||||
else if( row == ROOM_SETTINGS_MAIN_SECTION_ROW_REST_TIME_INFO) {
|
||||
cell = [self cellForWorkTimeInfo:tableView indexPath:indexPath];
|
||||
}
|
||||
else if (row == ROOM_SETTINGS_MAIN_SECTION_ROW_DIRECT_CHAT)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch *roomDirectChat = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
@@ -2440,11 +2471,11 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
{
|
||||
MXKTableViewCellWithButton *leaveCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier] forIndexPath:indexPath];
|
||||
|
||||
NSString* title = [VectorL10n leave];
|
||||
NSString* title = [VectorL10n roomParticipantsLeavePromptTitle];
|
||||
|
||||
[leaveCell.mxkButton setTitle:title forState:UIControlStateNormal];
|
||||
[leaveCell.mxkButton setTitle:title forState:UIControlStateHighlighted];
|
||||
[leaveCell.mxkButton setTintColor:ThemeService.shared.theme.tintColor];
|
||||
[leaveCell.mxkButton setTintColor:ThemeService.shared.theme.warningColor];
|
||||
leaveCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
|
||||
|
||||
[leaveCell.mxkButton removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
|
||||
@@ -2500,6 +2531,10 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.textLabel.text = [VectorL10n roomDetailsAccessSectionNoAddressWarning];
|
||||
}
|
||||
else if (row == ROOM_SETTINGS_ROOM_ACCESS_BW)
|
||||
{
|
||||
cell = [self cellForAccessSwitch:tableView indexPath:indexPath];
|
||||
}
|
||||
else
|
||||
{
|
||||
TableViewCellWithCheckBoxAndLabel *roomAccessCell = [tableView dequeueReusableCellWithIdentifier:[TableViewCellWithCheckBoxAndLabel defaultReuseIdentifier] forIndexPath:indexPath];
|
||||
@@ -4037,6 +4072,14 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
|
||||
[self refreshRoomSettings];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)singleImagePickerPresenterDidRemoveImage:(SingleImagePickerPresenter *)presenter
|
||||
{
|
||||
// This method should never be called here because room settings should not show the remove image option. But nevertheless we do a nice cleanup also for this delegate call
|
||||
[presenter dismissWithAnimated:YES completion:nil];
|
||||
self.imagePickerPresenter = nil;
|
||||
}
|
||||
|
||||
#pragma mark - TableViewSectionsDelegate
|
||||
@@ -4046,4 +4089,172 @@ NSString *const kRoomSettingsAdvancedE2eEnabledCellViewIdentifier = @"kRoomSetti
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - bwi Messenger Additions
|
||||
|
||||
- (Section*) sectionForAccessSwitch {
|
||||
Section *sectionAccess = [Section sectionWithTag:SECTION_TAG_ACCESS];
|
||||
[sectionAccess addRowWithTag:ROOM_SETTINGS_ROOM_ACCESS_BW];
|
||||
return sectionAccess;
|
||||
}
|
||||
|
||||
- (UITableViewCell*) cellForAccessSwitch:(UITableView*)tableView indexPath:(NSIndexPath*)indexPath {
|
||||
MXKTableViewCellWithLabelAndSwitch *roomAccessToggleCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
|
||||
roomAccessToggleCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_access_section_access_toggle_bw", @"Vector", nil);
|
||||
|
||||
[roomAccessToggleCell.mxkSwitch addTarget:self action:@selector(toggleDirectoryAccessBW:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
if (updatedItemsDict[kRoomSettingsDirectoryKey])
|
||||
{
|
||||
roomAccessToggleCell.mxkSwitch.on = ((NSNumber*) updatedItemsDict[kRoomSettingsDirectoryKey]).boolValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the last retrieved value if any
|
||||
roomAccessToggleCell.mxkSwitch.on = [actualDirectoryVisibility isEqualToString:kMXRoomDirectoryVisibilityPublic];
|
||||
}
|
||||
|
||||
// Store the switch to be able to update it
|
||||
directoryVisibilitySwitch = roomAccessToggleCell.mxkSwitch;
|
||||
|
||||
MXRoomPowerLevels *powerLevels = [mxRoomState powerLevels];
|
||||
|
||||
if ([powerLevels powerLevelOfUserWithUserID:self.mainSession.myUser.userId] != RoomPowerLevelAdmin) {
|
||||
directoryVisibilitySwitch.enabled = NO;
|
||||
}
|
||||
|
||||
return roomAccessToggleCell;
|
||||
}
|
||||
|
||||
- (UITableViewCell*) cellForWorkTimeSwitch:(UITableView*)tableView indexPath:(NSIndexPath*)indexPath {
|
||||
MXKTableViewCellWithLabelAndSwitch *workTimeToggleCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
|
||||
[workTimeToggleCell.mxkSwitch addTarget:self action:@selector(toggleWorkTime:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
workTimeToggleCell.mxkLabel.text = NSLocalizedStringFromTable(@"room_details_main_section_rest_time", @"Vector", nil);
|
||||
workTimeToggleCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
|
||||
workTimeToggleCell.mxkSwitch.on = [self isWorkTimeSwitchOn];
|
||||
workTimeToggleCell.mxkSwitch.enabled = [self isWorkTimeSwitchEnabled];
|
||||
|
||||
return workTimeToggleCell;
|
||||
}
|
||||
|
||||
- (UITableViewCell*) cellForWorkTimeInfo:(UITableView*)tableView indexPath:(NSIndexPath*)indexPath {
|
||||
MXKTableViewCell *workTimeInfoCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCell defaultReuseIdentifier] forIndexPath:indexPath];
|
||||
|
||||
if (!workTimeInfoCell)
|
||||
{
|
||||
workTimeInfoCell = [[MXKTableViewCell alloc] init];
|
||||
}
|
||||
|
||||
workTimeInfoCell.textLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
|
||||
workTimeInfoCell.textLabel.font = [UIFont systemFontOfSize:15.0];
|
||||
workTimeInfoCell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
workTimeInfoCell.userInteractionEnabled = NO;
|
||||
workTimeInfoCell.textLabel.text = [self textForWorkTimeInfoCell];
|
||||
workTimeInfoCell.textLabel.adjustsFontSizeToFitWidth = YES;
|
||||
|
||||
return workTimeInfoCell;
|
||||
}
|
||||
|
||||
- (void)toggleDirectoryAccessBW:(UISwitch*)theSwitch
|
||||
{
|
||||
MXRoomDirectoryVisibility visibility = theSwitch.on ? kMXRoomDirectoryVisibilityPublic : kMXRoomDirectoryVisibilityPrivate;
|
||||
|
||||
// Check whether the actual settings has been retrieved
|
||||
if (actualDirectoryVisibility)
|
||||
{
|
||||
if ([visibility isEqualToString:actualDirectoryVisibility])
|
||||
{
|
||||
[updatedItemsDict removeObjectForKey:kRoomSettingsDirectoryKey];
|
||||
[updatedItemsDict removeObjectForKey:kRoomSettingsJoinRuleKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
updatedItemsDict[kRoomSettingsDirectoryKey] = visibility;
|
||||
updatedItemsDict[kRoomSettingsJoinRuleKey] = [visibility isEqualToString:kMXRoomDirectoryVisibilityPublic] ? kMXRoomJoinRulePublic : kMXRoomJoinRuleInvite;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updatedItemsDict[kRoomSettingsDirectoryKey] = visibility;
|
||||
updatedItemsDict[kRoomSettingsJoinRuleKey] = [visibility isEqualToString:kMXRoomDirectoryVisibilityPublic] ? kMXRoomJoinRulePublic : kMXRoomJoinRuleInvite;
|
||||
}
|
||||
|
||||
[self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0);
|
||||
}
|
||||
|
||||
- (void)toggleWorkTime:(UISwitch*)theSwitch {
|
||||
NSLog(@"Toggle Worktime");
|
||||
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUser.userId];
|
||||
|
||||
updatedItemsDict[kRoomSettingsWorkTimeNotifKey] = @(theSwitch.on);
|
||||
|
||||
if (theSwitch.on) {
|
||||
[service activateWorkTimeInRoom:self.roomId];
|
||||
} else {
|
||||
[service deactivateWorkTimeInRoom:self.roomId];
|
||||
}
|
||||
|
||||
[self getNavigationItem].rightBarButtonItem.enabled = (updatedItemsDict.count != 0);
|
||||
}
|
||||
|
||||
- (NSString*) textForWorkTimeInfoCell {
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUser.userId];
|
||||
NSString *text = @"";
|
||||
|
||||
if (service.isWorkTimeGlobalyEnabled) {
|
||||
if ([service.store isWorkTimeRoom:self.roomId] ) {
|
||||
if ([service.store isWorkTimeInRoomActive:self.roomId]) {
|
||||
text = [NSString stringWithFormat:@"%@ %@", NSLocalizedStringFromTable(@"room_details_main_section_rest_time_locally_enabled", @"Vector", nil), [service localizedWorkTime]];
|
||||
} else {
|
||||
text = NSLocalizedStringFromTable(@"room_details_main_section_rest_time_locally_disabled", @"Vector", nil);
|
||||
}
|
||||
} else {
|
||||
text = [NSString stringWithFormat:@"%@ %@", NSLocalizedStringFromTable(@"room_details_main_section_rest_time_global", @"Vector", nil), [service localizedWorkTime]];
|
||||
}
|
||||
} else {
|
||||
text = NSLocalizedStringFromTable(@"room_details_main_section_rest_time_global_disabled", @"Vector", nil);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
- (BOOL) isWorkTimeSwitchOn {
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUser.userId];
|
||||
BOOL isOn = NO;
|
||||
|
||||
if (service.isWorkTimeGlobalyEnabled) {
|
||||
if ([service.store isWorkTimeRoom:self.roomId] ) {
|
||||
if ([service.store isWorkTimeInRoomActive:self.roomId]) {
|
||||
isOn = YES;
|
||||
}
|
||||
} else {
|
||||
isOn = !self->mxRoom.isDirect;
|
||||
}
|
||||
}
|
||||
|
||||
return isOn;
|
||||
}
|
||||
|
||||
- (BOOL) isWorkTimeSwitchEnabled {
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUser.userId];
|
||||
return service.isWorkTimeGlobalyEnabled;
|
||||
}
|
||||
|
||||
- (void) updateSectionsAsPersonalNotes {
|
||||
// create sections
|
||||
NSMutableArray<Section*> *tmpSections = [NSMutableArray arrayWithCapacity:SECTION_TAG_BANNED_ADVANCED + 1];
|
||||
|
||||
Section *sectionMain = [Section sectionWithTag:SECTION_TAG_MAIN];
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_PHOTO];
|
||||
[sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_NAME];
|
||||
|
||||
[tmpSections addObject:sectionMain];
|
||||
|
||||
// update sections
|
||||
self.tableViewSections.sections = tmpSections;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user