aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-27 15:25:37 +0200
committerChristian Schneppe <christian@pix-art.de>2016-08-27 23:17:24 +0200
commit1aca12fdfdcbb334e279583de0d70d611d22af6a (patch)
treed17b1baa917e23e593a342b1a11c44340ff182bf
parent4623fafa2eb88f076f579e1ef3938461d867d52e (diff)
mark conversation as read when swiping a notification with quick reply away
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java17
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java8
2 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index 92876205c..ce151931a 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -176,6 +176,9 @@ public class NotificationService {
public void clear() {
synchronized (notifications) {
+ for(ArrayList<Message> messages : notifications.values()) {
+ markAsReadIfHasDirectReply(messages);
+ }
notifications.clear();
updateNotification(false);
}
@@ -183,6 +186,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);
@@ -190,6 +194,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.primary));
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 1c9defe11..79f21b3df 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3024,7 +3024,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() {