Bug Fix - Chat screen: the vertical offset on encryption icon due to the timestamp

This commit is contained in:
giomfo 2016-11-16 15:36:35 +01:00
parent 1a9c93bd74
commit 2315fa0608
23 changed files with 118 additions and 251 deletions

View file

@ -100,6 +100,28 @@ NSString *const kMXKRoomBubbleCellVectorEditButtonPressed = @"kMXKRoomBubbleCell
// Available on iOS 8 and later
[NSLayoutConstraint activateConstraints:@[rightConstraint, topConstraint, widthConstraint, heightConstraint]];
// Check whether a vertical whitespace was applied to display correctly the timestamp.
if (componentIndex || bubbleData.shouldHideSenderInformation || bubbleData.shouldHideSenderName)
{
// Adjust the position of the potential encryption icon in this case.
if (self.encryptionStatusContainerView)
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
// Note: The encryption icon has been tagged with the component index.
if (view.tag == componentIndex)
{
CGRect frame = view.frame;
frame.origin.y += 15;
view.frame = frame;
break;
}
}
}
}
}
}

View file

@ -36,6 +36,14 @@ extern NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon;
*/
+ (UIImage*)encryptionIconForEvent:(MXEvent*)event andSession:(MXSession*)session;
/**
Set the encryption status icon in front of each bubble component.
@param bubbleData the bubble cell data
@param containerView the container view in which the icons will be added.
*/
+ (void)addEncryptionStatusFromBubbleData:(MXKRoomBubbleCellData *)bubbleData inContainerView:(UIView *)containerView;
@end

View file

@ -77,4 +77,39 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt
return [UIImage imageNamed:encryptionIcon];
}
+ (void)addEncryptionStatusFromBubbleData:(MXKRoomBubbleCellData *)bubbleData inContainerView:(UIView *)containerView
{
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [containerView subviews];
for (UIView* view in views)
{
[view removeFromSuperview];
}
NSArray *bubbleComponents = bubbleData.bubbleComponents;
MXKRoomBubbleComponent *component;
for (NSUInteger componentIndex; componentIndex < bubbleComponents.count; componentIndex++)
{
component = bubbleComponents[componentIndex];
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = containerView.frame.size.width / 2;
encryptStatusImageView.center = center;
encryptStatusImageView.tag = componentIndex;
[containerView addSubview:encryptStatusImageView];
}
}
@end

View file

@ -21,6 +21,4 @@
*/
@interface RoomIncomingEncryptedTextMsgBubbleCell : RoomIncomingTextMsgBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,38 +40,13 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];

View file

@ -21,6 +21,4 @@
*/
@interface RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell : RoomIncomingTextMsgWithPaginationTitleBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,34 +40,21 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];
}
[super didEndDisplay];
}
#pragma mark - User actions
- (IBAction)onEncryptionIconTap:(UITapGestureRecognizer*)sender

View file

@ -21,6 +21,4 @@
*/
@interface RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell : RoomIncomingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,34 +40,21 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];
}
[super didEndDisplay];
}
#pragma mark - User actions
- (IBAction)onEncryptionIconTap:(UITapGestureRecognizer*)sender

View file

@ -21,6 +21,4 @@
*/
@interface RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell : RoomIncomingTextMsgWithoutSenderInfoBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,34 +40,21 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];
}
[super didEndDisplay];
}
#pragma mark - User actions
- (IBAction)onEncryptionIconTap:(UITapGestureRecognizer*)sender

View file

@ -21,6 +21,4 @@
*/
@interface RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell : RoomIncomingTextMsgWithoutSenderNameBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,34 +40,21 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];
}
[super didEndDisplay];
}
#pragma mark - User actions
- (IBAction)onEncryptionIconTap:(UITapGestureRecognizer*)sender

View file

@ -21,6 +21,4 @@
*/
@interface RoomOutgoingEncryptedTextMsgBubbleCell : RoomOutgoingTextMsgBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,38 +40,13 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];

View file

@ -21,6 +21,4 @@
*/
@interface RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell : RoomOutgoingTextMsgWithPaginationTitleBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -71,7 +71,6 @@
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];

View file

@ -21,6 +21,4 @@
*/
@interface RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell : RoomOutgoingTextMsgWithPaginationTitleWithoutSenderNameBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,38 +40,13 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];

View file

@ -21,6 +21,4 @@
*/
@interface RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell : RoomOutgoingTextMsgWithoutSenderInfoBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,38 +40,13 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];

View file

@ -21,6 +21,4 @@
*/
@interface RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell : RoomOutgoingTextMsgWithoutSenderNameBubbleCell
@property (weak, nonatomic) IBOutlet UIView *encryptionStatusContainerView;
@end

View file

@ -40,38 +40,13 @@
if (bubbleData)
{
// Set the right device info icon in front of each event
// Ensure that older subviews are removed
// They should be (they are removed when the cell is not anymore used).
// But, it seems that is not always true.
NSArray* views = [self.encryptionStatusContainerView subviews];
for(UIView* view in views)
{
[view removeFromSuperview];
}
for (MXKRoomBubbleComponent *component in bubbleData.bubbleComponents)
{
UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession];
UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon];
CGRect frame = encryptStatusImageView.frame;
frame.origin.y = component.position.y + 3;
encryptStatusImageView.frame = frame;
CGPoint center = encryptStatusImageView.center;
center.x = self.encryptionStatusContainerView.frame.size.width / 2;
encryptStatusImageView.center = center;
[self.encryptionStatusContainerView addSubview:encryptStatusImageView];
}
[RoomEncryptedDataBubbleCell addEncryptionStatusFromBubbleData:bubbleData inContainerView:self.encryptionStatusContainerView];
}
}
- (void)didEndDisplay
{
NSArray* subviews = self.encryptionStatusContainerView.subviews;
for (UIView *view in subviews)
{
[view removeFromSuperview];