RoomVC: Use cells with encryption badge only if needed in order to recover horizontal white space.

This commit is contained in:
SBiOSoftWhare
2020-02-06 18:46:32 +01:00
parent 523c0716a0
commit 558f3853be
11 changed files with 46 additions and 77 deletions
@@ -21,53 +21,14 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt
@implementation RoomEncryptedDataBubbleCell
+ (UIImage*)encryptionIconForEvent:(MXEvent*)event andSession:(MXSession*)session
+ (UIImage*)encryptionIconForBubbleComponent:(MXKRoomBubbleComponent *)bubbleComponent
{
MXRoom *room = [session roomWithRoomId:event.roomId];
BOOL isRoomEncrypted = room.summary.isEncrypted && session.crypto;
if (!isRoomEncrypted)
if (!bubbleComponent.showEncryptionBadge)
{
return nil;
}
NSString *encryptionIconName;
UIImage* encryptionIcon;
if (!event.isEncrypted)
{
if (event.isLocalEvent
|| event.isState
|| event.contentHasBeenEdited) // Local echo for an edit is clear but uses a true event id, the one of the edited event
{
encryptionIconName = nil;
}
else
{
encryptionIconName = @"encryption_warning";
}
}
else if (event.decryptionError)
{
encryptionIconName = @"encryption_warning";
}
else if (event.sender)
{
MXUserTrustLevel *userTrustLevel = [session.crypto trustLevelForUser:event.sender];
MXDeviceInfo *deviceInfo = [session.crypto eventDeviceInfo:event];
if (userTrustLevel.isVerified && !deviceInfo.trustLevel.isVerified)
{
encryptionIconName = @"encryption_warning";
}
}
if (encryptionIconName)
{
encryptionIcon = [UIImage imageNamed:encryptionIconName];
}
return encryptionIcon;
return [UIImage imageNamed:@"encryption_warning"];
}
+ (void)addEncryptionStatusFromBubbleData:(MXKRoomBubbleCellData *)bubbleData inContainerView:(UIView *)containerView
@@ -93,8 +54,8 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt
{
continue;
}
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImage *icon = [[self class] encryptionIconForBubbleComponent:component];
if (icon)
{
@@ -111,7 +72,7 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt
encryptStatusImageView.tag = componentIndex;
[containerView addSubview:encryptStatusImageView];
}
}
}
}