mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Do not show a notification for a conversation we are in
This commit is contained in:
@@ -69,6 +69,7 @@ EventListener {
|
|||||||
new HashMap<GroupId, Integer>();
|
new HashMap<GroupId, Integer>();
|
||||||
private int contactTotal = 0, forumTotal = 0;
|
private int contactTotal = 0, forumTotal = 0;
|
||||||
private int nextRequestId = 0;
|
private int nextRequestId = 0;
|
||||||
|
private ContactId activeContact;
|
||||||
|
|
||||||
private volatile Settings settings = new Settings();
|
private volatile Settings settings = new Settings();
|
||||||
|
|
||||||
@@ -113,11 +114,14 @@ EventListener {
|
|||||||
public void showPrivateMessageNotification(ContactId c) {
|
public void showPrivateMessageNotification(ContactId c) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
Integer count = contactCounts.get(c);
|
// check first if user has this conversation open at the moment
|
||||||
if (count == null) contactCounts.put(c, 1);
|
if (activeContact == null || !activeContact.equals(c)) {
|
||||||
else contactCounts.put(c, count + 1);
|
Integer count = contactCounts.get(c);
|
||||||
contactTotal++;
|
if (count == null) contactCounts.put(c, 1);
|
||||||
updatePrivateMessageNotification();
|
else contactCounts.put(c, count + 1);
|
||||||
|
contactTotal++;
|
||||||
|
updatePrivateMessageNotification();
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
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
|
// Locking: lock
|
||||||
private void updatePrivateMessageNotification() {
|
private void updatePrivateMessageNotification() {
|
||||||
if (contactTotal == 0) {
|
if (contactTotal == 0) {
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
eventBus.addListener(this);
|
eventBus.addListener(this);
|
||||||
|
notificationManager.blockPrivateMessageNotification(contactId);
|
||||||
loadContactAndGroup();
|
loadContactAndGroup();
|
||||||
loadHeaders();
|
loadHeaders();
|
||||||
|
|
||||||
@@ -133,6 +134,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
eventBus.removeListener(this);
|
eventBus.removeListener(this);
|
||||||
|
notificationManager.unblockPrivateMessageNotification(contactId);
|
||||||
if (isFinishing()) markMessagesRead();
|
if (isFinishing()) markMessagesRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ public interface AndroidNotificationManager extends Service {
|
|||||||
|
|
||||||
void clearPrivateMessageNotification(ContactId c);
|
void clearPrivateMessageNotification(ContactId c);
|
||||||
|
|
||||||
|
void blockPrivateMessageNotification(ContactId c);
|
||||||
|
|
||||||
|
void unblockPrivateMessageNotification(ContactId c);
|
||||||
|
|
||||||
void showForumPostNotification(GroupId g);
|
void showForumPostNotification(GroupId g);
|
||||||
|
|
||||||
void clearForumPostNotification(GroupId g);
|
void clearForumPostNotification(GroupId g);
|
||||||
|
|||||||
Reference in New Issue
Block a user