mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Merge branch 'feature/5203_us01_add_federation_room_overview' into 'develop'
Feature/5203 us01 add federation room overview See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!244
This commit is contained in:
@@ -36,6 +36,7 @@ class BWIBuildSettings: NSObject {
|
||||
|
||||
private enum UserDefaultsKeys {
|
||||
static let additionalBwiHeaderKey = "bwiHeader"
|
||||
static let isFederationEnabled = "isFederationEnabled"
|
||||
}
|
||||
|
||||
private struct BwiSettingsConstants {
|
||||
@@ -690,6 +691,10 @@ class BWIBuildSettings: NSObject {
|
||||
var showContentScannerStatusWithFilename = true
|
||||
|
||||
// MARK: Federation
|
||||
@UserDefault(key: UserDefaultsKeys.isFederationEnabled, defaultValue: false, storage: RiotSettings.defaults)
|
||||
var isFederationEnabled
|
||||
|
||||
// shows the grey/green/red shield for the room avatar / user avatar
|
||||
var showEncryptionStatusBadgeOnAvatar = false
|
||||
|
||||
}
|
||||
|
||||
2
Podfile
2
Podfile
@@ -43,7 +43,7 @@ when String # specific MatrixSDK released version
|
||||
$matrixSDKVersionSpec = $matrixSDKVersion
|
||||
end
|
||||
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v2.12.0-BWI02' }
|
||||
$matrixSDKVersionSpec = { :git => 'https://dl-gitlab.example.com/bwmessenger/bundesmessenger/bundesmessenger-ios-sdk', :tag => 'v2.12.0-RC03' }
|
||||
|
||||
# Method to import the MatrixSDK
|
||||
def import_MatrixSDK
|
||||
|
||||
12
Riot/Assets/Images.xcassets/BWI/room_federated_bum_icon_dark.imageset/Contents.json
vendored
Normal file
12
Riot/Assets/Images.xcassets/BWI/room_federated_bum_icon_dark.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "room_federated_bum_icon_dark.svg",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg width="23" height="18" viewBox="0 0 23 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8.6" cy="8.6" r="8.6" fill="#15191E"/>
|
||||
<circle cx="14" cy="8.6" r="8.6" fill="#15191E"/>
|
||||
<ellipse cx="14" cy="8.60156" rx="6" ry="6" fill="white"/>
|
||||
<circle cx="8.6" cy="8.6" r="7.6" fill="#15191E"/>
|
||||
<ellipse cx="8.60004" cy="8.60156" rx="6" ry="6" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 378 B |
12
Riot/Assets/Images.xcassets/BWI/room_federated_bum_icon_light.imageset/Contents.json
vendored
Normal file
12
Riot/Assets/Images.xcassets/BWI/room_federated_bum_icon_light.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "room_federated_bum_icon_light.svg",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg width="23" height="18" viewBox="0 0 23 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8.6" cy="8.6" r="8.6" fill="white"/>
|
||||
<circle cx="14" cy="8.6" r="8.6" fill="white"/>
|
||||
<ellipse cx="14" cy="8.60156" rx="6" ry="6" fill="#17191C"/>
|
||||
<circle cx="8.59995" cy="8.59922" r="7.4" fill="white"/>
|
||||
<ellipse cx="8.60004" cy="8.60156" rx="6" ry="6" fill="#17191C"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 384 B |
@@ -63,6 +63,9 @@
|
||||
"bwi_settings_developer_key_backup_etag" = "ETag";
|
||||
"bwi_settings_developer_key_backup_version" = "Version";
|
||||
|
||||
// MARK: Labor
|
||||
"bwi_settings_labs_federation_feature" = "Föderation";
|
||||
|
||||
// MARK: - MDM
|
||||
|
||||
"bwi_mdm_logout_message" = "Die Konfiguration hat sich geändert. Bitte melde dich neu an.";
|
||||
|
||||
@@ -64,6 +64,9 @@
|
||||
"bwi_settings_developer_key_backup_etag" = "ETag";
|
||||
"bwi_settings_developer_key_backup_version" = "Version";
|
||||
|
||||
// MARK: Lab
|
||||
"bwi_settings_labs_federation_feature" = "Federation";
|
||||
|
||||
// MARK: - MDM
|
||||
|
||||
"bwi_mdm_logout_message" = "The configuration has changed. Please reconnect.";
|
||||
|
||||
@@ -631,6 +631,10 @@ public class BWIL10n: NSObject {
|
||||
public static var bwiSettingsIgnoredUsersText: String {
|
||||
return BWIL10n.tr("Bwi", "bwi_settings_ignored_users_text")
|
||||
}
|
||||
/// Föderation
|
||||
public static var bwiSettingsLabsFederationFeature: String {
|
||||
return BWIL10n.tr("Bwi", "bwi_settings_labs_federation_feature")
|
||||
}
|
||||
/// Netiquette
|
||||
public static var bwiSettingsNetiquette: String {
|
||||
return BWIL10n.tr("Bwi", "bwi_settings_netiquette")
|
||||
|
||||
@@ -35,4 +35,7 @@
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *lastEventDecriptionLabelTrailingConstraint;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *unsentImageView;
|
||||
|
||||
@property (nonatomic) UIImage *federationImage;
|
||||
@property (nonatomic) UIImageView *federationImageView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -38,6 +38,31 @@
|
||||
// Initialize unread count badge
|
||||
[_missedNotifAndUnreadBadgeBgView.layer setCornerRadius:10];
|
||||
_missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = 0;
|
||||
|
||||
// bwi: 5203 add federation icon
|
||||
if ([ThemeService.shared isCurrentThemeDark])
|
||||
{
|
||||
self.federationImage = AssetImages.roomFederatedBumIconDark.image;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImage = AssetImages.roomFederatedBumIconLight.image;
|
||||
}
|
||||
self.federationImageView = [[UIImageView alloc] initWithImage:self.federationImage];
|
||||
self.federationImageView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
self.federationImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.contentView addSubview:self.federationImageView];
|
||||
|
||||
// scale and new with federation icon
|
||||
float scaleFactor = ((self.roomAvatar.frame.size.height * 0.34) / self.federationImage.size.height);
|
||||
float imageWidth = scaleFactor * self.federationImage.size.width;
|
||||
// offset federation icon
|
||||
float offset = 3 * scaleFactor;
|
||||
|
||||
[self.federationImageView.bottomAnchor constraintEqualToAnchor:self.roomAvatar.bottomAnchor constant:0].active = YES;
|
||||
[self.federationImageView.trailingAnchor constraintEqualToAnchor:self.roomAvatar.trailingAnchor constant:offset].active = YES;
|
||||
[self.federationImageView.heightAnchor constraintEqualToConstant:(self.roomAvatar.frame.size.height * 0.34)].active = YES;
|
||||
[self.federationImageView.widthAnchor constraintEqualToConstant:imageWidth].active = YES;
|
||||
}
|
||||
|
||||
- (void)customizeTableViewCellRendering
|
||||
@@ -61,6 +86,17 @@
|
||||
// Round image view
|
||||
[_roomAvatar.layer setCornerRadius:_roomAvatar.frame.size.width / 2];
|
||||
_roomAvatar.clipsToBounds = YES;
|
||||
|
||||
// bwi: 5203 add federation icon
|
||||
if ([ThemeService.shared isCurrentThemeDark])
|
||||
{
|
||||
self.federationImage = AssetImages.roomFederatedBumIconDark.image;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImage = AssetImages.roomFederatedBumIconLight.image;
|
||||
}
|
||||
self.federationImageView.image = self.federationImage;
|
||||
}
|
||||
|
||||
- (void)render:(MXKCellData *)cellData
|
||||
@@ -74,6 +110,43 @@
|
||||
roomCellData = (id<MXKRecentCellDataStoring>)cellData;
|
||||
if (roomCellData)
|
||||
{
|
||||
|
||||
// bwi: 5203 add federation icon
|
||||
if (BWIBuildSettings.shared.isFederationEnabled)
|
||||
{
|
||||
MXRoom *room = [roomCellData.mxSession roomWithRoomId:roomCellData.roomSummary.roomId];
|
||||
if (room.isPersonalNotesRoom)
|
||||
{
|
||||
self.federationImageView.hidden = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (room.isDirect)
|
||||
{
|
||||
if (room.isDMFederated)
|
||||
{
|
||||
self.federationImageView.hidden = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImageView.hidden = YES;
|
||||
}
|
||||
}
|
||||
else if (room.isRoomFederated)
|
||||
{
|
||||
self.federationImageView.hidden = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImageView.hidden = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.federationImageView.hidden = YES;
|
||||
}
|
||||
|
||||
// Report computed values as is
|
||||
self.roomTitle.text = roomCellData.roomDisplayname;
|
||||
self.lastEventDate.text = roomCellData.lastEventDate;
|
||||
|
||||
@@ -234,7 +234,8 @@ typedef NS_ENUM(NSUInteger, LABS_ENABLE)
|
||||
LABS_ENABLE_NEW_SESSION_MANAGER,
|
||||
LABS_ENABLE_NEW_CLIENT_INFO_FEATURE,
|
||||
LABS_ENABLE_WYSIWYG_COMPOSER,
|
||||
LABS_ENABLE_VOICE_BROADCAST
|
||||
LABS_ENABLE_VOICE_BROADCAST,
|
||||
LABS_ENABLE_FEDERATION
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SECURITY)
|
||||
@@ -828,6 +829,10 @@ SSOAuthenticationPresenterDelegate>
|
||||
{
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_VOICE_BROADCAST];
|
||||
*/
|
||||
|
||||
// bwi: #5203 add federation feature
|
||||
[sectionLabs addRowWithTag:LABS_ENABLE_FEDERATION];
|
||||
|
||||
sectionLabs.headerTitle = [VectorL10n settingsLabs];
|
||||
if (sectionLabs.hasAnyRows)
|
||||
{
|
||||
@@ -3033,6 +3038,20 @@ SSOAuthenticationPresenterDelegate>
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
// bwi: #5203 add federation feature
|
||||
else if (row == LABS_ENABLE_FEDERATION)
|
||||
{
|
||||
MXKTableViewCellWithLabelAndSwitch *labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
|
||||
|
||||
labelAndSwitchCell.mxkLabel.text = [BWIL10n bwiSettingsLabsFederationFeature];
|
||||
labelAndSwitchCell.mxkSwitch.on = BWIBuildSettings.shared.isFederationEnabled;
|
||||
labelAndSwitchCell.mxkSwitch.thumbTintColor = ThemeService.shared.theme.backgroundColor;
|
||||
labelAndSwitchCell.mxkSwitch.onTintColor = ThemeService.shared.theme.tintColor;
|
||||
|
||||
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleEnableFederationFeature:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
cell = labelAndSwitchCell;
|
||||
}
|
||||
|
||||
else if (row == LABS_ENABLE_VOICE_BROADCAST)
|
||||
{
|
||||
@@ -3974,6 +3993,12 @@ SSOAuthenticationPresenterDelegate>
|
||||
RiotSettings.shared.roomScreenUseOnlyLatestUserAvatarAndName = sender.isOn;
|
||||
}
|
||||
|
||||
// bwi: #5203 add federation feature
|
||||
- (void)toggleEnableFederationFeature:(UISwitch *)sender
|
||||
{
|
||||
BWIBuildSettings.shared.isFederationEnabled = sender.isOn;
|
||||
}
|
||||
|
||||
- (void)markAllAsRead:(id)sender
|
||||
{
|
||||
// Feedback: disable button and run activity indicator
|
||||
|
||||
82
bwi/Federation/MXRoom+Federation.swift
Normal file
82
bwi/Federation/MXRoom+Federation.swift
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2023 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import MatrixSDK
|
||||
|
||||
@objc extension MXRoom {
|
||||
|
||||
func isRoomFederated() -> Bool {
|
||||
var isFederated: Bool = true
|
||||
state { state in
|
||||
// Search for federate flag. If the flag is not found, default value is true
|
||||
if let events = state?.stateEvents(with: .roomCreate) {
|
||||
for event in events {
|
||||
if let federateContentValue = event.wireContent["m.federate"] {
|
||||
isFederated = federateContentValue as? Bool ?? true
|
||||
}
|
||||
}
|
||||
}
|
||||
if isFederated {
|
||||
// Check Server ACLs
|
||||
if let events = state?.stateEvents(with: .roomServerACL) {
|
||||
let myUserId = self.mxSession.myUser.userId ?? ""
|
||||
let myUserIdComponents = myUserId.components(separatedBy: ":")
|
||||
for event in events {
|
||||
if let allowedServerList = event.wireContent["allow"] as? [String] {
|
||||
if allowedServerList.count == 1 {
|
||||
if allowedServerList[0] != "*" && myUserIdComponents.count == 2 && allowedServerList[0] == myUserIdComponents.last ?? "" {
|
||||
isFederated = false
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFederated
|
||||
}
|
||||
|
||||
func isDMFederated() -> Bool {
|
||||
var isFederated: Bool = true
|
||||
state { state in
|
||||
// Search for federate flag. If the flag is not found, default value is true
|
||||
if let events = state?.stateEvents(with: .roomCreate) {
|
||||
for event in events {
|
||||
if let federateContentValue = event.wireContent["m.federate"] {
|
||||
isFederated = federateContentValue as? Bool ?? true
|
||||
}
|
||||
}
|
||||
}
|
||||
if isFederated {
|
||||
// Check if the user is from the same homeserver
|
||||
if let memberUserId = self.directUserId {
|
||||
if let myUserId = self.mxSession.myUser.userId {
|
||||
let memberUserIdComponents = memberUserId.components(separatedBy: ":")
|
||||
let myUserIdComponents = myUserId.components(separatedBy: ":")
|
||||
if memberUserIdComponents.count == 2 && myUserIdComponents.count == 2
|
||||
&& memberUserIdComponents.last == myUserIdComponents.last {
|
||||
isFederated = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFederated
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user