From e2a6511fbf1f45c9a934b895e22bf95032a7cff9 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Mon, 21 Jul 2014 01:49:33 +0400 Subject: [PATCH] Fixed not working notifications in opened chat while app in background --- TMessagesProj/build.gradle | 2 +- .../org/telegram/messenger/ConnectionsManager.java | 13 ++++--------- .../src/main/java/org/telegram/ui/ChatActivity.java | 12 ++++++++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index a1cec90cc..ad4fa662b 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -83,7 +83,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 19 - versionCode 287 + versionCode 288 versionName "1.6.1" } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java index 4456e8e96..8af9e0ec2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java @@ -2231,16 +2231,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. if (request.completed) { break; } - if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) { - if (request.lastResendTime == 0 || request.lastResendTime + 60 < (int)(System.currentTimeMillis() / 1000)) { - request.lastResendTime = (int)(System.currentTimeMillis() / 1000); - requestResend = true; - } else { - confirm = false; - } - break; - } else { + if (request.lastResendTime == 0 || request.lastResendTime + 60 < (int)(System.currentTimeMillis() / 1000)) { + request.lastResendTime = (int)(System.currentTimeMillis() / 1000); requestResend = true; + } else { + confirm = false; } break; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 07d4546da..e9116ba1f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1984,7 +1984,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not messages.add(0, dateObj); } if (!obj.isOut() && obj.messageOwner.unread) { - obj.messageOwner.unread = false; + if (!paused) { + obj.messageOwner.unread = false; + } markAsRead = true; } dayArray.add(0, obj); @@ -2379,6 +2381,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } paused = false; if (readWhenResume && !messages.isEmpty()) { + for (MessageObject messageObject : messages) { + if (!messageObject.isUnread() && !messageObject.isFromMe()) { + break; + } + messageObject.messageOwner.unread = false; + } readWhenResume = false; MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, readWithMid, 0, readWithDate, true); } @@ -3310,7 +3318,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public boolean canPerformActions() { - return !actionBarLayer.isActionModeShowed(); + return actionBarLayer != null && !actionBarLayer.isActionModeShowed(); } }; if (view instanceof ChatMediaCell) {