Merge branch '322-forum-sharing-client' into 'master'

Forum Sharing Client Backend

This MR replaces the old `ForumSharingManagerImpl` with a new one
which is based on state machines and the `ProtocolEngine`.

There is a `SharerEngine` and a `InviteeEngine` that take care of state
transitions, messages, events and trigger actions to be carried out by
the `ForumSharingManagerImpl`. This is all very similar to the
Introduction Client.

The general sharing paradigm has been changed from sharing as a state to
sharing as an action. Now the UI can allow users to invite contacts to
forums. The contacts can accept or decline the invitation. Also, the
Forum Sharing Manager is notified when users leave a forum.

Please note that you will need the UI to actually test this. It is coming up soon in another MR.

Closes #322

See merge request !170
This commit is contained in:
akwizgran
2016-05-09 16:30:21 +00:00
28 changed files with 1735 additions and 353 deletions

View File

@@ -8,7 +8,7 @@ abstract class ConversationIntroductionItem extends ConversationItem {
private boolean answered;
public ConversationIntroductionItem(IntroductionRequest ir) {
super(ir.getMessageId(), ir.getTime());
super(ir.getMessageId(), ir.getTimestamp());
this.ir = ir;
this.answered = ir.wasAnswered();

View File

@@ -69,7 +69,7 @@ public abstract class ConversationItem {
ir.getName());
}
return new ConversationNoticeOutItem(ir.getMessageId(), text,
ir.getTime(), ir.isSent(), ir.isSeen());
ir.getTimestamp(), ir.isSent(), ir.isSeen());
} else {
String text;
if (ir.wasAccepted()) {
@@ -88,7 +88,7 @@ public abstract class ConversationItem {
}
}
return new ConversationNoticeInItem(ir.getMessageId(), text,
ir.getTime(), ir.isRead());
ir.getTimestamp(), ir.isRead());
}
}
@@ -98,9 +98,9 @@ public abstract class ConversationItem {
public static ConversationItem from(IntroductionMessage im) {
if (im.isLocal())
return new ConversationNoticeOutItem(im.getMessageId(), "",
im.getTime(), false, false);
return new ConversationNoticeInItem(im.getMessageId(), "", im.getTime(),
im.isRead());
im.getTimestamp(), false, false);
return new ConversationNoticeInItem(im.getMessageId(), "",
im.getTimestamp(), im.isRead());
}
protected interface OutgoingItem {

View File

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

View File

@@ -91,7 +91,6 @@ public class ShareForumActivity extends BriarActivity implements
onBackPressed();
return true;
case R.id.action_share_forum:
storeVisibility();
return true;
default:
return super.onOptionsItemSelected(item);
@@ -140,26 +139,6 @@ public class ShareForumActivity extends BriarActivity implements
});
}
private void storeVisibility() {
runOnDbThread(new Runnable() {
public void run() {
try {
long now = System.currentTimeMillis();
Collection<ContactId> selected =
adapter.getSelectedContactIds();
forumSharingManager.setSharedWith(groupId, selected);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Update took " + duration + " ms");
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
}
finishOnUiThread();
}
});
}
@Override
public void onItemClick(View view, ContactListItem item) {
((SelectableContactListItem) item).toggleSelected();