mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Merge branch '195-remove-notification-when-viewing' into 'master'
Fix notifications for current conversation * Remove notification about private messages when viewing the conversation * Do not show a notification for a conversation the user is viewing Closes #195 See merge request !61
This commit is contained in:
@@ -69,6 +69,7 @@ EventListener {
|
||||
new HashMap<GroupId, Integer>();
|
||||
private int contactTotal = 0, forumTotal = 0;
|
||||
private int nextRequestId = 0;
|
||||
private ContactId activeContact;
|
||||
|
||||
private volatile Settings settings = new Settings();
|
||||
|
||||
@@ -113,11 +114,14 @@ EventListener {
|
||||
public void showPrivateMessageNotification(ContactId c) {
|
||||
lock.lock();
|
||||
try {
|
||||
Integer count = contactCounts.get(c);
|
||||
if (count == null) contactCounts.put(c, 1);
|
||||
else contactCounts.put(c, count + 1);
|
||||
contactTotal++;
|
||||
updatePrivateMessageNotification();
|
||||
// check first if user has this conversation open at the moment
|
||||
if (activeContact == null || !activeContact.equals(c)) {
|
||||
Integer count = contactCounts.get(c);
|
||||
if (count == null) contactCounts.put(c, 1);
|
||||
else contactCounts.put(c, count + 1);
|
||||
contactTotal++;
|
||||
updatePrivateMessageNotification();
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@@ -135,6 +139,26 @@ EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void blockPrivateMessageNotification(ContactId c) {
|
||||
lock.lock();
|
||||
try {
|
||||
activeContact = c;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void unblockPrivateMessageNotification(ContactId c) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (activeContact != null && activeContact.equals(c)) {
|
||||
activeContact = null;
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: lock
|
||||
private void updatePrivateMessageNotification() {
|
||||
if (contactTotal == 0) {
|
||||
|
||||
@@ -122,14 +122,19 @@ public class ConversationActivity extends BriarActivity
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
eventBus.addListener(this);
|
||||
notificationManager.blockPrivateMessageNotification(contactId);
|
||||
loadContactAndGroup();
|
||||
loadHeaders();
|
||||
|
||||
// remove the notification for this conversation since we see it now
|
||||
notificationManager.clearPrivateMessageNotification(contactId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
eventBus.removeListener(this);
|
||||
notificationManager.unblockPrivateMessageNotification(contactId);
|
||||
if (isFinishing()) markMessagesRead();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user