mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Use new UI/DB interfaces for private messaging.
This commit is contained in:
@@ -25,7 +25,7 @@ import org.briarproject.android.util.HorizontalBorder;
|
|||||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||||
import org.briarproject.api.contact.Contact;
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
import org.briarproject.api.event.ContactAddedEvent;
|
import org.briarproject.api.event.ContactAddedEvent;
|
||||||
@@ -37,6 +37,7 @@ import org.briarproject.api.event.EventBus;
|
|||||||
import org.briarproject.api.event.EventListener;
|
import org.briarproject.api.event.EventListener;
|
||||||
import org.briarproject.api.event.MessageAddedEvent;
|
import org.briarproject.api.event.MessageAddedEvent;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.MessageHeader;
|
import org.briarproject.api.sync.MessageHeader;
|
||||||
@@ -74,7 +75,8 @@ EventListener {
|
|||||||
private ListLoadingProgressBar loading = null;
|
private ListLoadingProgressBar loading = null;
|
||||||
|
|
||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile ContactManager contactManager;
|
||||||
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
@Inject private volatile EventBus eventBus;
|
@Inject private volatile EventBus eventBus;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,11 +138,13 @@ EventListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
for (Contact c : db.getContacts()) {
|
for (Contact c : contactManager.getContacts()) {
|
||||||
try {
|
try {
|
||||||
GroupId inbox = db.getInboxGroupId(c.getId());
|
ContactId id = c.getId();
|
||||||
|
GroupId inbox =
|
||||||
|
messagingManager.getInboxGroupId(id);
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
db.getInboxMessageHeaders(c.getId());
|
messagingManager.getInboxMessageHeaders(id);
|
||||||
displayContact(c, inbox, headers);
|
displayContact(c, inbox, headers);
|
||||||
} catch (NoSuchContactException e) {
|
} catch (NoSuchContactException e) {
|
||||||
// Continue
|
// Continue
|
||||||
@@ -256,7 +260,7 @@ EventListener {
|
|||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
db.removeContact(c);
|
contactManager.removeContact(c);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
LOG.log(WARNING, e.toString(), e);
|
||||||
@@ -290,7 +294,7 @@ EventListener {
|
|||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
db.getInboxMessageHeaders(c);
|
messagingManager.getInboxMessageHeaders(c);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Partial load took " + duration + " ms");
|
LOG.info("Partial load took " + duration + " ms");
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import org.briarproject.android.util.LayoutUtils;
|
|||||||
import org.briarproject.api.android.AndroidNotificationManager;
|
import org.briarproject.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.api.contact.Contact;
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.crypto.CryptoExecutor;
|
import org.briarproject.api.crypto.CryptoExecutor;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
import org.briarproject.api.db.NoSuchMessageException;
|
import org.briarproject.api.db.NoSuchMessageException;
|
||||||
@@ -38,6 +38,7 @@ import org.briarproject.api.event.MessageAddedEvent;
|
|||||||
import org.briarproject.api.event.MessagesAckedEvent;
|
import org.briarproject.api.event.MessagesAckedEvent;
|
||||||
import org.briarproject.api.event.MessagesSentEvent;
|
import org.briarproject.api.event.MessagesSentEvent;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.sync.Group;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
@@ -89,7 +90,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
private ImageButton sendButton = null;
|
private ImageButton sendButton = null;
|
||||||
|
|
||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile ContactManager contactManager;
|
||||||
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
@Inject private volatile EventBus eventBus;
|
@Inject private volatile EventBus eventBus;
|
||||||
@Inject private volatile MessageFactory messageFactory;
|
@Inject private volatile MessageFactory messageFactory;
|
||||||
private volatile ContactId contactId = null;
|
private volatile ContactId contactId = null;
|
||||||
@@ -162,11 +164,11 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Contact contact = db.getContact(contactId);
|
Contact contact = contactManager.getContact(contactId);
|
||||||
contactName = contact.getAuthor().getName();
|
contactName = contact.getAuthor().getName();
|
||||||
localAuthorId = contact.getLocalAuthorId();
|
localAuthorId = contact.getLocalAuthorId();
|
||||||
groupId = db.getInboxGroupId(contactId);
|
groupId = messagingManager.getInboxGroupId(contactId);
|
||||||
group = db.getGroup(groupId);
|
group = messagingManager.getGroup(groupId);
|
||||||
connected = connectionRegistry.isConnected(contactId);
|
connected = connectionRegistry.isConnected(contactId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (LOG.isLoggable(INFO)) {
|
||||||
@@ -208,7 +210,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
Collection<MessageHeader> headers =
|
Collection<MessageHeader> headers =
|
||||||
db.getInboxMessageHeaders(contactId);
|
messagingManager.getInboxMessageHeaders(contactId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Loading headers took " + duration + " ms");
|
LOG.info("Loading headers took " + duration + " ms");
|
||||||
@@ -254,7 +256,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
byte[] body = db.getMessageBody(h.getId());
|
byte[] body = messagingManager.getMessageBody(h.getId());
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Loading message took " + duration + " ms");
|
LOG.info("Loading message took " + duration + " ms");
|
||||||
@@ -324,7 +326,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
for (MessageId m : unread) db.setReadFlag(m, true);
|
for (MessageId m : unread)
|
||||||
|
messagingManager.setReadFlag(m, true);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Marking read took " + duration + " ms");
|
LOG.info("Marking read took " + duration + " ms");
|
||||||
@@ -438,7 +441,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
db.addLocalMessage(m);
|
messagingManager.addLocalMessage(m);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Storing message took " + duration + " ms");
|
LOG.info("Storing message took " + duration + " ms");
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ import org.briarproject.android.util.AuthorView;
|
|||||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||||
import org.briarproject.android.util.HorizontalBorder;
|
import org.briarproject.android.util.HorizontalBorder;
|
||||||
import org.briarproject.android.util.LayoutUtils;
|
import org.briarproject.android.util.LayoutUtils;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchMessageException;
|
import org.briarproject.api.db.NoSuchMessageException;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.MessageId;
|
import org.briarproject.api.sync.MessageId;
|
||||||
import org.briarproject.util.StringUtils;
|
import org.briarproject.util.StringUtils;
|
||||||
@@ -58,7 +58,7 @@ implements OnClickListener {
|
|||||||
private int position = -1;
|
private int position = -1;
|
||||||
|
|
||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
private volatile MessageId messageId = null;
|
private volatile MessageId messageId = null;
|
||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ implements OnClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
db.setReadFlag(messageId, true);
|
messagingManager.setReadFlag(messageId, true);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Marking read took " + duration + " ms");
|
LOG.info("Marking read took " + duration + " ms");
|
||||||
@@ -189,7 +189,7 @@ implements OnClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
byte[] body = db.getMessageBody(messageId);
|
byte[] body = messagingManager.getMessageBody(messageId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Loading message took " + duration + " ms");
|
LOG.info("Loading message took " + duration + " ms");
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ import org.briarproject.android.BriarActivity;
|
|||||||
import org.briarproject.android.util.CommonLayoutParams;
|
import org.briarproject.android.util.CommonLayoutParams;
|
||||||
import org.briarproject.android.util.LayoutUtils;
|
import org.briarproject.android.util.LayoutUtils;
|
||||||
import org.briarproject.api.crypto.CryptoExecutor;
|
import org.briarproject.api.crypto.CryptoExecutor;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
import org.briarproject.api.identity.LocalAuthor;
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
import org.briarproject.api.messaging.MessagingManager;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.sync.Group;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.Message;
|
import org.briarproject.api.sync.Message;
|
||||||
@@ -62,7 +63,8 @@ implements OnClickListener {
|
|||||||
private EditText content = null;
|
private EditText content = null;
|
||||||
|
|
||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile IdentityManager identityManager;
|
||||||
|
@Inject private volatile MessagingManager messagingManager;
|
||||||
@Inject private volatile MessageFactory messageFactory;
|
@Inject private volatile MessageFactory messageFactory;
|
||||||
private volatile String contactName = null;
|
private volatile String contactName = null;
|
||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
@@ -146,8 +148,8 @@ implements OnClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
localAuthor = db.getLocalAuthor(localAuthorId);
|
localAuthor = identityManager.getLocalAuthor(localAuthorId);
|
||||||
group = db.getGroup(groupId);
|
group = messagingManager.getGroup(groupId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Load took " + duration + " ms");
|
LOG.info("Load took " + duration + " ms");
|
||||||
@@ -207,7 +209,7 @@ implements OnClickListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
db.addLocalMessage(m);
|
messagingManager.addLocalMessage(m);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Storing message took " + duration + " ms");
|
LOG.info("Storing message took " + duration + " ms");
|
||||||
|
|||||||
Reference in New Issue
Block a user