diff --git a/syMessaging/syMessaging.xcodeproj/project.pbxproj b/syMessaging/syMessaging.xcodeproj/project.pbxproj index 826c52897..560f83694 100644 --- a/syMessaging/syMessaging.xcodeproj/project.pbxproj +++ b/syMessaging/syMessaging.xcodeproj/project.pbxproj @@ -11,12 +11,15 @@ F01628C119E29C660071C473 /* default-profile.png in Resources */ = {isa = PBXBuildFile; fileRef = F01628BC19E29C660071C473 /* default-profile.png */; }; F01628C319E29C660071C473 /* logo.png in Resources */ = {isa = PBXBuildFile; fileRef = F01628BE19E29C660071C473 /* logo.png */; }; F024098219E7D177006E741B /* tab_recents@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F024098119E7D177006E741B /* tab_recents@2x.png */; }; + F02D707319F1CE4A007B47D3 /* CustomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F02D707219F1CE4A007B47D3 /* CustomTableViewCell.m */; }; F03EF5F619F171EB00A0EE52 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5EB19F171EB00A0EE52 /* HomeViewController.m */; }; F03EF5F719F171EB00A0EE52 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5ED19F171EB00A0EE52 /* LoginViewController.m */; }; F03EF5F819F171EB00A0EE52 /* MasterTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5EF19F171EB00A0EE52 /* MasterTabBarController.m */; }; F03EF5F919F171EB00A0EE52 /* RecentsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5F119F171EB00A0EE52 /* RecentsViewController.m */; }; F03EF5FA19F171EB00A0EE52 /* RoomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5F319F171EB00A0EE52 /* RoomViewController.m */; }; F03EF5FB19F171EB00A0EE52 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5F519F171EB00A0EE52 /* SettingsViewController.m */; }; + F03EF5FF19F1762000A0EE52 /* RoomMessageTableCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF5FE19F1762000A0EE52 /* RoomMessageTableCell.m */; }; + F03EF60219F19E7C00A0EE52 /* MediaManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F03EF60119F19E7C00A0EE52 /* MediaManager.m */; }; F05B955F19DEED8A008761B0 /* MatrixHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = F05B955E19DEED8A008761B0 /* MatrixHandler.m */; }; F07A80D819DD9DE700B621A1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F07A80D719DD9DE700B621A1 /* main.m */; }; F07A80DB19DD9DE700B621A1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F07A80DA19DD9DE700B621A1 /* AppDelegate.m */; }; @@ -46,6 +49,8 @@ F01628BC19E29C660071C473 /* default-profile.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "default-profile.png"; sourceTree = ""; }; F01628BE19E29C660071C473 /* logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = logo.png; sourceTree = ""; }; F024098119E7D177006E741B /* tab_recents@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_recents@2x.png"; sourceTree = ""; }; + F02D707119F1CE4A007B47D3 /* CustomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTableViewCell.h; sourceTree = ""; }; + F02D707219F1CE4A007B47D3 /* CustomTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomTableViewCell.m; sourceTree = ""; }; F03EF5EA19F171EB00A0EE52 /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = ""; }; F03EF5EB19F171EB00A0EE52 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = ""; }; F03EF5EC19F171EB00A0EE52 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = ""; }; @@ -58,6 +63,10 @@ F03EF5F319F171EB00A0EE52 /* RoomViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomViewController.m; sourceTree = ""; }; F03EF5F419F171EB00A0EE52 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; F03EF5F519F171EB00A0EE52 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; + F03EF5FD19F1762000A0EE52 /* RoomMessageTableCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomMessageTableCell.h; sourceTree = ""; }; + F03EF5FE19F1762000A0EE52 /* RoomMessageTableCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomMessageTableCell.m; sourceTree = ""; }; + F03EF60019F19E7C00A0EE52 /* MediaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaManager.h; sourceTree = ""; }; + F03EF60119F19E7C00A0EE52 /* MediaManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaManager.m; sourceTree = ""; }; F05B955D19DEED8A008761B0 /* MatrixHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MatrixHandler.h; sourceTree = ""; }; F05B955E19DEED8A008761B0 /* MatrixHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MatrixHandler.m; sourceTree = ""; }; F07A80D219DD9DE700B621A1 /* syMessaging.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = syMessaging.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -144,6 +153,17 @@ path = ViewController; sourceTree = ""; }; + F03EF5FC19F1762000A0EE52 /* View */ = { + isa = PBXGroup; + children = ( + F02D707119F1CE4A007B47D3 /* CustomTableViewCell.h */, + F02D707219F1CE4A007B47D3 /* CustomTableViewCell.m */, + F03EF5FD19F1762000A0EE52 /* RoomMessageTableCell.h */, + F03EF5FE19F1762000A0EE52 /* RoomMessageTableCell.m */, + ); + path = View; + sourceTree = ""; + }; F07A80C919DD9DE700B621A1 = { isa = PBXGroup; children = ( @@ -167,11 +187,14 @@ F07A80D419DD9DE700B621A1 /* syMessaging */ = { isa = PBXGroup; children = ( + F03EF5FC19F1762000A0EE52 /* View */, F03EF5E919F171EB00A0EE52 /* ViewController */, F07A80D919DD9DE700B621A1 /* AppDelegate.h */, F07A80DA19DD9DE700B621A1 /* AppDelegate.m */, F05B955D19DEED8A008761B0 /* MatrixHandler.h */, F05B955E19DEED8A008761B0 /* MatrixHandler.m */, + F03EF60019F19E7C00A0EE52 /* MediaManager.h */, + F03EF60119F19E7C00A0EE52 /* MediaManager.m */, F07A80E219DD9DE700B621A1 /* Main.storyboard */, F07A80E519DD9DE700B621A1 /* Images.xcassets */, F07A80E719DD9DE700B621A1 /* LaunchScreen.xib */, @@ -349,12 +372,15 @@ buildActionMask = 2147483647; files = ( F07A80DB19DD9DE700B621A1 /* AppDelegate.m in Sources */, + F03EF5FF19F1762000A0EE52 /* RoomMessageTableCell.m in Sources */, + F02D707319F1CE4A007B47D3 /* CustomTableViewCell.m in Sources */, F07A80D819DD9DE700B621A1 /* main.m in Sources */, F05B955F19DEED8A008761B0 /* MatrixHandler.m in Sources */, F03EF5FB19F171EB00A0EE52 /* SettingsViewController.m in Sources */, F03EF5FA19F171EB00A0EE52 /* RoomViewController.m in Sources */, F03EF5F819F171EB00A0EE52 /* MasterTabBarController.m in Sources */, F03EF5F619F171EB00A0EE52 /* HomeViewController.m in Sources */, + F03EF60219F19E7C00A0EE52 /* MediaManager.m in Sources */, F03EF5F919F171EB00A0EE52 /* RecentsViewController.m in Sources */, F03EF5F719F171EB00A0EE52 /* LoginViewController.m in Sources */, ); diff --git a/syMessaging/syMessaging/AppDelegate.m b/syMessaging/syMessaging/AppDelegate.m index 44357d361..bb5504aa7 100644 --- a/syMessaging/syMessaging/AppDelegate.m +++ b/syMessaging/syMessaging/AppDelegate.m @@ -17,6 +17,7 @@ #import "AppDelegate.h" #import "RoomViewController.h" #import "MatrixHandler.h" +#import "MediaManager.h" @interface AppDelegate () @@ -80,6 +81,9 @@ #pragma mark - - (void)logout { + // Clear cache + [MediaManager clearCache]; + // Logout Matrix [[MatrixHandler sharedHandler] logout]; [self.masterTabBarController showLoginScreen]; // By default the "Home" tab is focussed diff --git a/syMessaging/syMessaging/Base.lproj/Main.storyboard b/syMessaging/syMessaging/Base.lproj/Main.storyboard index b40699b1f..983547e73 100644 --- a/syMessaging/syMessaging/Base.lproj/Main.storyboard +++ b/syMessaging/syMessaging/Base.lproj/Main.storyboard @@ -37,12 +37,12 @@ - + - + @@ -87,11 +87,11 @@ + - - + @@ -107,7 +107,7 @@ - + @@ -139,8 +139,8 @@ + - diff --git a/syMessaging/syMessaging/MediaManager.h b/syMessaging/syMessaging/MediaManager.h new file mode 100644 index 000000000..56e5257ae --- /dev/null +++ b/syMessaging/syMessaging/MediaManager.h @@ -0,0 +1,30 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 +#import + +@interface MediaManager : NSObject + ++ (id)sharedInstance; + ++ (NSString*)cachePictureWithData:(NSData*)imageData forURL:(NSString *)pictureURL; + ++ (UIImage*)loadCachePicture:(NSString*)pictureURL; + ++ (void)clearCache; + +@end diff --git a/syMessaging/syMessaging/MediaManager.m b/syMessaging/syMessaging/MediaManager.m new file mode 100644 index 000000000..09f3d0690 --- /dev/null +++ b/syMessaging/syMessaging/MediaManager.m @@ -0,0 +1,104 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 "MediaManager.h" + +static NSString* pictureCachePath = nil; +static NSString *pictureDir = @"picturecache"; + +static MediaManager *sharedMediaManager = nil; + +@implementation MediaManager + ++ (id)sharedInstance { + @synchronized(self) { + if(sharedMediaManager == nil) + sharedMediaManager = [[self alloc] init]; + } + return sharedMediaManager; +} + +#pragma mark - Cache handling + ++ (NSString*)cachePictureWithData:(NSData*)imageData forURL:(NSString *)pictureURL { + NSString* filename = [MediaManager getCacheFileNameFor:pictureURL]; + + if ([imageData writeToFile:filename atomically:YES]) { + return filename; + } else { + return nil; + } +} + ++ (UIImage*)loadCachePicture:(NSString*)pictureURL { + UIImage* res = nil; + NSString* filename = [MediaManager getCacheFileNameFor:pictureURL]; + + if ([[NSFileManager defaultManager] fileExistsAtPath:filename]) { + NSData* imageContent = [NSData dataWithContentsOfFile:filename options:(NSDataReadingMappedAlways | NSDataReadingUncached) error:nil]; + if (imageContent) { + res = [[UIImage alloc] initWithData:imageContent]; + } + } + + return res; +} + ++ (NSString*)getCachePath { + NSString *mediaCachePath = nil; + + if (!pictureCachePath) { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + NSString *cacheRoot = [paths objectAtIndex:0]; + + pictureCachePath = [cacheRoot stringByAppendingPathComponent:pictureDir]; + + if (![[NSFileManager defaultManager] fileExistsAtPath:pictureCachePath]) { + [[NSFileManager defaultManager] createDirectoryAtPath:pictureCachePath withIntermediateDirectories:NO attributes:nil error:nil]; + } + } + mediaCachePath = pictureCachePath; + + return mediaCachePath; +} + ++ (NSString*)getCacheFileNameFor:(NSString*)pictureURL { + NSString* baseFileName = [[MediaManager getCachePath] stringByAppendingPathComponent:@"ima"]; + return [NSString stringWithFormat:@"%@%d.jpg", baseFileName, pictureURL.hash]; +} + ++ (void)clearCache { + NSError *error = nil; + + if (!pictureCachePath) { + // compute the path + pictureCachePath = [MediaManager getCachePath]; + } + + if (pictureCachePath) { + if (![[NSFileManager defaultManager] removeItemAtPath:pictureCachePath error:&error]) { + NSLog(@"Fails to delete picture cache dir : %@", error); + } else { + NSLog(@"Picture cache : deleted !"); + } + } else { + NSLog(@"Picture cache does not exist"); + } + + pictureCachePath = nil; +} + +@end diff --git a/syMessaging/syMessaging/View/CustomTableViewCell.h b/syMessaging/syMessaging/View/CustomTableViewCell.h new file mode 100644 index 000000000..839e177e0 --- /dev/null +++ b/syMessaging/syMessaging/View/CustomTableViewCell.h @@ -0,0 +1,26 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 + +// Customize UITableViewCell in order to handle Table cell with UIImageView based on remote url +@interface CustomTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UIImageView *pictureView; + +@property (strong, nonatomic) NSString *placeholder; +@property (strong, nonatomic) NSString *pictureURL; +@end + diff --git a/syMessaging/syMessaging/View/CustomTableViewCell.m b/syMessaging/syMessaging/View/CustomTableViewCell.m new file mode 100644 index 000000000..14d128359 --- /dev/null +++ b/syMessaging/syMessaging/View/CustomTableViewCell.m @@ -0,0 +1,97 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 "CustomTableViewCell.h" +#import "MediaManager.h" + +@interface CustomTableViewCell () { + NSMutableData *downloadData; + NSURLConnection *downloadConnection; +} +@end + +@implementation CustomTableViewCell + +- (void)setPictureURL:(NSString *)pictureURL { + // Cancel current request (if any) + [downloadConnection cancel]; + downloadConnection = nil; + downloadData = nil; + + _pictureURL = pictureURL; + + // Update user picture + _pictureView.image = nil; + if (pictureURL) { + // Check cache + _pictureView.image = [MediaManager loadCachePicture:pictureURL]; + + if (!_pictureView.image) { + if (_placeholder) { + // Set picture placeholder + _pictureView.image = [UIImage imageNamed:_placeholder]; + } + + // Download picture + NSURL *url = [NSURL URLWithString:pictureURL]; + downloadData = [[NSMutableData alloc] init]; + downloadConnection = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:url] delegate:self]; + } + } else { + if (_placeholder) { + // Set picture placeholder + _pictureView.image = [UIImage imageNamed:_placeholder]; + } + } +} + +- (void)dealloc +{ + downloadData = nil; + downloadConnection = nil; +} + +#pragma mark - NSURLConnectionDelegate +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error +{ + NSLog(@"ERROR: picture download failed: %@", error); +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data +{ + // Append data + [downloadData appendData:data]; +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)connection +{ + // Set the downloaded image + _pictureView.image = [UIImage imageWithData:downloadData]; + if (_pictureView.image) { + // Cache the downloaded data + [MediaManager cachePictureWithData:downloadData forURL:_pictureURL]; + } else { + if (_placeholder) { + // Set picture placeholder + _pictureView.image = [UIImage imageNamed:_placeholder]; + } + } + + downloadData = nil; + downloadConnection = nil; +} + +@end \ No newline at end of file diff --git a/syMessaging/syMessaging/View/RoomMessageTableCell.h b/syMessaging/syMessaging/View/RoomMessageTableCell.h new file mode 100644 index 000000000..ae800bc4d --- /dev/null +++ b/syMessaging/syMessaging/View/RoomMessageTableCell.h @@ -0,0 +1,32 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 +#import "CustomTableViewCell.h" + +// Room Message Table View Cell +@interface RoomMessageTableCell : CustomTableViewCell +@property (weak, nonatomic) IBOutlet UITextView *messageTextView; +@end + +@interface IncomingMessageTableCell : RoomMessageTableCell +@property (weak, nonatomic) IBOutlet UILabel *userNameLabel; +@end + +@interface OutgoingMessageTableCell : RoomMessageTableCell +@property (weak, nonatomic) IBOutlet UILabel *unsentLabel; +@end + diff --git a/syMessaging/syMessaging/View/RoomMessageTableCell.m b/syMessaging/syMessaging/View/RoomMessageTableCell.m new file mode 100644 index 000000000..b2e26c545 --- /dev/null +++ b/syMessaging/syMessaging/View/RoomMessageTableCell.m @@ -0,0 +1,29 @@ +/* + Copyright 2014 OpenMarket Ltd + + 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 "RoomMessageTableCell.h" + + +@implementation RoomMessageTableCell +@end + + +@implementation IncomingMessageTableCell +@end + + +@implementation OutgoingMessageTableCell +@end \ No newline at end of file diff --git a/syMessaging/syMessaging/ViewController/RoomViewController.m b/syMessaging/syMessaging/ViewController/RoomViewController.m index b07017b1c..722b4efca 100644 --- a/syMessaging/syMessaging/ViewController/RoomViewController.m +++ b/syMessaging/syMessaging/ViewController/RoomViewController.m @@ -15,6 +15,7 @@ */ #import "RoomViewController.h" +#import "RoomMessageTableCell.h" #import "MatrixHandler.h" #import "AppDelegate.h" @@ -26,26 +27,6 @@ NSString *const kLocalEchoEventIdPrefix = @"localEcho-"; NSString *const kFailedEventId = @"failedEventId"; -// Table view cell -@interface RoomMessageCell : UITableViewCell -@property (weak, nonatomic) IBOutlet UIImageView *userPicture; -@property (weak, nonatomic) IBOutlet UITextView *messageTextView; -@end -@implementation RoomMessageCell -@end - -@interface IncomingMessageCell : RoomMessageCell -@property (weak, nonatomic) IBOutlet UILabel *userNameLabel; -@end -@implementation IncomingMessageCell -@end - -@interface OutgoingMessageCell : RoomMessageCell -@property (weak, nonatomic) IBOutlet UILabel *unsentLabel; -@end -@implementation OutgoingMessageCell -@end - @interface RoomViewController () { @@ -437,7 +418,7 @@ NSString *const kFailedEventId = @"failedEventId"; } // Handle here room thread cells - RoomMessageCell *cell; + RoomMessageTableCell *cell; MXEvent *mxEvent = [messages objectAtIndex:indexPath.row]; BOOL isIncomingMsg = NO; @@ -456,20 +437,25 @@ NSString *const kFailedEventId = @"failedEventId"; } // Hide user picture if the previous message is from the same user - cell.userPicture.hidden = NO; + cell.pictureView.hidden = NO; if (indexPath.row) { MXEvent *previousMxEvent = [messages objectAtIndex:indexPath.row - 1]; if ([previousMxEvent.user_id isEqualToString:mxEvent.user_id]) { - cell.userPicture.hidden = YES; + cell.pictureView.hidden = YES; } } + // Set url for visible picture + if (!cell.pictureView.hidden) { + cell.placeholder = @"default-profile"; + cell.pictureURL = [mxRoomData getMember:mxEvent.user_id].avatar_url; + } // Update incoming/outgoing message layout if (isIncomingMsg) { // Hide userName in incoming message if the previous message is from the same user - IncomingMessageCell* incomingMsgCell = (IncomingMessageCell*)cell; + IncomingMessageTableCell* incomingMsgCell = (IncomingMessageTableCell*)cell; CGRect frame = incomingMsgCell.userNameLabel.frame; - if (cell.userPicture.hidden) { + if (cell.pictureView.hidden) { incomingMsgCell.userNameLabel.text = nil; frame.size.height = 0; incomingMsgCell.userNameLabel.hidden = YES; @@ -482,7 +468,7 @@ NSString *const kFailedEventId = @"failedEventId"; incomingMsgCell.userNameLabel.frame = frame; } else { // Hide unsent label by default - UILabel *unsentLabel = ((OutgoingMessageCell*)cell).unsentLabel; + UILabel *unsentLabel = ((OutgoingMessageTableCell*)cell).unsentLabel; unsentLabel.hidden = YES; // Set the right text color for outgoing messages