From 5447d742262efdffc9e459383a1c3dc5d1ad83ea Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Wed, 5 Apr 2017 17:10:50 +0200 Subject: [PATCH] =?UTF-8?q?[imdm]=20fix=20accus=C3=A9=20reception=20on=20b?= =?UTF-8?q?ackground=20mode=20or=20inactive=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/ChatConversationTableView.m | 6 ++++-- Classes/ChatConversationView.m | 6 ++++-- Classes/LinphoneAppDelegate.m | 10 +++++++--- Classes/LinphoneUI/UIChatBubbleTextCell.m | 5 ++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index 17dd31f60..ba958810d 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -127,8 +127,10 @@ if (index == -1 && count > 0) { index = (int)count - 1; } - - linphone_chat_room_mark_as_read(_chatRoom); + if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + linphone_chat_room_mark_as_read(_chatRoom); + } TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; [tab update:YES]; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index ea016e76b..58afb88d9 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -157,6 +157,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - - (void)setChatRoom:(LinphoneChatRoom *)chatRoom { + _chatRoom = chatRoom; [_messageField setText:@""]; [_tableController setChatRoom:_chatRoom]; @@ -357,10 +358,11 @@ static UICompositeViewDescription *compositeDescription = nil; if (fromStr && cr_from_string) { if (strcasecmp(cr_from_string, fromStr) == 0) { - if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { + if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { linphone_chat_room_mark_as_read(room); - [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; } + [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; [_tableController addChatEntry:chat]; [_tableController scrollToLastUnread:TRUE]; } diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index eefab7b09..75cbf6363 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -900,7 +900,9 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response NSString *from = [notification.userInfo objectForKey:@"from_addr"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { - linphone_chat_room_mark_as_read(room); + if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) + linphone_chat_room_mark_as_read(room); TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; [tab update:YES]; @@ -949,8 +951,10 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) { [LinphoneManager.instance alertLIME:room]; } - - linphone_chat_room_mark_as_read(room); + if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + linphone_chat_room_mark_as_read(room); + } [PhoneMainView.instance updateApplicationBadgeNumber]; } } diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 5a79762f6..8cca9e4b7 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -150,7 +150,10 @@ [_messageText setAccessibilityLabel:@"Outgoing message"]; } else { [_messageText setAccessibilityLabel:@"Incoming message"]; - VIEW(ChatConversationView).markAsRead; + if (!([UIApplication sharedApplication].applicationState != UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState != UIApplicationStateInactive)) { + VIEW(ChatConversationView).markAsRead; + } } if (outgoing &&