Prepare for new Forum Sharing Client

Methods for creating, adding and removing forums have been moved to the
`ForumManager`. In order to still handle removing forums properly, a
`RemoveForumHook` has been introduced.

Methods for sharing forums with all current and future contacts have
been removed along with the localGroup where this information was saved.

The `ShareForumActivity` now has the proper label.

The `SessionId` and the `ProtocolEngine` have been moved to the
`clients` package.

This addresses part of #322 and part of what has been discussed in #320.
This commit is contained in:
Torsten Grote
2016-04-26 16:37:40 -03:00
parent 189efe8d97
commit 9f9a216305
31 changed files with 144 additions and 162 deletions

View File

@@ -51,7 +51,7 @@ import org.briarproject.api.introduction.IntroductionManager;
import org.briarproject.api.introduction.IntroductionMessage;
import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.introduction.IntroductionResponse;
import org.briarproject.api.introduction.SessionId;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.messaging.MessagingManager;
import org.briarproject.api.messaging.PrivateMessage;
import org.briarproject.api.messaging.PrivateMessageFactory;

View File

@@ -14,7 +14,7 @@ import android.widget.TextView;
import org.briarproject.R;
import org.briarproject.api.introduction.IntroductionRequest;
import org.briarproject.api.introduction.SessionId;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.messaging.PrivateMessageHeader;
import org.briarproject.util.StringUtils;

View File

@@ -171,7 +171,7 @@ implements EventListener, OnItemClickListener {
runOnDbThread(new Runnable() {
public void run() {
try {
forumSharingManager.addForum(f);
forumManager.addForum(f);
forumSharingManager.setSharedWith(f.getId(), shared);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))

View File

@@ -19,7 +19,7 @@ import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarActivity;
import org.briarproject.api.db.DbException;
import org.briarproject.api.forum.Forum;
import org.briarproject.api.forum.ForumSharingManager;
import org.briarproject.api.forum.ForumManager;
import org.briarproject.util.StringUtils;
import java.util.logging.Logger;
@@ -47,7 +47,7 @@ public class CreateForumActivity extends BriarActivity
// Fields that are accessed from background threads must be volatile
@Inject
protected volatile ForumSharingManager forumSharingManager;
protected volatile ForumManager forumManager;
@Override
public void onCreate(Bundle state) {
@@ -126,8 +126,8 @@ public class CreateForumActivity extends BriarActivity
public void run() {
try {
long now = System.currentTimeMillis();
Forum f = forumSharingManager.createForum(name);
forumSharingManager.addForum(f);
Forum f = forumManager.createForum(name);
forumManager.addForum(f);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Storing forum took " + duration + " ms");

View File

@@ -68,7 +68,7 @@ public class ForumActivity extends BriarActivity implements EventListener,
Logger.getLogger(ForumActivity.class.getName());
@Inject protected AndroidNotificationManager notificationManager;
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
private Map<MessageId, byte[]> bodyCache = new HashMap<>();
private TextView empty = null;
private ForumAdapter adapter = null;
private ListView list = null;
@@ -158,7 +158,6 @@ public class ForumActivity extends BriarActivity implements EventListener,
Intent i2 = new Intent(this, ShareForumActivity.class);
i2.setFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
i2.putExtra(GROUP_ID, groupId.getBytes());
i2.putExtra(FORUM_NAME, forum.getName());
ActivityOptionsCompat options = ActivityOptionsCompat
.makeCustomAnimation(this, android.R.anim.slide_in_left,
android.R.anim.slide_out_right);
@@ -302,7 +301,7 @@ public class ForumActivity extends BriarActivity implements EventListener,
}
private void markPostsRead() {
List<MessageId> unread = new ArrayList<MessageId>();
List<MessageId> unread = new ArrayList<>();
int count = adapter.getCount();
for (int i = 0; i < count; i++) {
ForumPostHeader h = adapter.getItem(i).getHeader();

View File

@@ -401,7 +401,7 @@ public class ForumListFragment extends BaseEventFragment implements
public void run() {
try {
long now = System.currentTimeMillis();
forumSharingManager.removeForum(f);
forumManager.removeForum(f);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Removing forum took " + duration + " ms");

View File

@@ -33,7 +33,6 @@ import javax.inject.Inject;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.android.forum.ForumActivity.FORUM_NAME;
public class ShareForumActivity extends BriarActivity implements
BaseContactListAdapter.OnItemClickListener {
@@ -59,9 +58,6 @@ public class ShareForumActivity extends BriarActivity implements
byte[] b = i.getByteArrayExtra(GROUP_ID);
if (b == null) throw new IllegalStateException();
groupId = new GroupId(b);
String forumName = i.getStringExtra(FORUM_NAME);
if (forumName == null) throw new IllegalStateException();
setTitle(forumName);
adapter = new ContactSelectorAdapter(this, this);
BriarRecyclerView list =
@@ -112,11 +108,9 @@ public class ShareForumActivity extends BriarActivity implements
public void run() {
try {
long now = System.currentTimeMillis();
List<ContactListItem> contacts =
new ArrayList<ContactListItem>();
Collection<ContactId> selectedContacts =
new HashSet<ContactId>(
forumSharingManager.getSharedWith(groupId));
List<ContactListItem> contacts = new ArrayList<>();
Collection<ContactId> selectedContacts = new HashSet<>(
forumSharingManager.getSharedWith(groupId));
for (Contact c : contactManager.getActiveContacts()) {
LocalAuthor localAuthor = identityManager