Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read receipts details #1341

Merged
merged 14 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Riot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
24B5103E1EFA7083004C6AD2 /* ReadReceiptsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */; };
24B510401EFA88CC004C6AD2 /* ReadReceiptsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */; };
3205ED7D1E976C8A003D65FA /* DirectoryServerPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3205ED7C1E976C8A003D65FA /* DirectoryServerPickerViewController.m */; };
3205ED841E97725E003D65FA /* DirectoryServerTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3205ED821E97725E003D65FA /* DirectoryServerTableViewCell.m */; };
3205ED851E97725E003D65FA /* DirectoryServerTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3205ED831E97725E003D65FA /* DirectoryServerTableViewCell.xib */; };
Expand Down Expand Up @@ -471,6 +473,9 @@

/* Begin PBXFileReference section */
1129C74A281B080432B1A1A1 /* Pods-Riot.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Riot.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Riot/Pods-Riot.debug.xcconfig"; sourceTree = "<group>"; };
24B5103C1EFA7083004C6AD2 /* ReadReceiptsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadReceiptsViewController.h; sourceTree = "<group>"; };
24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReadReceiptsViewController.m; sourceTree = "<group>"; };
24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReadReceiptsViewController.xib; sourceTree = "<group>"; };
3205ED7B1E976C8A003D65FA /* DirectoryServerPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryServerPickerViewController.h; sourceTree = "<group>"; };
3205ED7C1E976C8A003D65FA /* DirectoryServerPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryServerPickerViewController.m; sourceTree = "<group>"; };
3205ED811E97725E003D65FA /* DirectoryServerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryServerTableViewCell.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1585,6 +1590,9 @@
F083BC541E7009EC00A9B29C /* StartChatViewController.xib */,
F083BC551E7009EC00A9B29C /* UsersDevicesViewController.h */,
F083BC561E7009EC00A9B29C /* UsersDevicesViewController.m */,
24B5103C1EFA7083004C6AD2 /* ReadReceiptsViewController.h */,
24B5103D1EFA7083004C6AD2 /* ReadReceiptsViewController.m */,
24B5103F1EFA88CC004C6AD2 /* ReadReceiptsViewController.xib */,
);
path = ViewController;
sourceTree = "<group>";
Expand Down Expand Up @@ -2041,6 +2049,7 @@
F083BD881E7009ED00A9B29C /* [email protected] in Resources */,
F083BDAB1E7009ED00A9B29C /* [email protected] in Resources */,
F083BE4D1E7009ED00A9B29C /* RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.xib in Resources */,
24B510401EFA88CC004C6AD2 /* ReadReceiptsViewController.xib in Resources */,
F083BDC81E7009ED00A9B29C /* search_icon.png in Resources */,
F083BDE91E7009ED00A9B29C /* ring.mp3 in Resources */,
F083BE431E7009ED00A9B29C /* RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.xib in Resources */,
Expand Down Expand Up @@ -2405,7 +2414,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find the reason of this change on shellScript. Which pod version are you using? FYI we use 1.2.1.
Discard this change from your PR if this is simple for you. Don't waste time on this, I can handle it on my side.

showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -2457,6 +2466,7 @@
F083BE761E7009ED00A9B29C /* RoomOutgoingTextMsgWithPaginationTitleBubbleCell.m in Sources */,
F083BE5A1E7009ED00A9B29C /* RoomIncomingAttachmentBubbleCell.m in Sources */,
F083BE541E7009ED00A9B29C /* RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m in Sources */,
24B5103E1EFA7083004C6AD2 /* ReadReceiptsViewController.m in Sources */,
F083BE621E7009ED00A9B29C /* RoomIncomingTextMsgWithoutSenderInfoBubbleCell.m in Sources */,
F083BE881E7009ED00A9B29C /* RoomMemberTitleView.m in Sources */,
F083BE701E7009ED00A9B29C /* RoomOutgoingTextMsgBubbleCell.m in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@
"room_details_copy_room_address" = "Copy Room Address";
"room_details_copy_room_url" = "Copy Room URL";

// Read Receipts
"read_receipts_list" = "Read Receipts List";
"receipt_status_read" = "Read: ";

// Media picker
"media_picker_library" = "Library";
"media_picker_select" = "Select";
Expand Down
12 changes: 12 additions & 0 deletions Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
*/
extern NSString *const kMXKRoomBubbleCellRiotEditButtonPressed;

/**
Action identifier used when the user tapped on receipts area.

The 'userInfo' disctionary contains an 'MXKReceiptSendersContainer' object under the 'kMXKRoomBubbleCellReceiptsContainerKey' key, representing the receipts container which was tapped on.
*/
extern NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer;

/**
Define a `MXKRoomBubbleTableViewCell` category at Riot level to handle bubble customisation.
*/
Expand Down Expand Up @@ -56,6 +63,11 @@ extern NSString *const kMXKRoomBubbleCellRiotEditButtonPressed;
*/
- (void)addDateLabel;

/**
Called when the user taps on the Receipt Container.
*/
- (IBAction)onReceiptContainerTap:(UITapGestureRecognizer *)sender;

/**
Blur the view by adding a transparent overlay. Default is NO.
*/
Expand Down
18 changes: 15 additions & 3 deletions Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_WIDTH 4

NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRiotEditButtonPressed";
NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer = @"kMXKRoomBubbleCellTapOnReceiptsContainer";

@implementation MXKRoomBubbleTableViewCell (Riot)

Expand Down Expand Up @@ -146,7 +147,7 @@ - (void)selectComponent:(NSUInteger)componentIndex

