mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
RoomVC: Use cells with encryption badge only if needed in order to recover horizontal white space.
This commit is contained in:
@@ -341,7 +341,7 @@
|
||||
|
||||
CGFloat leftMargin = RoomBubbleCellLayout.reactionsViewLeftMargin;
|
||||
|
||||
if (self.room.summary.isEncrypted)
|
||||
if (roomBubbleCellData.containsBubbleComponentWithEncryptionBadge)
|
||||
{
|
||||
leftMargin+= RoomBubbleCellLayout.encryptedContentLeftMargin;
|
||||
}
|
||||
|
||||
@@ -2095,13 +2095,21 @@
|
||||
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
|
||||
{
|
||||
Class cellViewClass = nil;
|
||||
BOOL isEncryptedRoom = self.roomDataSource.room.summary.isEncrypted;
|
||||
BOOL showEncryptionBadge = NO;
|
||||
|
||||
// Sanity check
|
||||
if ([cellData conformsToProtocol:@protocol(MXKRoomBubbleCellDataStoring)])
|
||||
{
|
||||
id<MXKRoomBubbleCellDataStoring> bubbleData = (id<MXKRoomBubbleCellDataStoring>)cellData;
|
||||
|
||||
MXKRoomBubbleCellData *roomBubbleCellData;
|
||||
|
||||
if ([bubbleData isKindOfClass:MXKRoomBubbleCellData.class])
|
||||
{
|
||||
roomBubbleCellData = (MXKRoomBubbleCellData*)bubbleData;
|
||||
showEncryptionBadge = roomBubbleCellData.containsBubbleComponentWithEncryptionBadge;
|
||||
}
|
||||
|
||||
// Select the suitable table view cell class, by considering first the empty bubble cell.
|
||||
if (bubbleData.hasNoDisplay)
|
||||
{
|
||||
@@ -2159,15 +2167,15 @@
|
||||
}
|
||||
else if (bubbleData.isPaginationFirstBubble)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedAttachmentWithPaginationTitleBubbleCell.class : RoomIncomingAttachmentWithPaginationTitleBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedAttachmentWithPaginationTitleBubbleCell.class : RoomIncomingAttachmentWithPaginationTitleBubbleCell.class;
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderInformation)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedAttachmentWithoutSenderInfoBubbleCell.class : RoomIncomingAttachmentWithoutSenderInfoBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedAttachmentWithoutSenderInfoBubbleCell.class : RoomIncomingAttachmentWithoutSenderInfoBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedAttachmentBubbleCell.class : RoomIncomingAttachmentBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedAttachmentBubbleCell.class : RoomIncomingAttachmentBubbleCell.class;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2176,24 +2184,24 @@
|
||||
{
|
||||
if (bubbleData.shouldHideSenderName)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class : RoomIncomingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class : RoomIncomingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.class : RoomIncomingTextMsgWithPaginationTitleBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.class : RoomIncomingTextMsgWithPaginationTitleBubbleCell.class;
|
||||
}
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderInformation)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.class : RoomIncomingTextMsgWithoutSenderInfoBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.class : RoomIncomingTextMsgWithoutSenderInfoBubbleCell.class;
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderName)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.class : RoomIncomingTextMsgWithoutSenderNameBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.class : RoomIncomingTextMsgWithoutSenderNameBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomIncomingEncryptedTextMsgBubbleCell.class : RoomIncomingTextMsgBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomIncomingEncryptedTextMsgBubbleCell.class : RoomIncomingTextMsgBubbleCell.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2209,15 +2217,15 @@
|
||||
}
|
||||
else if (bubbleData.isPaginationFirstBubble)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedAttachmentWithPaginationTitleBubbleCell.class :RoomOutgoingAttachmentWithPaginationTitleBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedAttachmentWithPaginationTitleBubbleCell.class :RoomOutgoingAttachmentWithPaginationTitleBubbleCell.class;
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderInformation)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.class : RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.class : RoomOutgoingAttachmentWithoutSenderInfoBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedAttachmentBubbleCell.class : RoomOutgoingAttachmentBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedAttachmentBubbleCell.class : RoomOutgoingAttachmentBubbleCell.class;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2226,24 +2234,24 @@
|
||||
{
|
||||
if (bubbleData.shouldHideSenderName)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class : RoomOutgoingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class : RoomOutgoingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.class : RoomOutgoingTextMsgWithPaginationTitleBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.class : RoomOutgoingTextMsgWithPaginationTitleBubbleCell.class;
|
||||
}
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderInformation)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.class :RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.class :RoomOutgoingTextMsgWithoutSenderInfoBubbleCell.class;
|
||||
}
|
||||
else if (bubbleData.shouldHideSenderName)
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.class : RoomOutgoingTextMsgWithoutSenderNameBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.class : RoomOutgoingTextMsgWithoutSenderNameBubbleCell.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellViewClass = isEncryptedRoom ? RoomOutgoingEncryptedTextMsgBubbleCell.class : RoomOutgoingTextMsgBubbleCell.class;
|
||||
cellViewClass = showEncryptionBadge ? RoomOutgoingEncryptedTextMsgBubbleCell.class : RoomOutgoingTextMsgBubbleCell.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,11 @@ extern NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon;
|
||||
@interface RoomEncryptedDataBubbleCell : NSObject
|
||||
|
||||
/**
|
||||
Return the icon displayed in front an event in an encrypted room .
|
||||
Return the icon displayed in front of an event in an encrypted room if needed.
|
||||
|
||||
@param event the event.
|
||||
@param session the matrix session
|
||||
@param event the bubble component.
|
||||
*/
|
||||
+ (UIImage*)encryptionIconForEvent:(MXEvent*)event andSession:(MXSession*)session;
|
||||
+ (UIImage*)encryptionIconForBubbleComponent:(MXKRoomBubbleComponent *)bubbleComponent;
|
||||
|
||||
/**
|
||||
Set the encryption status icon in front of each bubble component.
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
+3
-2
@@ -43,7 +43,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,4 +62,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@end
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@
|
||||
MXKRoomBubbleComponent *component = bubbleData.bubbleComponents.firstObject;
|
||||
if (component)
|
||||
{
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,4 +62,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -163,7 +163,7 @@
|
||||
{
|
||||
// Set the right device info icon
|
||||
self.encryptionStatusView.hidden = NO;
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
|
||||
self.encryptionStatusView.image = [RoomEncryptedDataBubbleCell encryptionIconForBubbleComponent:component];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user