diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 62c0ae85c..f91a3ebf1 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1236,6 +1236,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut while (history) { NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; LinphoneChatMessage *msg = history->data; + const char *state = linphone_chat_message_state_to_string(linphone_chat_message_get_state(msg)); bool_t isOutgoing = linphone_chat_message_is_outgoing(msg); bool_t isFileTransfer = linphone_chat_message_is_file_transfer(msg); const LinphoneAddress *fromAddress = linphone_chat_message_get_from_address(msg); @@ -1246,6 +1247,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut withMaxWidth:200 andMaxHeight:200]; NSData *fromImageData = UIImageJPEGRepresentation(fromImage, 1); + [msgData setObject:[NSString stringWithUTF8String:state] forKey:@"state"]; [msgData setObject:displayNameDate forKey:@"displayNameDate"]; [msgData setObject:[NSNumber numberWithBool:isFileTransfer] forKey:@"isFileTransfer"]; [msgData setObject:fromImageData forKey:@"fromImageData"]; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 67240e5cd..e06903ce7 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -38,17 +38,26 @@ - + + + + + @@ -70,6 +79,7 @@ + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 0f15fa177..3a6767f92 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -11,5 +11,6 @@ @property (weak, nonatomic) IBOutlet UIImageView *contactImage; @property (weak, nonatomic) IBOutlet UILabel *nameDate; @property (weak, nonatomic) IBOutlet UITextView *msgText; +@property (weak, nonatomic) IBOutlet UILabel *imdm; @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 014b6178d..29cd6b8b7 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -16,17 +16,28 @@ @implementation NotificationViewController { @private - NSArray *msgs; + NSMutableArray *msgs; } - (void)viewDidLoad { [super viewDidLoad]; + self.tableView.scrollEnabled = TRUE; // Do any required interface initialization here. } - (void)didReceiveNotification:(UNNotification *)notification { - msgs = [[[[notification request] content] userInfo] objectForKey:@"msgs"]; + if (msgs) + [msgs addObject:[((NSArray *)[[[[notification request] content] userInfo] objectForKey:@"msgs"]) lastObject]]; + else + msgs = [NSMutableArray arrayWithArray:[[[[notification request] content] userInfo] objectForKey:@"msgs"]]; [self.tableView reloadData]; + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:msgs.count - 1 + inSection:0] + atScrollPosition:UITableViewScrollPositionBottom + animated:YES]; + NSLog(@"Content length : %f", self.tableView.contentSize.height); + NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); + [self.view.superview bringSubviewToFront:self.tableView]; } #pragma mark - UITableViewDataSource Functions @@ -43,8 +54,9 @@ BOOL isOutgoing = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"isOutgoing"]).boolValue; NSString *display = ((NSString *)[msgs[indexPath.row] objectForKey:@"displayNameDate"]); NSString *msgText = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); + NSString *imdm = ((NSString *)[msgs[indexPath.row] objectForKey:@"state"]); NSData *imageData = [msgs[indexPath.row] objectForKey:@"fromImageData"]; - printf("Message %s de %s : %s\n", isOutgoing ? "sortant" : "entrant", + printf("%s : %s : %s\n", isOutgoing ? "sortant" : "entrant", display.UTF8String, msgText.UTF8String); printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); @@ -52,6 +64,14 @@ cell.contactImage.image = [UIImage imageWithData:imageData]; cell.nameDate.text = display; cell.msgText.text = msgText; + if (!isOutgoing) + cell.imdm.hidden = YES; + if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) + cell.imdm.text = NSLocalizedString(@"Delivered", nil); + else if ([imdm isEqualToString:@"LinphoneChatMessageStateDisplayed"]) + cell.imdm.text = NSLocalizedString(@"Read", nil); + else + cell.imdm.text = imdm; return cell; }