mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Addressing second round of review issues
This commit is contained in:
@@ -4,12 +4,15 @@ import android.support.annotation.Nullable;
|
||||
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.android.threaded.ThreadListControllerImpl;
|
||||
import org.briarproject.api.clients.MessageTracker.GroupCount;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.GroupMessageAddedEvent;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.privategroup.GroupMessage;
|
||||
import org.briarproject.api.privategroup.GroupMessageHeader;
|
||||
@@ -18,8 +21,6 @@ import org.briarproject.api.privategroup.PrivateGroupManager;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -36,19 +37,19 @@ public class GroupControllerImpl
|
||||
|
||||
@Inject
|
||||
GroupControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||
LifecycleManager lifecycleManager,
|
||||
LifecycleManager lifecycleManager, IdentityManager identityManager,
|
||||
@CryptoExecutor Executor cryptoExecutor,
|
||||
PrivateGroupManager privateGroupManager, EventBus eventBus,
|
||||
AndroidNotificationManager notificationManager) {
|
||||
super(dbExecutor, lifecycleManager, cryptoExecutor, eventBus,
|
||||
notificationManager);
|
||||
super(dbExecutor, lifecycleManager, identityManager, cryptoExecutor,
|
||||
eventBus, notificationManager);
|
||||
this.privateGroupManager = privateGroupManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResume() {
|
||||
super.onActivityResume();
|
||||
notificationManager.clearForumPostNotification(getGroupId());
|
||||
// TODO: Add new notification manager methods for private groups
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +57,7 @@ public class GroupControllerImpl
|
||||
super.eventOccurred(e);
|
||||
|
||||
if (e instanceof GroupMessageAddedEvent) {
|
||||
final GroupMessageAddedEvent gmae = (GroupMessageAddedEvent) e;
|
||||
GroupMessageAddedEvent gmae = (GroupMessageAddedEvent) e;
|
||||
if (!gmae.isLocal() && gmae.getGroupId().equals(getGroupId())) {
|
||||
LOG.info("Group message received, adding...");
|
||||
final GroupMessageHeader h = gmae.getHeader();
|
||||
@@ -71,7 +72,7 @@ public class GroupControllerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PrivateGroup loadGroupItem() throws DbException {
|
||||
protected PrivateGroup loadNamedGroup() throws DbException {
|
||||
return privateGroupManager.getPrivateGroup(getGroupId());
|
||||
}
|
||||
|
||||
@@ -81,18 +82,8 @@ public class GroupControllerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<MessageId, String> loadBodies(
|
||||
Collection<GroupMessageHeader> headers)
|
||||
throws DbException {
|
||||
Map<MessageId, String> bodies = new HashMap<>();
|
||||
for (GroupMessageHeader header : headers) {
|
||||
if (!bodyCache.containsKey(header.getId())) {
|
||||
String body =
|
||||
privateGroupManager.getMessageBody(header.getId());
|
||||
bodies.put(header.getId(), body);
|
||||
}
|
||||
}
|
||||
return bodies;
|
||||
protected String loadMessageBody(MessageId id) throws DbException {
|
||||
return privateGroupManager.getMessageBody(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,10 +92,17 @@ public class GroupControllerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GroupMessage createLocalMessage(String body,
|
||||
@Nullable MessageId parentId) throws DbException {
|
||||
protected long getLatestTimestamp() throws DbException {
|
||||
GroupCount count = privateGroupManager.getGroupCount(getGroupId());
|
||||
return count.getLatestMsgTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GroupMessage createLocalMessage(String body, long timestamp,
|
||||
@Nullable MessageId parentId, LocalAuthor author) {
|
||||
return privateGroupManager
|
||||
.createLocalMessage(getGroupId(), body, parentId);
|
||||
.createLocalMessage(getGroupId(), body, timestamp, parentId,
|
||||
author);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +112,7 @@ public class GroupControllerImpl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteGroupItem(PrivateGroup group) throws DbException {
|
||||
protected void deleteNamedGroup(PrivateGroup group) throws DbException {
|
||||
privateGroupManager.removePrivateGroup(group.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class GroupListAdapter extends BriarAdapter<GroupItem, GroupViewHolder> {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(GroupViewHolder ui, int position) {
|
||||
ui.bindView(ctx, getItemAt(position), listener);
|
||||
ui.bindView(ctx, items.get(position), listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,6 +68,7 @@ public class GroupListControllerImpl extends DbControllerImpl
|
||||
throw new IllegalStateException(
|
||||
"GroupListListener needs to be attached");
|
||||
eventBus.addListener(this);
|
||||
// TODO: Add new notification manager methods for private groups
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.briarproject.android.privategroup.list;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityOptionsCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
@@ -51,7 +50,7 @@ class GroupViewHolder extends RecyclerView.ViewHolder {
|
||||
remove = (Button) v.findViewById(R.id.removeButton);
|
||||
}
|
||||
|
||||
void bindView(final Context ctx, @Nullable final GroupItem group,
|
||||
void bindView(final Context ctx, final GroupItem group,
|
||||
@NotNull final OnGroupRemoveClickListener listener) {
|
||||
if (group == null) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user