aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-27 15:25:37 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-08-27 15:25:37 +0200
commit2c187d0e7c03c4c1d0d6fecf77d90f8d11307a2c (patch)
tree2708108e2dd2d46ca8a27024b52698566c7e8753 /src
parentcaafd0313027fc81b7cf529e84df33461a7f9a90 (diff)
mark conversation as read when swiping a notification with quick reply away
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java17
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java8
2 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index f86152e2..00b76c76 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -171,6 +171,9 @@ public class NotificationService {
public void clear() {
synchronized (notifications) {
+ for(ArrayList<Message> messages : notifications.values()) {
+ markAsReadIfHasDirectReply(messages);
+ }
notifications.clear();
updateNotification(false);
}
@@ -178,6 +181,7 @@ public class NotificationService {
public void clear(final Conversation conversation) {
synchronized (notifications) {
+ markAsReadIfHasDirectReply(conversation);
notifications.remove(conversation.getUuid());
final NotificationManager nm = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(conversation.getUuid(), NOTIFICATION_ID);
@@ -185,6 +189,19 @@ public class NotificationService {
}
}
+ private void markAsReadIfHasDirectReply(final Conversation conversation) {
+ markAsReadIfHasDirectReply(notifications.get(conversation.getUuid()));
+ }
+
+ private void markAsReadIfHasDirectReply(final ArrayList<Message> messages) {
+ if (messages != null && messages.size() > 0) {
+ Message last = messages.get(messages.size() - 1);
+ if (last.getStatus() != Message.STATUS_RECEIVED) {
+ mXmppConnectionService.markRead(last.getConversation(), false);
+ }
+ }
+ }
+
private void setNotificationColor(final Builder mBuilder) {
mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary500));
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 83a1af23..19d1186b 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -3022,7 +3022,13 @@ public class XmppConnectionService extends Service {
}
public boolean markRead(final Conversation conversation) {
- mNotificationService.clear(conversation);
+ return markRead(conversation,true);
+ }
+
+ public boolean markRead(final Conversation conversation, boolean clear) {
+ if (clear) {
+ mNotificationService.clear(conversation);
+ }
final List<Message> readMessages = conversation.markRead();
if (readMessages.size() > 0) {
Runnable runnable = new Runnable() {