From c8467b3a42e7c99e4d513289b9f6a13905756807 Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Wed, 15 Mar 2017 14:40:39 +0100 Subject: [PATCH] [Imdm] Imdm implementation - first version --- Classes/ChatConversationTableView.m | 1 + Classes/LinphoneManager.m | 9 +-- .../Base.lproj/UIChatBubblePhotoCell.xib | 31 +++++++--- .../Base.lproj/UIChatBubbleTextCell.xib | 36 ++++++++---- Classes/LinphoneUI/UIChatBubbleTextCell.h | 3 + Classes/LinphoneUI/UIChatBubbleTextCell.m | 54 ++++++++++++++---- Resources/en.lproj/Localizable.strings | Bin 63178 -> 63446 bytes Resources/fr.lproj/Localizable.strings | Bin 65718 -> 65962 bytes submodules/cmake-builder | 2 +- submodules/externals/opus | 2 +- submodules/linphone | 2 +- 11 files changed, 102 insertions(+), 38 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index bae83dd30..17dd31f60 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -102,6 +102,7 @@ [self.tableView reloadData]; size_t count = bctbx_list_size(messageList); if (count) { + [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:(count - 1) inSection:0]]; [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(count - 1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES]; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 08cce12d4..ad5b9a4c6 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1963,15 +1963,10 @@ static BOOL libStarted = FALSE; [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } - // Disable notify policy + // Enable notify policy for all LinphoneImNotifPolicy *im_notif_policy; im_notif_policy = linphone_core_get_im_notif_policy(theLinphoneCore); - if (im_notif_policy != NULL) { - /* The IM notification policy can be NULL at this point in case of remote provisioning. */ - linphone_im_notif_policy_clear(im_notif_policy); - linphone_im_notif_policy_set_send_is_composing(im_notif_policy, TRUE); - linphone_im_notif_policy_set_recv_is_composing(im_notif_policy, TRUE); - } + linphone_im_notif_policy_enable_all(im_notif_policy); if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { // go directly to bg mode diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib index dfd3370df..46e90ad66 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib @@ -1,5 +1,5 @@ - - + + @@ -22,6 +22,8 @@ + + @@ -30,16 +32,16 @@ - - + + - + - + @@ -108,7 +110,7 @@ - + @@ -125,6 +127,18 @@ + + @@ -134,7 +148,7 @@ - + @@ -156,6 +170,7 @@ + diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib index bec5dd5da..7b6f67246 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatBubbleTextCell.xib @@ -1,5 +1,5 @@ - - + + @@ -17,6 +17,8 @@ + + @@ -29,16 +31,16 @@ - - + + - + - + @@ -67,21 +69,33 @@ - + - - + + + + + + + + @@ -91,6 +105,7 @@ + @@ -98,6 +113,7 @@ + diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.h b/Classes/LinphoneUI/UIChatBubbleTextCell.h index 89e89ba0a..9c3d71762 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.h +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.h @@ -37,6 +37,8 @@ @property(strong, nonatomic) IBOutlet UIView *bubbleView; @property(strong, nonatomic) IBOutlet UITapGestureRecognizer *resendRecognizer; @property(weak, nonatomic) IBOutlet UIImageView *LIMEKO; +@property(weak, nonatomic) IBOutlet UIImageView *imdmIcon; +@property(weak, nonatomic) IBOutlet UILabel *imdmLabel; + (CGSize)ViewSizeForMessage:(LinphoneChatMessage *)chat withWidth:(int)width; @@ -46,6 +48,7 @@ - (IBAction)onResendClick:(id)event; - (void)update; +- (void)displayImdmStatus:(LinphoneChatMessageState)state; + (CGSize)ViewHeightForMessage:(LinphoneChatMessage *)chat withWidth:(int)width; + (NSString *)TextMessageForChat:(LinphoneChatMessage *)message; + (CGSize)computeBoundingBox:(NSString *)text size:(CGSize)size font:(UIFont *)font; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 54caca958..ebaef798e 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -138,16 +138,17 @@ if (outgoing && state == LinphoneChatMessageStateInProgress) { _statusErrorImage.hidden = YES; [_statusInProgressSpinner startAnimating]; - } else if (outgoing && - (state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError)) { - _statusErrorImage.hidden = NO; - [_statusInProgressSpinner stopAnimating]; + } /* else if (outgoing && + (state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError)) { + _statusErrorImage.hidden = NO; + [_statusInProgressSpinner stopAnimating]; - NSAttributedString *resend_text = - [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Resend", @"Resend") - attributes:@{NSForegroundColorAttributeName : [UIColor redColor]}]; - [_contactDateLabel setAttributedText:resend_text]; - } else if (!outgoing && state == LinphoneChatMessageStateFileTransferError) { + NSAttributedString *resend_text = + [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Resend", @"Resend") + attributes:@{NSForegroundColorAttributeName : [UIColor redColor]}]; + [_contactDateLabel setAttributedText:resend_text]; + }*/ + else if (!outgoing && state == LinphoneChatMessageStateFileTransferError) { _statusErrorImage.hidden = NO; [_statusInProgressSpinner stopAnimating]; } else { @@ -159,7 +160,15 @@ [_messageText setAccessibilityLabel:@"Outgoing message"]; } else { [_messageText setAccessibilityLabel:@"Incoming message"]; + //[self hideImdmIcons]; } + // TODO : Message deliver and displayed + if (outgoing && + (state == LinphoneChatMessageStateDeliveredToUser || state == LinphoneChatMessageStateDisplayed || + state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError)) { + [self displayImdmStatus:state]; + } else + [self displayImdmStatus:LinphoneChatMessageStateInProgress]; if (!outgoing && !linphone_chat_message_is_secured(_message) && linphone_core_lime_enabled(LC) == LinphoneLimeMandatory) { @@ -251,6 +260,31 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st [view.tableController updateChatEntry:msg]; } +- (void)displayImdmStatus:(LinphoneChatMessageState)state { + if (state == LinphoneChatMessageStateDeliveredToUser) { //|| state == LinphoneChatMessageStateDelivered){ + [_imdmIcon setImage:[UIImage imageNamed:@"valid_disabled"]]; + [_imdmLabel setText:NSLocalizedString(@"Delivered", nil)]; + //[_imdmLabel setTextColor:[UIColor blueColor]]; + [_imdmIcon setHidden:FALSE]; + [_imdmLabel setHidden:FALSE]; + } else if (state == LinphoneChatMessageStateDisplayed) { + [_imdmIcon setImage:[UIImage imageNamed:@"valid_default"]]; + [_imdmLabel setText:NSLocalizedString(@"Displayed", nil)]; + //[_imdmLabel setTextColor:[UIColor greenColor]]; + [_imdmIcon setHidden:FALSE]; + [_imdmLabel setHidden:FALSE]; + } else if (state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError) { + [_imdmIcon setImage:[UIImage imageNamed:@"chat_message_not_delivered"]]; + [_imdmLabel setText:NSLocalizedString(@"Resend", nil)]; + [_imdmLabel setTextColor:[UIColor redColor]]; + [_imdmIcon setHidden:FALSE]; + [_imdmLabel setHidden:FALSE]; + } else { + [_imdmIcon setHidden:TRUE]; + [_imdmLabel setHidden:TRUE]; + } +} + #pragma mark - Bubble size computing + (CGSize)computeBoundingBox:(NSString *)text size:(CGSize)size font:(UIFont *)font { @@ -277,7 +311,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st static const CGFloat CELL_MIN_HEIGHT = 60.0f; static const CGFloat CELL_MIN_WIDTH = 150.0f; static const CGFloat CELL_MESSAGE_X_MARGIN = 78 + 10.0f; -static const CGFloat CELL_MESSAGE_Y_MARGIN = 44; +static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44; static const CGFloat CELL_IMAGE_HEIGHT = 100.0f; static const CGFloat CELL_IMAGE_WIDTH = 100.0f; diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 2acf576e3e4e4b96b87f5744c0478606db3baf1c..5530beface7192487bcde1abcf07d5176a471d59 100644 GIT binary patch delta 97 zcmX^0migLy<_%|bS#uaN8OkOfED`2*VMt{F^B7Vm>!-wTKB1e(te(kG%uoOnPGqPA nN~bU=F(@$D0|`5LyU7Jce485#y^aC^y5Sq| delta 23 fcmccip83>U<_%|bHwWouF;8|d_S)QI