mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Merge branch 'develop' into riot_2924
# Conflicts: # Riot/Modules/Room/DataSources/RoomDataSource.m
This commit is contained in:
commit
17fb117329
11 changed files with 187 additions and 99 deletions
|
@ -5,6 +5,7 @@ Improvements:
|
|||
* ON/OFF Cross-signing development in a Lab setting (#2855).
|
||||
* RoomVC: Update encryption decoration with shields (#2934, #2930, #2906).
|
||||
* Settings: Remove "End-to-End Encryption" from the LABS section (#2941).
|
||||
* Room decoration: Use shields instead of padlocks (#2906).
|
||||
|
||||
Changes in 0.10.4 (2019-12-11)
|
||||
===============================================
|
||||
|
|
|
@ -266,6 +266,7 @@ NSString *const AppDelegateDidValidateEmailNotificationClientSecretKey = @"AppDe
|
|||
// Set the App Group identifier.
|
||||
MXSDKOptions *sdkOptions = [MXSDKOptions sharedInstance];
|
||||
sdkOptions.applicationGroupIdentifier = @"group.im.vector";
|
||||
sdkOptions.computeE2ERoomSummaryTrust = YES;
|
||||
|
||||
// Redirect NSLogs to files only if we are not debugging
|
||||
if (!isatty(STDERR_FILENO))
|
||||
|
|
|
@ -16,6 +16,17 @@
|
|||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
/**
|
||||
RoomEncryptionTrustLevel represents the trust level in an encrypted room.
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, RoomEncryptionTrustLevel) {
|
||||
RoomEncryptionTrustLevelTrusted,
|
||||
RoomEncryptionTrustLevelWarning,
|
||||
RoomEncryptionTrustLevelNormal,
|
||||
RoomEncryptionTrustLevelUnknown
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Define a `MXRoomSummary` category at Riot level.
|
||||
*/
|
||||
|
@ -32,4 +43,11 @@
|
|||
*/
|
||||
- (void)setRoomAvatarImageIn:(MXKImageView*)mxkImageView;
|
||||
|
||||
/**
|
||||
Get the trust level in the room.
|
||||
|
||||
@return the trust level.
|
||||
*/
|
||||
- (RoomEncryptionTrustLevel)roomEncryptionTrustLevel;
|
||||
|
||||
@end
|
||||
|
|
|
@ -47,4 +47,31 @@
|
|||
mxkImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
|
||||
- (RoomEncryptionTrustLevel)roomEncryptionTrustLevel
|
||||
{
|
||||
RoomEncryptionTrustLevel roomEncryptionTrustLevel = RoomEncryptionTrustLevelUnknown;
|
||||
if (self.trust)
|
||||
{
|
||||
double trustedDevicesPercentage = self.trust.trustedDevicesProgress.fractionCompleted;
|
||||
|
||||
if (trustedDevicesPercentage >= 1.0
|
||||
|| self.trust.trustedDevicesProgress.totalUnitCount == 0)
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelTrusted;
|
||||
}
|
||||
else if (trustedDevicesPercentage == 0.0)
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelNormal;
|
||||
}
|
||||
else
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelWarning;
|
||||
}
|
||||
|
||||
roomEncryptionTrustLevel = roomEncryptionTrustLevel;
|
||||
}
|
||||
|
||||
return roomEncryptionTrustLevel;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -137,7 +137,15 @@ static const CGFloat kDirectRoomBorderWidth = 3.0;
|
|||
|
||||
self.directRoomBorderView.hidden = !roomCellData.roomSummary.room.isDirect;
|
||||
|
||||
self.encryptedRoomIcon.hidden = !roomCellData.roomSummary.isEncrypted;
|
||||
if (roomCellData.roomSummary.isEncrypted)
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = NO;
|
||||
self.encryptedRoomIcon.image = [self shieldImageForTrustLevel:roomCellData.roomSummary.roomEncryptionTrustLevel];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = YES;
|
||||
}
|
||||
|
||||
[roomCellData.roomSummary setRoomAvatarImageIn:self.roomAvatar];
|
||||
}
|
||||
|
@ -153,4 +161,32 @@ static const CGFloat kDirectRoomBorderWidth = 3.0;
|
|||
return 74;
|
||||
}
|
||||
|
||||
- (UIImage*)shieldImageForTrustLevel:(RoomEncryptionTrustLevel)roomEncryptionTrustLevel
|
||||
{
|
||||
UIImage *shieldImage;
|
||||
|
||||
NSString *encryptionIconName;
|
||||
switch (roomEncryptionTrustLevel)
|
||||
{
|
||||
case RoomEncryptionTrustLevelWarning:
|
||||
encryptionIconName = @"encryption_warning";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelNormal:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelTrusted:
|
||||
encryptionIconName = @"encryption_trusted";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelUnknown:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
}
|
||||
|
||||
if (encryptionIconName)
|
||||
{
|
||||
shieldImage = [UIImage imageNamed:encryptionIconName];
|
||||
}
|
||||
return shieldImage;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
@ -75,10 +75,10 @@
|
|||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OeZ-wN-eil">
|
||||
<rect key="frame" x="524" y="14" width="0.0" height="20"/>
|
||||
<rect key="frame" x="524" y="13.5" width="0.0" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mbn-A1-1Yw">
|
||||
<rect key="frame" x="-4" y="2" width="9" height="17"/>
|
||||
<rect key="frame" x="-4.5" y="1.5" width="9" height="17"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="MissedNotifAndUnreadBadge"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
|
@ -94,11 +94,11 @@
|
|||
</constraints>
|
||||
</view>
|
||||
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="e2e_verified" translatesAutoresizingMaskIntoConstraints="NO" id="NAZ-zd-MHS">
|
||||
<rect key="frame" x="50" y="42" width="11" height="13"/>
|
||||
<rect key="frame" x="44" y="43" width="16" height="16"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="EncryptedRoomIcon"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="13" id="QdE-73-LyZ"/>
|
||||
<constraint firstAttribute="width" constant="11" id="i9u-Bs-pBy"/>
|
||||
<constraint firstAttribute="height" constant="16" id="QdE-73-LyZ"/>
|
||||
<constraint firstAttribute="width" constant="16" id="i9u-Bs-pBy"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
</subviews>
|
||||
|
@ -112,11 +112,11 @@
|
|||
<constraint firstItem="dQt-mN-T6b" firstAttribute="leading" secondItem="RX5-eD-c3c" secondAttribute="trailing" constant="14" id="XFM-LG-4uJ"/>
|
||||
<constraint firstItem="360-Go-RcG" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="16" id="XyO-tl-6SX"/>
|
||||
<constraint firstAttribute="trailing" secondItem="360-Go-RcG" secondAttribute="trailing" constant="10" id="YqC-WC-Wqe"/>
|
||||
<constraint firstItem="NAZ-zd-MHS" firstAttribute="centerY" secondItem="dQt-mN-T6b" secondAttribute="centerY" id="c6L-cn-sJL"/>
|
||||
<constraint firstItem="NAZ-zd-MHS" firstAttribute="centerY" secondItem="dQt-mN-T6b" secondAttribute="centerY" constant="2" id="c6L-cn-sJL"/>
|
||||
<constraint firstItem="OeZ-wN-eil" firstAttribute="centerY" secondItem="360-Go-RcG" secondAttribute="centerY" id="fYc-th-Nay"/>
|
||||
<constraint firstItem="dQt-mN-T6b" firstAttribute="top" secondItem="Lg1-xQ-AGn" secondAttribute="bottom" constant="4" id="iaT-57-GOs"/>
|
||||
<constraint firstItem="RX5-eD-c3c" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="15" id="mga-fG-I0L"/>
|
||||
<constraint firstItem="NAZ-zd-MHS" firstAttribute="leading" secondItem="aXz-IR-jj5" secondAttribute="leading" constant="50" id="ofi-HP-uke"/>
|
||||
<constraint firstItem="NAZ-zd-MHS" firstAttribute="leading" secondItem="aXz-IR-jj5" secondAttribute="leading" constant="44" id="ofi-HP-uke"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dQt-mN-T6b" secondAttribute="trailing" constant="10" id="t2m-pb-5zd"/>
|
||||
<constraint firstItem="Lg1-xQ-AGn" firstAttribute="top" secondItem="aXz-IR-jj5" secondAttribute="top" constant="14" id="tY3-6V-A3B"/>
|
||||
<constraint firstItem="RX5-eD-c3c" firstAttribute="leading" secondItem="aXz-IR-jj5" secondAttribute="leading" constant="13" id="tgy-cX-Wxm"/>
|
||||
|
|
|
@ -159,7 +159,15 @@ static const CGFloat kDirectRoomBorderWidth = 3.0;
|
|||
|
||||
self.directRoomBorderView.hidden = !roomCellData.roomSummary.room.isDirect;
|
||||
|
||||
self.encryptedRoomIcon.hidden = !roomCellData.roomSummary.isEncrypted;
|
||||
if (roomCellData.roomSummary.isEncrypted)
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = NO;
|
||||
self.encryptedRoomIcon.image = [self shieldImageForTrustLevel:roomCellData.roomSummary.roomEncryptionTrustLevel];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = YES;
|
||||
}
|
||||
|
||||
[roomCellData.roomSummary setRoomAvatarImageIn:self.roomAvatar];
|
||||
}
|
||||
|
@ -207,5 +215,33 @@ static const CGFloat kDirectRoomBorderWidth = 3.0;
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (UIImage*)shieldImageForTrustLevel:(RoomEncryptionTrustLevel)roomEncryptionTrustLevel
|
||||
{
|
||||
UIImage *shieldImage;
|
||||
|
||||
NSString *encryptionIconName;
|
||||
switch (roomEncryptionTrustLevel)
|
||||
{
|
||||
case RoomEncryptionTrustLevelWarning:
|
||||
encryptionIconName = @"encryption_warning";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelNormal:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelTrusted:
|
||||
encryptionIconName = @"encryption_trusted";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelUnknown:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
}
|
||||
|
||||
if (encryptionIconName)
|
||||
{
|
||||
shieldImage = [UIImage imageNamed:encryptionIconName];
|
||||
}
|
||||
return shieldImage;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
@ -39,7 +38,7 @@
|
|||
<rect key="frame" x="80" y="5" width="0.0" height="20"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZUZ-tv-dVV">
|
||||
<rect key="frame" x="-4" y="2" width="9" height="17"/>
|
||||
<rect key="frame" x="-4.5" y="1.5" width="9" height="17"/>
|
||||
<accessibility key="accessibilityConfiguration" identifier="MissedNotifAndUnreadBadge"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
|
@ -55,10 +54,10 @@
|
|||
</constraints>
|
||||
</view>
|
||||
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="e2e_verified" translatesAutoresizingMaskIntoConstraints="NO" id="5Yd-df-HbB">
|
||||
<rect key="frame" x="53" y="55" width="15" height="18"/>
|
||||
<rect key="frame" x="48" y="50" width="24" height="24"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="UEZ-5S-KMf"/>
|
||||
<constraint firstAttribute="width" constant="15" id="bbS-D2-SZi"/>
|
||||
<constraint firstAttribute="height" constant="24" id="UEZ-5S-KMf"/>
|
||||
<constraint firstAttribute="width" constant="24" id="bbS-D2-SZi"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="RoomTitle" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oxX-IL-dG4">
|
||||
|
@ -93,7 +92,7 @@
|
|||
</subviews>
|
||||
</view>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="5Yd-df-HbB" secondAttribute="trailing" constant="12" id="0gr-xn-dfD"/>
|
||||
<constraint firstAttribute="trailing" secondItem="5Yd-df-HbB" secondAttribute="trailing" constant="8" id="0gr-xn-dfD"/>
|
||||
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="oxX-IL-dG4" secondAttribute="bottom" constant="5" id="1JB-d1-zb9"/>
|
||||
<constraint firstItem="oxX-IL-dG4" firstAttribute="top" secondItem="T1Q-RS-8o6" secondAttribute="bottom" constant="4" id="2DB-H2-E2v"/>
|
||||
<constraint firstAttribute="bottom" secondItem="jta-3V-4wL" secondAttribute="bottom" id="3rt-Ig-1rG"/>
|
||||
|
@ -108,7 +107,7 @@
|
|||
<constraint firstItem="T1Q-RS-8o6" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="10" id="cc7-bg-15Z"/>
|
||||
<constraint firstItem="Jkz-Zp-aaG" firstAttribute="leading" secondItem="eCk-zY-LXq" secondAttribute="leading" constant="7" id="fPh-Lb-Bv9"/>
|
||||
<constraint firstItem="xws-BR-H47" firstAttribute="centerY" secondItem="T1Q-RS-8o6" secondAttribute="centerY" id="faX-hg-WfP"/>
|
||||
<constraint firstItem="5Yd-df-HbB" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="55" id="h4R-2d-Xxn"/>
|
||||
<constraint firstItem="5Yd-df-HbB" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="50" id="h4R-2d-Xxn"/>
|
||||
<constraint firstAttribute="trailing" secondItem="oxX-IL-dG4" secondAttribute="trailing" constant="4" id="hDl-X9-M4n"/>
|
||||
<constraint firstItem="T1Q-RS-8o6" firstAttribute="centerX" secondItem="eCk-zY-LXq" secondAttribute="centerX" id="hmB-fl-oN2"/>
|
||||
<constraint firstItem="Q6g-b0-3sZ" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="5" id="jST-Ic-lsn"/>
|
||||
|
|
|
@ -19,15 +19,7 @@
|
|||
|
||||
#import "WidgetManager.h"
|
||||
|
||||
/**
|
||||
RoomEncryptionTrustLevel represents the room members trust level in an encrypted room.
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, RoomEncryptionTrustLevel) {
|
||||
RoomEncryptionTrustLevelTrusted,
|
||||
RoomEncryptionTrustLevelWarning,
|
||||
RoomEncryptionTrustLevelNormal,
|
||||
RoomEncryptionTrustLevelUnknown
|
||||
};
|
||||
#import "MXRoomSummary+Riot.h"
|
||||
|
||||
@protocol RoomDataSourceDelegate;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
NSLog(@"[MXKRoomDataSource] finalizeRoomDataSource: Cannot retrieve all room members");
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
if (self.room.summary.isEncrypted)
|
||||
{
|
||||
[self fetchEncryptionTrustedLevel];
|
||||
|
@ -193,85 +193,27 @@
|
|||
|
||||
- (void)registerTrustLevelDidChangeNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceInfoTrustLevelDidChange:) name:MXDeviceInfoTrustLevelDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(crossSigningInfoTrustLevelDidChange:) name:MXCrossSigningInfoTrustLevelDidChangeNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(roomSummaryDidChange:) name:kMXRoomSummaryDidChangeNotification object:self.room.summary];
|
||||
}
|
||||
|
||||
- (void)deviceInfoTrustLevelDidChange:(NSNotification*)notification
|
||||
{
|
||||
MXDeviceInfo *deviceInfo = notification.object;
|
||||
|
||||
NSString *userId = deviceInfo.userId;
|
||||
|
||||
if (userId)
|
||||
{
|
||||
[self encryptionTrustLevelDidChangeRelatedToUserId:userId];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)crossSigningInfoTrustLevelDidChange:(NSNotification*)notification
|
||||
{
|
||||
MXCrossSigningInfo *crossSigningInfo = notification.object;
|
||||
|
||||
NSString *userId = crossSigningInfo.userId;
|
||||
|
||||
if (userId)
|
||||
{
|
||||
[self encryptionTrustLevelDidChangeRelatedToUserId:userId];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fetchEncryptionTrustedLevel
|
||||
{
|
||||
[self encryptionTrustLevelDidChangeRelatedToUserId:self.mxSession.myUser.userId];
|
||||
}
|
||||
|
||||
- (void)encryptionTrustLevelDidChangeRelatedToUserId:(NSString*)userId
|
||||
- (void)roomSummaryDidChange:(NSNotification*)notification
|
||||
{
|
||||
if (!self.room.summary.isEncrypted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[self.room members:^(MXRoomMembers *roomMembers) {
|
||||
MXRoomMember *roomMember = [roomMembers memberWithUserId:userId];
|
||||
|
||||
// If user belongs to the room refresh the trust level
|
||||
if (roomMember)
|
||||
{
|
||||
[self.room membersTrustLevelSummaryWithForceDownload:NO
|
||||
success:^(MXUsersTrustLevelSummary *usersTrustLevelSummary) {
|
||||
|
||||
RoomEncryptionTrustLevel roomEncryptionTrustLevel;
|
||||
|
||||
double trustedDevicesPercentage = usersTrustLevelSummary.trustedDevicesProgress.fractionCompleted;
|
||||
|
||||
if (trustedDevicesPercentage >= 1.0)
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelTrusted;
|
||||
}
|
||||
else if (trustedDevicesPercentage == 0.0)
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelNormal;
|
||||
}
|
||||
else
|
||||
{
|
||||
roomEncryptionTrustLevel = RoomEncryptionTrustLevelWarning;
|
||||
}
|
||||
|
||||
self.encryptionTrustLevel = roomEncryptionTrustLevel;
|
||||
[self.roomDataSourceDelegate roomDataSource:self didUpdateEncryptionTrustLevel:roomEncryptionTrustLevel];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"[RoomDataSource] trustLevelDidChangeRelatedToUserId fails to retrieve room members trusted progress");
|
||||
}];
|
||||
}
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
NSLog(@"[RoomDataSource] trustLevelDidChangeRelatedToUserId fails to retrieve room members");
|
||||
}];
|
||||
[self fetchEncryptionTrustedLevel];
|
||||
}
|
||||
|
||||
- (void)fetchEncryptionTrustedLevel
|
||||
{
|
||||
self.encryptionTrustLevel = self.room.summary.roomEncryptionTrustLevel;
|
||||
[self.roomDataSourceDelegate roomDataSource:self didUpdateEncryptionTrustLevel:self.encryptionTrustLevel];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
|
|
|
@ -71,7 +71,15 @@
|
|||
|
||||
self.directRoomBorderView.hidden = !roomCellData.roomSummary.isDirect;
|
||||
|
||||
self.encryptedRoomIcon.hidden = !roomCellData.roomSummary.isEncrypted;
|
||||
if (roomCellData.roomSummary.isEncrypted)
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = NO;
|
||||
self.encryptedRoomIcon.image = [self shieldImageForTrustLevel:roomCellData.roomSummary.roomEncryptionTrustLevel];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.encryptedRoomIcon.hidden = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,4 +88,32 @@
|
|||
return 74;
|
||||
}
|
||||
|
||||
- (UIImage*)shieldImageForTrustLevel:(RoomEncryptionTrustLevel)roomEncryptionTrustLevel
|
||||
{
|
||||
UIImage *shieldImage;
|
||||
|
||||
NSString *encryptionIconName;
|
||||
switch (roomEncryptionTrustLevel)
|
||||
{
|
||||
case RoomEncryptionTrustLevelWarning:
|
||||
encryptionIconName = @"encryption_warning";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelNormal:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelTrusted:
|
||||
encryptionIconName = @"encryption_trusted";
|
||||
break;
|
||||
case RoomEncryptionTrustLevelUnknown:
|
||||
encryptionIconName = @"encryption_normal";
|
||||
break;
|
||||
}
|
||||
|
||||
if (encryptionIconName)
|
||||
{
|
||||
shieldImage = [UIImage imageNamed:encryptionIconName];
|
||||
}
|
||||
return shieldImage;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue