mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Use new UI/DB interfaces for forums.
This commit is contained in:
@@ -12,7 +12,6 @@ import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||
import org.briarproject.api.event.Event;
|
||||
@@ -21,6 +20,7 @@ import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import org.briarproject.api.event.SubscriptionAddedEvent;
|
||||
import org.briarproject.api.event.SubscriptionRemovedEvent;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
@@ -46,7 +46,7 @@ implements EventListener, OnItemClickListener {
|
||||
private ListLoadingProgressBar loading = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
@@ -78,10 +78,11 @@ implements EventListener, OnItemClickListener {
|
||||
Collection<ForumContacts> available =
|
||||
new ArrayList<ForumContacts>();
|
||||
long now = System.currentTimeMillis();
|
||||
for (Group g : db.getAvailableGroups()) {
|
||||
for (Group g : forumManager.getAvailableGroups()) {
|
||||
try {
|
||||
GroupId id = g.getId();
|
||||
Collection<Contact> c = db.getSubscribers(id);
|
||||
Collection<Contact> c =
|
||||
forumManager.getSubscribers(id);
|
||||
available.add(new ForumContacts(g, c));
|
||||
} catch (NoSuchSubscriptionException e) {
|
||||
// Continue
|
||||
@@ -151,8 +152,8 @@ implements EventListener, OnItemClickListener {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
db.addGroup(g);
|
||||
db.setVisibility(g.getId(), visible);
|
||||
forumManager.addGroup(g);
|
||||
forumManager.setVisibility(g.getId(), visible);
|
||||
} catch (DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
|
||||
@@ -16,8 +16,8 @@ import android.widget.Toast;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.util.StringUtils;
|
||||
@@ -53,7 +53,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile GroupFactory groupFactory;
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -140,7 +140,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
try {
|
||||
Group g = groupFactory.createGroup(name);
|
||||
long now = System.currentTimeMillis();
|
||||
db.addGroup(g);
|
||||
forumManager.addGroup(g);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Storing forum took " + duration + " ms");
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||
@@ -27,6 +26,7 @@ import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.EventListener;
|
||||
import org.briarproject.api.event.MessageAddedEvent;
|
||||
import org.briarproject.api.event.SubscriptionRemovedEvent;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
@@ -71,7 +71,7 @@ OnClickListener, OnItemClickListener {
|
||||
private ImageButton composeButton = null, shareButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Group group = null;
|
||||
@@ -152,7 +152,7 @@ OnClickListener, OnItemClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
group = db.getGroup(groupId);
|
||||
group = forumManager.getGroup(groupId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Loading group " + duration + " ms");
|
||||
@@ -181,7 +181,7 @@ OnClickListener, OnItemClickListener {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<MessageHeader> headers =
|
||||
db.getMessageHeaders(groupId);
|
||||
forumManager.getMessageHeaders(groupId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Load took " + duration + " ms");
|
||||
@@ -228,7 +228,7 @@ OnClickListener, OnItemClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
byte[] body = db.getMessageBody(h.getId());
|
||||
byte[] body = forumManager.getMessageBody(h.getId());
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Loading message took " + duration + " ms");
|
||||
@@ -298,7 +298,8 @@ OnClickListener, OnItemClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
for (MessageId m : unread) db.setReadFlag(m, true);
|
||||
for (MessageId m : unread)
|
||||
forumManager.setReadFlag(m, true);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Marking read took " + duration + " ms");
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||
import org.briarproject.api.event.Event;
|
||||
@@ -33,6 +32,7 @@ import org.briarproject.api.event.MessageAddedEvent;
|
||||
import org.briarproject.api.event.RemoteSubscriptionsUpdatedEvent;
|
||||
import org.briarproject.api.event.SubscriptionAddedEvent;
|
||||
import org.briarproject.api.event.SubscriptionRemovedEvent;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageHeader;
|
||||
@@ -77,7 +77,7 @@ OnCreateContextMenuListener {
|
||||
private ImageButton newForumButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
@@ -153,14 +153,16 @@ OnCreateContextMenuListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
for (Group g : db.getGroups()) {
|
||||
for (Group g : forumManager.getGroups()) {
|
||||
try {
|
||||
displayHeaders(g, db.getMessageHeaders(g.getId()));
|
||||
Collection<MessageHeader> headers =
|
||||
forumManager.getMessageHeaders(g.getId());
|
||||
displayHeaders(g, headers);
|
||||
} catch (NoSuchSubscriptionException e) {
|
||||
// Continue
|
||||
}
|
||||
}
|
||||
int available = db.getAvailableGroups().size();
|
||||
int available = forumManager.getAvailableGroups().size();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Full load took " + duration + " ms");
|
||||
@@ -279,7 +281,7 @@ OnCreateContextMenuListener {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<MessageHeader> headers =
|
||||
db.getMessageHeaders(g.getId());
|
||||
forumManager.getMessageHeaders(g.getId());
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Partial load took " + duration + " ms");
|
||||
@@ -318,7 +320,7 @@ OnCreateContextMenuListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
int available = db.getAvailableGroups().size();
|
||||
int available = forumManager.getAvailableGroups().size();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Loading available took " + duration + " ms");
|
||||
@@ -373,7 +375,7 @@ OnCreateContextMenuListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
db.removeGroup(g);
|
||||
forumManager.removeGroup(g);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Removing group took " + duration + " ms");
|
||||
|
||||
@@ -17,9 +17,9 @@ import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
@@ -57,7 +57,7 @@ implements OnClickListener {
|
||||
private int position = -1;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
private volatile MessageId messageId = null;
|
||||
|
||||
@Override
|
||||
@@ -169,7 +169,7 @@ implements OnClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
db.setReadFlag(messageId, true);
|
||||
forumManager.setReadFlag(messageId, true);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Marking read took " + duration + " ms");
|
||||
@@ -186,7 +186,7 @@ implements OnClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
byte[] body = db.getMessageBody(messageId);
|
||||
byte[] body = forumManager.getMessageBody(messageId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Loading message took " + duration + " ms");
|
||||
|
||||
@@ -17,8 +17,9 @@ import org.briarproject.android.invitation.AddContactActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
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.forum.ForumManager;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -50,7 +51,8 @@ SelectContactsDialog.Listener {
|
||||
private boolean changed = false;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile ContactManager contactManager;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Collection<Contact> contacts = null;
|
||||
private volatile Collection<ContactId> selected = null;
|
||||
@@ -136,8 +138,8 @@ SelectContactsDialog.Listener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
contacts = db.getContacts();
|
||||
selected = db.getVisibility(groupId);
|
||||
contacts = contactManager.getContacts();
|
||||
selected = forumManager.getVisibility(groupId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Load took " + duration + " ms");
|
||||
@@ -173,8 +175,8 @@ SelectContactsDialog.Listener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
db.setVisibleToAll(groupId, all);
|
||||
if (!all) db.setVisibility(groupId, selected);
|
||||
forumManager.setVisibleToAll(groupId, all);
|
||||
if (!all) forumManager.setVisibility(groupId, selected);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Update took " + duration + " ms");
|
||||
|
||||
@@ -27,9 +27,10 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.crypto.KeyParser;
|
||||
import org.briarproject.api.crypto.PrivateKey;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
@@ -75,7 +76,8 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private GroupId groupId = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile DatabaseComponent db;
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile MessageFactory messageFactory;
|
||||
private volatile MessageId parentId = null;
|
||||
@@ -166,8 +168,9 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<LocalAuthor> localAuthors = db.getLocalAuthors();
|
||||
group = db.getGroup(groupId);
|
||||
Collection<LocalAuthor> localAuthors =
|
||||
identityManager.getLocalAuthors();
|
||||
group = forumManager.getGroup(groupId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Load took " + duration + " ms");
|
||||
@@ -292,7 +295,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
public void run() {
|
||||
try {
|
||||
long now = System.currentTimeMillis();
|
||||
db.addLocalMessage(m);
|
||||
forumManager.addLocalMessage(m);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Storing message took " + duration + " ms");
|
||||
|
||||
Reference in New Issue
Block a user