aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java30
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java3
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 71074d3d..306f61eb 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -85,6 +85,8 @@ public class ConversationActivity extends XmppActivity
private Toast prepareFileToast;
+ private boolean mActivityPaused = false;
+
public List<Conversation> getConversationList() {
return this.conversationList;
@@ -262,11 +264,15 @@ public class ConversationActivity extends XmppActivity
this.updateActionBarTitle();
this.invalidateOptionsMenu();
if (xmppConnectionServiceBound) {
- xmppConnectionService.getNotificationService().setOpenConversation(getSelectedConversation());
- if (!getSelectedConversation().isRead()) {
- xmppConnectionService.markRead(getSelectedConversation(), true);
- listView.invalidateViews();
- }
+ final Conversation conversation = getSelectedConversation();
+ xmppConnectionService.getNotificationService().setOpenConversation(conversation);
+ sendReadMarkerIfNecessary(conversation);
+ }
+ }
+
+ public void sendReadMarkerIfNecessary(final Conversation conversation) {
+ if (!mActivityPaused && !conversation.isRead()) {
+ xmppConnectionService.sendReadMarker(conversation);
}
}
@@ -738,12 +744,25 @@ public class ConversationActivity extends XmppActivity
}
@Override
+ public void onPause() {
+ super.onPause();
+ this.mActivityPaused = true;
+ if (this.xmppConnectionServiceBound) {
+ this.xmppConnectionService.getNotificationService().setIsInForeground(false);
+ }
+ }
+
+ @Override
public void onResume() {
super.onResume();
int theme = findTheme();
if (this.mTheme != theme) {
recreate();
}
+ this.mActivityPaused = false;
+ if (this.xmppConnectionServiceBound) {
+ this.xmppConnectionService.getNotificationService().setIsInForeground(true);
+ }
}
@Override
@@ -763,6 +782,7 @@ public class ConversationActivity extends XmppActivity
@Override
void onBackendConnected() {
+ this.xmppConnectionService.getNotificationService().setIsInForeground(true);
updateConversationList();
if (xmppConnectionService.getAccounts().size() == 0) {
startActivity(new Intent(this, EditAccountActivity.class));
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index c3b47d76..98f70728 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -665,8 +665,7 @@ public class ConversationFragment extends Fragment {
this.messageListAdapter.notifyDataSetChanged();
updateChatMsgHint();
if (!activity.isConversationsOverviewVisable() || !activity.isConversationsOverviewHideable()) {
- activity.xmppConnectionService.markRead(conversation, true);
- activity.updateConversationList();
+ activity.sendReadMarkerIfNecessary(conversation);
}
this.updateSendButton();
}