mark conversation as read when swiping a notification with quick reply away
This commit is contained in:
parent
caafd03130
commit
2c187d0e7c
|
@ -171,6 +171,9 @@ public class NotificationService {
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
synchronized (notifications) {
|
synchronized (notifications) {
|
||||||
|
for(ArrayList<Message> messages : notifications.values()) {
|
||||||
|
markAsReadIfHasDirectReply(messages);
|
||||||
|
}
|
||||||
notifications.clear();
|
notifications.clear();
|
||||||
updateNotification(false);
|
updateNotification(false);
|
||||||
}
|
}
|
||||||
|
@ -178,6 +181,7 @@ public class NotificationService {
|
||||||
|
|
||||||
public void clear(final Conversation conversation) {
|
public void clear(final Conversation conversation) {
|
||||||
synchronized (notifications) {
|
synchronized (notifications) {
|
||||||
|
markAsReadIfHasDirectReply(conversation);
|
||||||
notifications.remove(conversation.getUuid());
|
notifications.remove(conversation.getUuid());
|
||||||
final NotificationManager nm = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
|
final NotificationManager nm = (NotificationManager) mXmppConnectionService.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
nm.cancel(conversation.getUuid(), NOTIFICATION_ID);
|
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) {
|
private void setNotificationColor(final Builder mBuilder) {
|
||||||
mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary500));
|
mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary500));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3022,7 +3022,13 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean markRead(final Conversation conversation) {
|
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();
|
final List<Message> readMessages = conversation.markRead();
|
||||||
if (readMessages.size() > 0) {
|
if (readMessages.size() > 0) {
|
||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
|
|
Loading…
Reference in New Issue