// Retrieve the read receipts container related to the selected component (if any)
// Blur the others
for (UIView* view in self.bubbleOverlayContainer.subviews)
for (UIView* view in self.tmpSubviews)
{
// Note read receipt container tag is equal to the index of the related component.
if (view.tag != componentIndex)
Expand Down Expand Up @@ -305,11 +306,14 @@ - (void)setBlurred:(BOOL)blurred
self.bubbleOverlayContainer.alpha = 0.8;
self.bubbleOverlayContainer.userInteractionEnabled = YES;

// Blur read receipts if any
// Blur subviews if any
for (UIView* view in self.bubbleOverlayContainer.subviews)
{
view.alpha = 0.2;
}

// Move this view in front
[self.contentView bringSubviewToFront:self.bubbleOverlayContainer];
}
else
{
Expand All @@ -320,7 +324,7 @@ - (void)setBlurred:(BOOL)blurred
self.bubbleOverlayContainer.alpha = 1;
self.bubbleOverlayContainer.userInteractionEnabled = NO;

// Restore read receipts display
// Restore subviews display
for (UIView* view in self.bubbleOverlayContainer.subviews)
{
view.alpha = 1;
Expand Down Expand Up @@ -388,6 +392,14 @@ - (IBAction)onEditButtonPressed:(id)sender
}
}

- (IBAction)onReceiptContainerTap:(UITapGestureRecognizer *)sender
{
if (self.delegate)
{
[self.delegate cell:self didRecognizeAction:kMXKRoomBubbleCellTapOnReceiptsContainer userInfo:@{kMXKRoomBubbleCellReceiptsContainerKey : sender.view}];
}
}

#pragma mark - Internals

- (void)addEditButtonForComponent:(NSUInteger)componentIndex completion:(void (^ __nullable)(BOOL finished))completion
Expand Down
36 changes: 27 additions & 9 deletions Riot/Model/Room/RoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
// Ignore the read receipts on the bubble without actual display.
if ((self.showBubbleReceipts && cellData.hasReadReceipts) || self.showReadMarker)
{
// Read receipts container are inserted here on the right side into the overlay container.
// Read receipts container are inserted here on the right side into the content view.
// Some vertical whitespaces are added in message text view (see RoomBubbleCellData class) to insert correctly multiple receipts.
bubbleCell.bubbleOverlayContainer.backgroundColor = [UIColor clearColor];
bubbleCell.bubbleOverlayContainer.alpha = 1;
bubbleCell.bubbleOverlayContainer.userInteractionEnabled = NO;
bubbleCell.bubbleOverlayContainer.hidden = NO;

NSInteger index = bubbleComponents.count;
CGFloat bottomPositionY = bubbleCell.frame.size.height;
while (index--)
Expand Down Expand Up @@ -199,10 +194,26 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
avatarsContainer.tag = index;

[avatarsContainer refreshReceiptSenders:roomMembers withPlaceHolders:placeholders andAlignment:ReadReceiptAlignmentRight];
avatarsContainer.readReceipts = receipts;
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:cell action:@selector(onReceiptContainerTap:)];
[tapRecognizer setNumberOfTapsRequired:1];
[tapRecognizer setNumberOfTouchesRequired:1];
[avatarsContainer addGestureRecognizer:tapRecognizer];
avatarsContainer.userInteractionEnabled = YES;

avatarsContainer.translatesAutoresizingMaskIntoConstraints = NO;
avatarsContainer.accessibilityIdentifier = @"readReceiptsContainer";
[bubbleCell.bubbleOverlayContainer addSubview:avatarsContainer];

// Add this read receipts container in the content view
if (!bubbleCell.tmpSubviews)
{
bubbleCell.tmpSubviews = [NSMutableArray arrayWithArray:@[avatarsContainer]];
}
else
{
[bubbleCell.tmpSubviews addObject:avatarsContainer];
}
[bubbleCell.contentView addSubview:avatarsContainer];

// Force receipts container size
NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:avatarsContainer
Expand All @@ -224,14 +235,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSLayoutConstraint *trailingConstraint = [NSLayoutConstraint constraintWithItem:avatarsContainer
attribute:NSLayoutAttributeTrailing
relatedBy:NSLayoutRelationEqual
toItem:bubbleCell.bubbleOverlayContainer
toItem:avatarsContainer.superview
attribute:NSLayoutAttributeTrailing
multiplier:1.0
constant:-6];
NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:avatarsContainer
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:bubbleCell.bubbleOverlayContainer
toItem:avatarsContainer.superview
attribute:NSLayoutAttributeTop
multiplier:1.0
constant:bottomPositionY - 13];
Expand All @@ -244,6 +255,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
// Check whether the read marker must be displayed here.
if (self.showReadMarker)
{
// The read marker is added into the overlay container.
// CAUTION: Keep disabled the user interaction on this container to not disturb tap gesture handling.
bubbleCell.bubbleOverlayContainer.backgroundColor = [UIColor clearColor];
bubbleCell.bubbleOverlayContainer.alpha = 1;
bubbleCell.bubbleOverlayContainer.userInteractionEnabled = NO;
bubbleCell.bubbleOverlayContainer.hidden = NO;

if ([component.event.eventId isEqualToString:self.room.accountData.readMarkerEventId])
{
bubbleCell.readMarkerView = [[UIView alloc] initWithFrame:CGRectMake(0, bottomPositionY - 2, bubbleCell.bubbleOverlayContainer.frame.size.width, 2)];
Expand Down
24 changes: 24 additions & 0 deletions Riot/ViewController/ReadReceiptsViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 Aram Sargsyan

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 <UIKit/UIKit.h>
#import <MatrixKit/MatrixKit.h>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use forward declaration rather than import everything


@interface ReadReceiptsViewController : MXKViewController

+ (void)openInViewController:(UIViewController *)viewController fromContainer:(MXKReceiptSendersContainer *)receiptSendersContainer withSession:(MXSession *)session;

@end
Loading