diff --git a/Classes/ChatRoomTableViewController.h b/Classes/ChatRoomTableViewController.h index d3c0a17ac..09de79e8c 100644 --- a/Classes/ChatRoomTableViewController.h +++ b/Classes/ChatRoomTableViewController.h @@ -25,6 +25,7 @@ - (BOOL)chatRoomStartImageDownload:(NSURL*)url userInfo:(id)userInfo; - (BOOL)chatRoomStartImageUpload:(UIImage*)image url:(NSURL*)url; +- (void)resendChat:(NSString*)message; @end diff --git a/Classes/ChatRoomTableViewController.m b/Classes/ChatRoomTableViewController.m index 85eecc9d7..04125d2bd 100644 --- a/Classes/ChatRoomTableViewController.m +++ b/Classes/ChatRoomTableViewController.m @@ -170,7 +170,7 @@ ChatModel *chat = [data objectAtIndex:[indexPath row]]; [data removeObjectAtIndex:[indexPath row]]; [chat delete]; - [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom]; [tableView endUpdates]; } } diff --git a/Classes/ChatRoomViewController.m b/Classes/ChatRoomViewController.m index ee14b36ed..dc5f1841c 100644 --- a/Classes/ChatRoomViewController.m +++ b/Classes/ChatRoomViewController.m @@ -612,6 +612,9 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta return FALSE; } +- (void)resendChat:(NSString *)message { + [self sendMessage:message withExterlBodyUrl:nil withInternalUrl:nil]; +} #pragma mark ImageSharingDelegate diff --git a/Classes/LinphoneUI/UIChatRoomCell.h b/Classes/LinphoneUI/UIChatRoomCell.h index e043cc3d7..d7cd58e9f 100644 --- a/Classes/LinphoneUI/UIChatRoomCell.h +++ b/Classes/LinphoneUI/UIChatRoomCell.h @@ -23,6 +23,7 @@ #import "ChatRoomTableViewController.h" #import "UILoadingImageView.h" #import "UITransparentTVCell.h" +#import "UITextViewNoDefine.h" @interface UIChatRoomCell : UITransparentTVCell { @@ -32,13 +33,14 @@ @property (nonatomic, retain) IBOutlet UIView *innerView; @property (nonatomic, retain) IBOutlet UIView *bubbleView; @property (nonatomic, retain) IBOutlet UIImageView* backgroundImage; -@property (nonatomic, retain) IBOutlet UITextView *messageText; +@property (nonatomic, retain) IBOutlet UITextViewNoDefine *messageText; @property (nonatomic, retain) IBOutlet UILoadingImageView *messageImageView; @property (nonatomic, retain) IBOutlet UIButton *deleteButton; @property (nonatomic, retain) IBOutlet UILabel *dateLabel; @property (nonatomic, retain) IBOutlet UIImageView* statusImage; @property (nonatomic, retain) IBOutlet UIButton* downloadButton; @property (nonatomic, retain) IBOutlet UITapGestureRecognizer* imageTapGestureRecognizer; +@property (nonatomic, retain) IBOutlet UITapGestureRecognizer* resendTapGestureRecognizer; - (id)initWithIdentifier:(NSString*)identifier; + (CGFloat)height:(ChatModel*)chat width:(int)width; diff --git a/Classes/LinphoneUI/UIChatRoomCell.m b/Classes/LinphoneUI/UIChatRoomCell.m index 5e14344ff..5791a6237 100644 --- a/Classes/LinphoneUI/UIChatRoomCell.m +++ b/Classes/LinphoneUI/UIChatRoomCell.m @@ -42,6 +42,7 @@ @synthesize downloadButton; @synthesize chatRoomDelegate; @synthesize imageTapGestureRecognizer; +@synthesize resendTapGestureRecognizer; static const CGFloat CELL_MIN_HEIGHT = 50.0f; static const CGFloat CELL_MIN_WIDTH = 150.0f; @@ -62,6 +63,10 @@ static UIFont *CELL_FONT = nil; options:nil]; imageTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onImageClick:)]; [messageImageView addGestureRecognizer:imageTapGestureRecognizer]; + + resendTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onResendClick:)]; + [dateLabel addGestureRecognizer:resendTapGestureRecognizer]; + [self addSubview:innerView]; [deleteButton setAlpha:0.0f]; @@ -71,6 +76,7 @@ static UIFont *CELL_FONT = nil; messageCoords.origin.y += 2; messageCoords.size.width -= 5; [messageText setFrame:messageCoords]; + messageText.allowSelectAll = TRUE; } return self; } @@ -88,6 +94,7 @@ static UIFont *CELL_FONT = nil; [chat release]; [downloadButton release]; [imageTapGestureRecognizer release]; + [resendTapGestureRecognizer release]; [super dealloc]; } @@ -179,6 +186,11 @@ static UIFont *CELL_FONT = nil; } else if ([chat.state intValue] == LinphoneChatMessageStateNotDelivered) { [statusImage setImage:[UIImage imageNamed:@"chat_message_not_delivered.png"]]; statusImage.hidden = FALSE; + + NSAttributedString* resend_text = [[NSAttributedString alloc] + initWithString:NSLocalizedString(@"Resend", @"Resend") + attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}]; + [dateLabel setAttributedText:resend_text]; } else { statusImage.hidden = TRUE; } @@ -213,11 +225,11 @@ static UIFont *CELL_FONT = nil; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 if( [[[UIDevice currentDevice] systemVersion] doubleValue] >= 7){ - NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:CELL_FONT forKey: NSFontAttributeName]; - messageSize = [[chat message] boundingRectWithSize:CGSizeMake(width - CELL_MESSAGE_X_MARGIN, CGFLOAT_MAX) - options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading) - attributes:stringAttributes - context:nil].size; + messageSize = [[chat message] + boundingRectWithSize:CGSizeMake(width - CELL_MESSAGE_X_MARGIN, CGFLOAT_MAX) + options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading) + attributes:@{NSFontAttributeName: CELL_FONT} + context:nil].size; } else #endif { @@ -303,4 +315,17 @@ static UIFont *CELL_FONT = nil; } } +- (IBAction)onResendClick:(id)event { + if ([chat.state intValue] == LinphoneChatMessageStateNotDelivered) { + NSString* message = [chat message]; + [self onDeleteClick:nil]; + + double delayInSeconds = 0.4; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + [chatRoomDelegate resendChat:message]; + }); + } +} + @end diff --git a/Classes/LinphoneUI/UIChatRoomCell.xib b/Classes/LinphoneUI/UIChatRoomCell.xib index d252e5cf4..28099191d 100644 --- a/Classes/LinphoneUI/UIChatRoomCell.xib +++ b/Classes/LinphoneUI/UIChatRoomCell.xib @@ -1,7 +1,6 @@ - @@ -42,7 +41,7 @@ - + @@ -69,7 +68,7 @@ -