mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Merge branch '646-shared-with-subtitle' into 'master'
Add blog sharing information to toolbar subtitle This MR introduces a new `SharingController` which is supposed to be used in activities that show blogs, groups and forums. Feedback on this approach is welcome before this is used to add "Shared with" support to other parts of the UI. The toolbar subtitle shows information about how many contacts the current shareable is shared with and how many of those are online. So far this is implemented for blogs:  One part of #646 See merge request !447
This commit is contained in:
@@ -2,38 +2,60 @@ package org.briarproject.briar.android.blog;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
import org.briarproject.briar.android.activity.BriarActivity;
|
import org.briarproject.briar.android.activity.BriarActivity;
|
||||||
import org.briarproject.briar.android.blog.BlogPostAdapter.OnBlogPostClickListener;
|
import org.briarproject.briar.android.blog.BlogPostAdapter.OnBlogPostClickListener;
|
||||||
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
|
import org.briarproject.briar.android.fragment.BaseFragment.BaseFragmentListener;
|
||||||
|
import org.briarproject.briar.android.sharing.BlogSharingStatusActivity;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public class BlogActivity extends BriarActivity implements
|
public class BlogActivity extends BriarActivity implements
|
||||||
OnBlogPostClickListener, BaseFragmentListener {
|
OnBlogPostClickListener, BaseFragmentListener {
|
||||||
|
|
||||||
static final int REQUEST_WRITE_POST = 1;
|
static final int REQUEST_WRITE_POST = 2;
|
||||||
static final int REQUEST_SHARE = 2;
|
static final int REQUEST_SHARE = 3;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BlogController blogController;
|
BlogController blogController;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(@Nullable Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
// GroupId from Intent
|
// GroupId from Intent
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
byte[] b = i.getByteArrayExtra(GROUP_ID);
|
byte[] b = i.getByteArrayExtra(GROUP_ID);
|
||||||
if (b == null) throw new IllegalStateException("No group ID in intent");
|
if (b == null) throw new IllegalStateException("No group ID in intent");
|
||||||
GroupId groupId = new GroupId(b);
|
final GroupId groupId = new GroupId(b);
|
||||||
blogController.setGroupId(groupId);
|
blogController.setGroupId(groupId);
|
||||||
|
|
||||||
setContentView(R.layout.activity_fragment_container);
|
setContentView(R.layout.activity_fragment_container);
|
||||||
|
|
||||||
|
// Open Sharing Status on ActionBar click
|
||||||
|
View actionBar = findViewById(R.id.action_bar);
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setOnClickListener(
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent i = new Intent(BlogActivity.this,
|
||||||
|
BlogSharingStatusActivity.class);
|
||||||
|
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
BlogFragment f = BlogFragment.newInstance(groupId);
|
BlogFragment f = BlogFragment.newInstance(groupId);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
@@ -59,4 +81,5 @@ public class BlogActivity extends BriarActivity implements
|
|||||||
@Override
|
@Override
|
||||||
public void onFragmentCreated(String tag) {
|
public void onFragmentCreated(String tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package org.briarproject.briar.android.blog;
|
package org.briarproject.briar.android.blog;
|
||||||
|
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
@@ -13,6 +17,8 @@ public interface BlogController extends BaseController {
|
|||||||
|
|
||||||
void setGroupId(GroupId g);
|
void setGroupId(GroupId g);
|
||||||
|
|
||||||
|
void setBlogSharingListener(BlogSharingListener listener);
|
||||||
|
|
||||||
void loadBlogPosts(
|
void loadBlogPosts(
|
||||||
ResultExceptionHandler<Collection<BlogPostItem>, DbException> handler);
|
ResultExceptionHandler<Collection<BlogPostItem>, DbException> handler);
|
||||||
|
|
||||||
@@ -23,4 +29,15 @@ public interface BlogController extends BaseController {
|
|||||||
|
|
||||||
void deleteBlog(ResultExceptionHandler<Void, DbException> handler);
|
void deleteBlog(ResultExceptionHandler<Void, DbException> handler);
|
||||||
|
|
||||||
|
void loadSharingContacts(
|
||||||
|
ResultExceptionHandler<Collection<ContactId>, DbException> handler);
|
||||||
|
|
||||||
|
interface BlogSharingListener extends BlogListener {
|
||||||
|
@UiThread
|
||||||
|
void onBlogInvitationAccepted(ContactId c);
|
||||||
|
|
||||||
|
@UiThread
|
||||||
|
void onBlogLeft(ContactId c);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package org.briarproject.briar.android.blog;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
@@ -20,8 +22,13 @@ import org.briarproject.briar.android.controller.handler.ResultExceptionHandler;
|
|||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.blog.Blog;
|
import org.briarproject.briar.api.blog.Blog;
|
||||||
import org.briarproject.briar.api.blog.BlogManager;
|
import org.briarproject.briar.api.blog.BlogManager;
|
||||||
|
import org.briarproject.briar.api.blog.BlogSharingManager;
|
||||||
|
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
|
||||||
import org.briarproject.briar.api.blog.event.BlogPostAddedEvent;
|
import org.briarproject.briar.api.blog.event.BlogPostAddedEvent;
|
||||||
|
import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||||
|
import org.briarproject.briar.api.sharing.event.ContactLeftShareableEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -39,15 +46,19 @@ class BlogControllerImpl extends BaseControllerImpl
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(BlogControllerImpl.class.getName());
|
Logger.getLogger(BlogControllerImpl.class.getName());
|
||||||
|
|
||||||
|
private final BlogSharingManager blogSharingManager;
|
||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
|
private volatile BlogSharingListener listener;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BlogControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
BlogControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||||
LifecycleManager lifecycleManager, EventBus eventBus,
|
LifecycleManager lifecycleManager, EventBus eventBus,
|
||||||
AndroidNotificationManager notificationManager,
|
AndroidNotificationManager notificationManager,
|
||||||
IdentityManager identityManager, BlogManager blogManager) {
|
IdentityManager identityManager, BlogManager blogManager,
|
||||||
|
BlogSharingManager blogSharingManager) {
|
||||||
super(dbExecutor, lifecycleManager, eventBus, notificationManager,
|
super(dbExecutor, lifecycleManager, eventBus, notificationManager,
|
||||||
identityManager, blogManager);
|
identityManager, blogManager);
|
||||||
|
this.blogSharingManager = blogSharingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,6 +87,12 @@ class BlogControllerImpl extends BaseControllerImpl
|
|||||||
groupId = g;
|
groupId = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlogSharingListener(BlogSharingListener listener) {
|
||||||
|
super.setBlogListener(listener);
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
if (groupId == null) throw new IllegalStateException();
|
if (groupId == null) throw new IllegalStateException();
|
||||||
@@ -85,6 +102,20 @@ class BlogControllerImpl extends BaseControllerImpl
|
|||||||
LOG.info("Blog post added");
|
LOG.info("Blog post added");
|
||||||
onBlogPostAdded(b.getHeader(), b.isLocal());
|
onBlogPostAdded(b.getHeader(), b.isLocal());
|
||||||
}
|
}
|
||||||
|
} else if (e instanceof BlogInvitationResponseReceivedEvent) {
|
||||||
|
BlogInvitationResponseReceivedEvent b =
|
||||||
|
(BlogInvitationResponseReceivedEvent) e;
|
||||||
|
InvitationResponse r = b.getResponse();
|
||||||
|
if (r.getGroupId().equals(groupId) && r.wasAccepted()) {
|
||||||
|
LOG.info("Blog invitation accepted");
|
||||||
|
onBlogInvitationAccepted(b.getContactId());
|
||||||
|
}
|
||||||
|
} else if (e instanceof ContactLeftShareableEvent) {
|
||||||
|
ContactLeftShareableEvent s = (ContactLeftShareableEvent) e;
|
||||||
|
if (s.getGroupId().equals(groupId)) {
|
||||||
|
LOG.info("Blog left by contact");
|
||||||
|
onBlogLeft(s.getContactId());
|
||||||
|
}
|
||||||
} else if (e instanceof GroupRemovedEvent) {
|
} else if (e instanceof GroupRemovedEvent) {
|
||||||
GroupRemovedEvent g = (GroupRemovedEvent) e;
|
GroupRemovedEvent g = (GroupRemovedEvent) e;
|
||||||
if (g.getGroup().getId().equals(groupId)) {
|
if (g.getGroup().getId().equals(groupId)) {
|
||||||
@@ -94,6 +125,24 @@ class BlogControllerImpl extends BaseControllerImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onBlogInvitationAccepted(final ContactId c) {
|
||||||
|
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
listener.onBlogInvitationAccepted(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onBlogLeft(final ContactId c) {
|
||||||
|
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
listener.onBlogLeft(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBlogPosts(
|
public void loadBlogPosts(
|
||||||
final ResultExceptionHandler<Collection<BlogPostItem>, DbException> handler) {
|
final ResultExceptionHandler<Collection<BlogPostItem>, DbException> handler) {
|
||||||
@@ -159,4 +208,27 @@ class BlogControllerImpl extends BaseControllerImpl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSharingContacts(
|
||||||
|
final ResultExceptionHandler<Collection<ContactId>, DbException> handler) {
|
||||||
|
if (groupId == null) throw new IllegalStateException();
|
||||||
|
runOnDbThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Collection<Contact> contacts =
|
||||||
|
blogSharingManager.getSharedWith(groupId);
|
||||||
|
Collection<ContactId> contactIds =
|
||||||
|
new ArrayList<>(contacts.size());
|
||||||
|
for (Contact c : contacts) contactIds.add(c.getId());
|
||||||
|
handler.onResult(contactIds);
|
||||||
|
} catch (DbException e) {
|
||||||
|
if (LOG.isLoggable(WARNING))
|
||||||
|
LOG.log(WARNING, e.toString(), e);
|
||||||
|
handler.onException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.support.annotation.UiThread;
|
|||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.app.ActivityOptionsCompat;
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -17,6 +18,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
@@ -24,8 +26,10 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
|||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
import org.briarproject.briar.android.blog.BaseController.BlogListener;
|
import org.briarproject.briar.android.activity.BriarActivity;
|
||||||
|
import org.briarproject.briar.android.blog.BlogController.BlogSharingListener;
|
||||||
import org.briarproject.briar.android.blog.BlogPostAdapter.OnBlogPostClickListener;
|
import org.briarproject.briar.android.blog.BlogPostAdapter.OnBlogPostClickListener;
|
||||||
|
import org.briarproject.briar.android.controller.SharingController;
|
||||||
import org.briarproject.briar.android.controller.handler.UiResultExceptionHandler;
|
import org.briarproject.briar.android.controller.handler.UiResultExceptionHandler;
|
||||||
import org.briarproject.briar.android.fragment.BaseFragment;
|
import org.briarproject.briar.android.fragment.BaseFragment;
|
||||||
import org.briarproject.briar.android.sharing.BlogSharingStatusActivity;
|
import org.briarproject.briar.android.sharing.BlogSharingStatusActivity;
|
||||||
@@ -46,17 +50,20 @@ import static android.widget.Toast.LENGTH_SHORT;
|
|||||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||||
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_SHARE;
|
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_SHARE;
|
||||||
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_WRITE_POST;
|
import static org.briarproject.briar.android.blog.BlogActivity.REQUEST_WRITE_POST;
|
||||||
|
import static org.briarproject.briar.android.controller.SharingController.SharingListener;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
public class BlogFragment extends BaseFragment implements
|
public class BlogFragment extends BaseFragment
|
||||||
BlogListener {
|
implements BlogSharingListener, SharingListener {
|
||||||
|
|
||||||
private final static String TAG = BlogFragment.class.getName();
|
private final static String TAG = BlogFragment.class.getName();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BlogController blogController;
|
BlogController blogController;
|
||||||
|
@Inject
|
||||||
|
SharingController sharingController;
|
||||||
|
|
||||||
private GroupId groupId;
|
private GroupId groupId;
|
||||||
private BlogPostAdapter adapter;
|
private BlogPostAdapter adapter;
|
||||||
@@ -101,13 +108,16 @@ public class BlogFragment extends BaseFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void injectFragment(ActivityComponent component) {
|
public void injectFragment(ActivityComponent component) {
|
||||||
component.inject(this);
|
component.inject(this);
|
||||||
blogController.setBlogListener(this);
|
blogController.setBlogSharingListener(this);
|
||||||
|
sharingController.setSharingListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
sharingController.onStart();
|
||||||
loadBlog();
|
loadBlog();
|
||||||
|
loadSharedContacts();
|
||||||
loadBlogPosts(false);
|
loadBlogPosts(false);
|
||||||
list.startPeriodicUpdate();
|
list.startPeriodicUpdate();
|
||||||
}
|
}
|
||||||
@@ -115,6 +125,7 @@ public class BlogFragment extends BaseFragment implements
|
|||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
sharingController.onStop();
|
||||||
list.stopPeriodicUpdate();
|
list.stopPeriodicUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +266,52 @@ public class BlogFragment extends BaseFragment implements
|
|||||||
getActivity().setTitle(title);
|
getActivity().setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadSharedContacts() {
|
||||||
|
blogController.loadSharingContacts(
|
||||||
|
new UiResultExceptionHandler<Collection<ContactId>, DbException>(this) {
|
||||||
|
@Override
|
||||||
|
public void onResultUi(Collection<ContactId> contacts) {
|
||||||
|
sharingController.addAll(contacts);
|
||||||
|
int online = sharingController.getOnlineCount();
|
||||||
|
setToolbarSubTitle(contacts.size(), online);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExceptionUi(DbException exception) {
|
||||||
|
// TODO: Decide how to handle errors in the UI
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlogInvitationAccepted(ContactId c) {
|
||||||
|
sharingController.add(c);
|
||||||
|
setToolbarSubTitle(sharingController.getTotalCount(),
|
||||||
|
sharingController.getOnlineCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlogLeft(ContactId c) {
|
||||||
|
sharingController.remove(c);
|
||||||
|
setToolbarSubTitle(sharingController.getTotalCount(),
|
||||||
|
sharingController.getOnlineCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSharingInfoUpdated(int total, int online) {
|
||||||
|
setToolbarSubTitle(total, online);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setToolbarSubTitle(int total, int online) {
|
||||||
|
ActionBar actionBar =
|
||||||
|
((BriarActivity) getActivity()).getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setSubtitle(
|
||||||
|
getString(R.string.shared_with, total, online));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showWriteButton() {
|
private void showWriteButton() {
|
||||||
isMyBlog = true;
|
isMyBlog = true;
|
||||||
if (writeButton != null)
|
if (writeButton != null)
|
||||||
@@ -327,4 +384,5 @@ public class BlogFragment extends BaseFragment implements
|
|||||||
public void onBlogRemoved() {
|
public void onBlogRemoved() {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package org.briarproject.briar.android.blog;
|
|||||||
|
|
||||||
import org.briarproject.briar.android.activity.ActivityScope;
|
import org.briarproject.briar.android.activity.ActivityScope;
|
||||||
import org.briarproject.briar.android.activity.BaseActivity;
|
import org.briarproject.briar.android.activity.BaseActivity;
|
||||||
|
import org.briarproject.briar.android.controller.SharingController;
|
||||||
|
import org.briarproject.briar.android.controller.SharingControllerImpl;
|
||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
@@ -22,4 +24,12 @@ public class BlogModule {
|
|||||||
FeedController provideFeedController(FeedControllerImpl feedController) {
|
FeedController provideFeedController(FeedControllerImpl feedController) {
|
||||||
return feedController;
|
return feedController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ActivityScope
|
||||||
|
@Provides
|
||||||
|
SharingController provideSharingController(
|
||||||
|
SharingControllerImpl sharingController) {
|
||||||
|
return sharingController;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package org.briarproject.briar.android.controller;
|
||||||
|
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
|
import org.briarproject.briar.android.DestroyableContext;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
|
public interface SharingController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the listener that is called when contacts go on or offline.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void setSharingListener(SharingListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this when your lifecycle starts,
|
||||||
|
* so the listener will be called when information changes.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void onStart();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this when your lifecycle stops,
|
||||||
|
* so that the controller knows it can stops listening to events.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void onStop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds one contact to be tracked.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void add(ContactId c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a collection of contacts to be tracked.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void addAll(Collection<ContactId> contacts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this when the contact identified by c is no longer sharing
|
||||||
|
* the given group identified by GroupId g.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
void remove(ContactId c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of online contacts.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
int getOnlineCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the total number of contacts that have been added.
|
||||||
|
*/
|
||||||
|
@UiThread
|
||||||
|
int getTotalCount();
|
||||||
|
|
||||||
|
interface SharingListener extends DestroyableContext {
|
||||||
|
@UiThread
|
||||||
|
void onSharingInfoUpdated(int total, int online);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package org.briarproject.briar.android.controller;
|
||||||
|
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.annotation.UiThread;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.event.Event;
|
||||||
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
|
import org.briarproject.bramble.api.event.EventListener;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
|
||||||
|
import org.briarproject.bramble.api.plugin.event.ContactConnectedEvent;
|
||||||
|
import org.briarproject.bramble.api.plugin.event.ContactDisconnectedEvent;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
|
public class SharingControllerImpl implements SharingController, EventListener {
|
||||||
|
|
||||||
|
private final EventBus eventBus;
|
||||||
|
private final ConnectionRegistry connectionRegistry;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private volatile SharingListener listener;
|
||||||
|
// only access on @UiThread
|
||||||
|
private final Set<ContactId> contacts = new HashSet<>();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SharingControllerImpl(EventBus eventBus,
|
||||||
|
ConnectionRegistry connectionRegistry) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.connectionRegistry = connectionRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSharingListener(SharingListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
eventBus.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
eventBus.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(Event e) {
|
||||||
|
if (e instanceof ContactConnectedEvent) {
|
||||||
|
setConnected(((ContactConnectedEvent) e).getContactId());
|
||||||
|
} else if (e instanceof ContactDisconnectedEvent) {
|
||||||
|
setConnected(((ContactDisconnectedEvent) e).getContactId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setConnected(final ContactId c) {
|
||||||
|
if (listener == null) return;
|
||||||
|
listener.runOnUiThreadUnlessDestroyed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (contacts.contains(c)) {
|
||||||
|
int online = getOnlineCount();
|
||||||
|
listener.onSharingInfoUpdated(contacts.size(), online);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addAll(Collection<ContactId> c) {
|
||||||
|
contacts.addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(ContactId c) {
|
||||||
|
contacts.add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(ContactId c) {
|
||||||
|
contacts.remove(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOnlineCount() {
|
||||||
|
int online = 0;
|
||||||
|
for (ContactId c : contacts) {
|
||||||
|
if (connectionRegistry.isConnected(c)) online++;
|
||||||
|
}
|
||||||
|
return online;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTotalCount() {
|
||||||
|
return contacts.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -259,6 +259,7 @@
|
|||||||
<string name="forum_invitation_response_declined_received">%s declined the forum invitation.</string>
|
<string name="forum_invitation_response_declined_received">%s declined the forum invitation.</string>
|
||||||
|
|
||||||
<string name="sharing_status">Sharing Status</string>
|
<string name="sharing_status">Sharing Status</string>
|
||||||
|
<string name="shared_with">Shared with %1$d (%2$d online)</string>
|
||||||
<plurals name="forums_shared">
|
<plurals name="forums_shared">
|
||||||
<item quantity="one">%d forum shared by contacts</item>
|
<item quantity="one">%d forum shared by contacts</item>
|
||||||
<item quantity="other">%d forums shared by contacts</item>
|
<item quantity="other">%d forums shared by contacts</item>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.briarproject.briar.api.sharing.event;
|
||||||
|
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.event.Event;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
|
public class ContactLeftShareableEvent extends Event {
|
||||||
|
|
||||||
|
private final GroupId groupId;
|
||||||
|
private final ContactId contactId;
|
||||||
|
|
||||||
|
public ContactLeftShareableEvent(GroupId groupId, ContactId contactId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.contactId = contactId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupId getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactId getContactId() {
|
||||||
|
return contactId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -258,7 +258,7 @@ class BlogSharingManagerImpl extends
|
|||||||
@Override
|
@Override
|
||||||
public BlogInvitation build(BlogSharerSessionState localState,
|
public BlogInvitation build(BlogSharerSessionState localState,
|
||||||
long time) {
|
long time) {
|
||||||
return new BlogInvitation(localState.getGroupId(),
|
return new BlogInvitation(localState.getContactGroupId(),
|
||||||
localState.getSessionId(), localState.getBlogAuthorName(),
|
localState.getSessionId(), localState.getBlogAuthorName(),
|
||||||
localState.getBlogPublicKey(), time,
|
localState.getBlogPublicKey(), time,
|
||||||
localState.getMessage());
|
localState.getMessage());
|
||||||
@@ -338,7 +338,7 @@ class BlogSharingManagerImpl extends
|
|||||||
ContactId contactId = localState.getContactId();
|
ContactId contactId = localState.getContactId();
|
||||||
BlogInvitationRequest request =
|
BlogInvitationRequest request =
|
||||||
new BlogInvitationRequest(localState.getInvitationId(),
|
new BlogInvitationRequest(localState.getInvitationId(),
|
||||||
localState.getSessionId(), localState.getGroupId(),
|
localState.getSessionId(), localState.getContactGroupId(),
|
||||||
contactId, blog.getAuthor().getName(), msg, true,
|
contactId, blog.getAuthor().getName(), msg, true,
|
||||||
time, false, false, false, false);
|
time, false, false, false, false);
|
||||||
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
||||||
@@ -357,7 +357,8 @@ class BlogSharingManagerImpl extends
|
|||||||
throw new IllegalStateException("No responseId");
|
throw new IllegalStateException("No responseId");
|
||||||
BlogInvitationResponse response =
|
BlogInvitationResponse response =
|
||||||
new BlogInvitationResponse(responseId,
|
new BlogInvitationResponse(responseId,
|
||||||
localState.getSessionId(), localState.getGroupId(),
|
localState.getSessionId(),
|
||||||
|
localState.getShareableId(),
|
||||||
localState.getContactId(), accept, time, false,
|
localState.getContactId(), accept, time, false,
|
||||||
false, false, false);
|
false, false, false);
|
||||||
return new BlogInvitationResponseReceivedEvent(c, response);
|
return new BlogInvitationResponseReceivedEvent(c, response);
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class ForumSharingManagerImpl extends
|
|||||||
@Override
|
@Override
|
||||||
public ForumInvitation build(ForumSharerSessionState localState,
|
public ForumInvitation build(ForumSharerSessionState localState,
|
||||||
long time) {
|
long time) {
|
||||||
return new ForumInvitation(localState.getGroupId(),
|
return new ForumInvitation(localState.getContactGroupId(),
|
||||||
localState.getSessionId(), localState.getForumName(),
|
localState.getSessionId(), localState.getForumName(),
|
||||||
localState.getForumSalt(), time, localState.getMessage());
|
localState.getForumSalt(), time, localState.getMessage());
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ class ForumSharingManagerImpl extends
|
|||||||
ContactId contactId = localState.getContactId();
|
ContactId contactId = localState.getContactId();
|
||||||
ForumInvitationRequest request = new ForumInvitationRequest(
|
ForumInvitationRequest request = new ForumInvitationRequest(
|
||||||
localState.getInvitationId(), localState.getSessionId(),
|
localState.getInvitationId(), localState.getSessionId(),
|
||||||
localState.getGroupId(), contactId, forum.getName(), msg,
|
localState.getContactGroupId(), contactId, forum.getName(), msg,
|
||||||
true, time, false, false, false, false);
|
true, time, false, false, false, false);
|
||||||
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
||||||
request);
|
request);
|
||||||
@@ -287,8 +287,8 @@ class ForumSharingManagerImpl extends
|
|||||||
throw new IllegalStateException("No responseId");
|
throw new IllegalStateException("No responseId");
|
||||||
ForumInvitationResponse response = new ForumInvitationResponse(
|
ForumInvitationResponse response = new ForumInvitationResponse(
|
||||||
responseId, localState.getSessionId(),
|
responseId, localState.getSessionId(),
|
||||||
localState.getGroupId(), localState.getContactId(), accept,
|
localState.getShareableId(), localState.getContactId(),
|
||||||
time, false, false, false, false);
|
accept, time, false, false, false, false);
|
||||||
return new ForumInvitationResponseReceivedEvent(name, c, response);
|
return new ForumInvitationResponseReceivedEvent(name, c, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package org.briarproject.briar.sharing;
|
|||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.briar.api.sharing.event.InvitationRequestReceivedEvent;
|
import org.briarproject.briar.api.sharing.event.InvitationRequestReceivedEvent;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
interface InvitationReceivedEventFactory<IS extends InviteeSessionState, IR extends InvitationRequestReceivedEvent> {
|
interface InvitationReceivedEventFactory<IS extends InviteeSessionState, IR extends InvitationRequestReceivedEvent> {
|
||||||
|
|
||||||
IR build(IS localState, long time, String msg);
|
IR build(IS localState, long time, @Nullable String msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,20 +77,20 @@ class InviteeEngine<IS extends InviteeSessionState, IR extends InvitationRequest
|
|||||||
if (action == InviteeSessionState.Action.LOCAL_ACCEPT) {
|
if (action == InviteeSessionState.Action.LOCAL_ACCEPT) {
|
||||||
localState.setTask(TASK_ADD_SHARED_SHAREABLE);
|
localState.setTask(TASK_ADD_SHARED_SHAREABLE);
|
||||||
msg = new SimpleMessage(SHARE_MSG_TYPE_ACCEPT,
|
msg = new SimpleMessage(SHARE_MSG_TYPE_ACCEPT,
|
||||||
localState.getGroupId(), localState.getSessionId(),
|
localState.getContactGroupId(), localState.getSessionId(),
|
||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
} else {
|
} else {
|
||||||
localState.setTask(
|
localState.setTask(
|
||||||
TASK_REMOVE_SHAREABLE_FROM_LIST_SHARED_WITH_US);
|
TASK_REMOVE_SHAREABLE_FROM_LIST_SHARED_WITH_US);
|
||||||
msg = new SimpleMessage(SHARE_MSG_TYPE_DECLINE,
|
msg = new SimpleMessage(SHARE_MSG_TYPE_DECLINE,
|
||||||
localState.getGroupId(), localState.getSessionId(),
|
localState.getContactGroupId(), localState.getSessionId(),
|
||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
}
|
}
|
||||||
messages = Collections.singletonList(msg);
|
messages = Collections.singletonList(msg);
|
||||||
logLocalAction(currentState, localState, msg);
|
logLocalAction(currentState, localState, msg);
|
||||||
} else if (action == InviteeSessionState.Action.LOCAL_LEAVE) {
|
} else if (action == InviteeSessionState.Action.LOCAL_LEAVE) {
|
||||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
||||||
localState.getGroupId(), localState.getSessionId(),
|
localState.getContactGroupId(), localState.getSessionId(),
|
||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
messages = Collections.singletonList(msg);
|
messages = Collections.singletonList(msg);
|
||||||
logLocalAction(currentState, localState, msg);
|
logLocalAction(currentState, localState, msg);
|
||||||
@@ -221,7 +221,7 @@ class InviteeEngine<IS extends InviteeSessionState, IR extends InvitationRequest
|
|||||||
}
|
}
|
||||||
localState.setState(InviteeSessionState.State.ERROR);
|
localState.setState(InviteeSessionState.State.ERROR);
|
||||||
BaseMessage msg =
|
BaseMessage msg =
|
||||||
new SimpleMessage(SHARE_MSG_TYPE_ABORT, localState.getGroupId(),
|
new SimpleMessage(SHARE_MSG_TYPE_ABORT, localState.getContactGroupId(),
|
||||||
localState.getSessionId(), clock.currentTimeMillis());
|
localState.getSessionId(), clock.currentTimeMillis());
|
||||||
List<BaseMessage> messages = Collections.singletonList(msg);
|
List<BaseMessage> messages = Collections.singletonList(msg);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class SharerEngine<I extends Invitation, SS extends SharerSessionState, IRR exte
|
|||||||
.setTask(TASK_ADD_SHAREABLE_TO_LIST_TO_BE_SHARED_BY_US);
|
.setTask(TASK_ADD_SHAREABLE_TO_LIST_TO_BE_SHARED_BY_US);
|
||||||
} else if (action == SharerSessionState.Action.LOCAL_LEAVE) {
|
} else if (action == SharerSessionState.Action.LOCAL_LEAVE) {
|
||||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_LEAVE,
|
||||||
localState.getGroupId(), localState.getSessionId(),
|
localState.getContactGroupId(), localState.getSessionId(),
|
||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
messages = Collections.singletonList(msg);
|
messages = Collections.singletonList(msg);
|
||||||
logLocalAction(currentState, nextState, msg);
|
logLocalAction(currentState, nextState, msg);
|
||||||
@@ -217,7 +217,7 @@ class SharerEngine<I extends Invitation, SS extends SharerSessionState, IRR exte
|
|||||||
|
|
||||||
localState.setState(SharerSessionState.State.ERROR);
|
localState.setState(SharerSessionState.State.ERROR);
|
||||||
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_ABORT,
|
BaseMessage msg = new SimpleMessage(SHARE_MSG_TYPE_ABORT,
|
||||||
localState.getGroupId(), localState.getSessionId(),
|
localState.getContactGroupId(), localState.getSessionId(),
|
||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
List<BaseMessage> messages = Collections.singletonList(msg);
|
List<BaseMessage> messages = Collections.singletonList(msg);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.briarproject.briar.api.sharing.SharingInvitationItem;
|
|||||||
import org.briarproject.briar.api.sharing.SharingManager;
|
import org.briarproject.briar.api.sharing.SharingManager;
|
||||||
import org.briarproject.briar.api.sharing.event.InvitationRequestReceivedEvent;
|
import org.briarproject.briar.api.sharing.event.InvitationRequestReceivedEvent;
|
||||||
import org.briarproject.briar.api.sharing.event.InvitationResponseReceivedEvent;
|
import org.briarproject.briar.api.sharing.event.InvitationResponseReceivedEvent;
|
||||||
|
import org.briarproject.briar.api.sharing.event.ContactLeftShareableEvent;
|
||||||
import org.briarproject.briar.client.ConversationClientImpl;
|
import org.briarproject.briar.client.ConversationClientImpl;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -301,7 +302,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
// track message
|
// track message
|
||||||
// TODO handle this properly without engine hacks (#376)
|
// TODO handle this properly without engine hacks (#376)
|
||||||
long time = update.toSend.get(0).getTime();
|
long time = update.toSend.get(0).getTime();
|
||||||
messageTracker.trackMessage(txn, localState.getGroupId(), time,
|
messageTracker.trackMessage(txn, localState.getContactGroupId(), time,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
@@ -365,7 +366,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
// track message
|
// track message
|
||||||
// TODO handle this properly without engine hacks (#376)
|
// TODO handle this properly without engine hacks (#376)
|
||||||
long time = update.toSend.get(0).getTime();
|
long time = update.toSend.get(0).getTime();
|
||||||
messageTracker.trackMessage(txn, localState.getGroupId(), time, true);
|
messageTracker.trackMessage(txn, localState.getContactGroupId(), time, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -872,7 +873,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
localState.setTask(-1);
|
localState.setTask(-1);
|
||||||
|
|
||||||
// get group ID for later
|
// get group ID for later
|
||||||
GroupId groupId = localState.getGroupId();
|
GroupId groupId = localState.getContactGroupId();
|
||||||
// get contact ID for later
|
// get contact ID for later
|
||||||
ContactId contactId = localState.getContactId();
|
ContactId contactId = localState.getContactId();
|
||||||
|
|
||||||
@@ -897,9 +898,17 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
} else if (task == TASK_UNSHARE_SHAREABLE_SHARED_BY_US) {
|
} else if (task == TASK_UNSHARE_SHAREABLE_SHARED_BY_US) {
|
||||||
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
||||||
removeFromList(txn, groupId, SHARED_BY_US, f);
|
removeFromList(txn, groupId, SHARED_BY_US, f);
|
||||||
|
// broadcast event informing UI that contact has left the group
|
||||||
|
ContactLeftShareableEvent
|
||||||
|
e = new ContactLeftShareableEvent(f.getId(), contactId);
|
||||||
|
txn.attach(e);
|
||||||
} else if (task == TASK_UNSHARE_SHAREABLE_SHARED_WITH_US) {
|
} else if (task == TASK_UNSHARE_SHAREABLE_SHARED_WITH_US) {
|
||||||
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
db.setGroupVisibility(txn, contactId, f.getId(), INVISIBLE);
|
||||||
removeFromList(txn, groupId, SHARED_WITH_US, f);
|
removeFromList(txn, groupId, SHARED_WITH_US, f);
|
||||||
|
// broadcast event informing UI that contact has left the group
|
||||||
|
ContactLeftShareableEvent
|
||||||
|
e = new ContactLeftShareableEvent(f.getId(), contactId);
|
||||||
|
txn.attach(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ abstract class SharingSessionState {
|
|||||||
BdfDictionary d = new BdfDictionary();
|
BdfDictionary d = new BdfDictionary();
|
||||||
d.put(SESSION_ID, getSessionId());
|
d.put(SESSION_ID, getSessionId());
|
||||||
d.put(STORAGE_ID, getStorageId());
|
d.put(STORAGE_ID, getStorageId());
|
||||||
d.put(GROUP_ID, getGroupId());
|
d.put(GROUP_ID, getContactGroupId());
|
||||||
d.put(CONTACT_ID, getContactId().getInt());
|
d.put(CONTACT_ID, getContactId().getInt());
|
||||||
d.put(SHAREABLE_ID, getShareableId());
|
d.put(SHAREABLE_ID, getShareableId());
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ abstract class SharingSessionState {
|
|||||||
return storageId;
|
return storageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupId getGroupId() {
|
public GroupId getContactGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user