mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Removed public/private groups from the wire protocol.
The distinction between inbox groups and other groups can be maintained internally, there's no need to represent it on the wire.
This commit is contained in:
@@ -77,7 +77,7 @@ SelectContactsDialog.Listener {
|
||||
setTitle(name);
|
||||
b = i.getByteArrayExtra("net.sf.briar.GROUP_SALT");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
group = new Group(id, name, b, false);
|
||||
group = new Group(id, name, b);
|
||||
subscribed = i.getBooleanExtra("net.sf.briar.SUBSCRIBED", false);
|
||||
boolean all = i.getBooleanExtra("net.sf.briar.VISIBLE_TO_ALL", false);
|
||||
|
||||
@@ -208,8 +208,8 @@ SelectContactsDialog.Listener {
|
||||
long now = System.currentTimeMillis();
|
||||
if(subscribe) {
|
||||
if(!wasSubscribed) db.addGroup(group);
|
||||
db.setVisibleToAll(group, all);
|
||||
if(!all) db.setVisibility(group, visible);
|
||||
db.setVisibleToAll(group.getId(), all);
|
||||
if(!all) db.setVisibility(group.getId(), visible);
|
||||
} else if(wasSubscribed) {
|
||||
db.removeGroup(group);
|
||||
}
|
||||
|
||||
@@ -173,11 +173,11 @@ SelectContactsDialog.Listener {
|
||||
public void run() {
|
||||
try {
|
||||
lifecycleManager.waitForDatabase();
|
||||
Group g = groupFactory.createGroup(name, false);
|
||||
Group g = groupFactory.createGroup(name);
|
||||
long now = System.currentTimeMillis();
|
||||
db.addGroup(g);
|
||||
if(all) db.setVisibleToAll(g, true);
|
||||
else db.setVisibility(g, visible);
|
||||
if(all) db.setVisibleToAll(g.getId(), true);
|
||||
else db.setVisibility(g.getId(), visible);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Storing group took " + duration + " ms");
|
||||
|
||||
@@ -15,6 +15,8 @@ import static net.sf.briar.android.util.CommonLayoutParams.MATCH_WRAP_1;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -58,6 +60,9 @@ OnItemClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(GroupListActivity.class.getName());
|
||||
|
||||
private final Map<GroupId,GroupId> groups =
|
||||
new ConcurrentHashMap<GroupId,GroupId>();
|
||||
|
||||
private GroupListAdapter adapter = null;
|
||||
private ListView list = null;
|
||||
private ListLoadingProgressBar loading = null;
|
||||
@@ -140,7 +145,6 @@ OnItemClickListener {
|
||||
long now = System.currentTimeMillis();
|
||||
for(GroupStatus s : db.getAvailableGroups()) {
|
||||
Group g = s.getGroup();
|
||||
if(g.isPrivate()) continue;
|
||||
if(s.isSubscribed()) {
|
||||
try {
|
||||
Collection<MessageHeader> headers =
|
||||
@@ -173,6 +177,7 @@ OnItemClickListener {
|
||||
private void clearHeaders() {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
groups.clear();
|
||||
list.setVisibility(GONE);
|
||||
loading.setVisibility(VISIBLE);
|
||||
adapter.clear();
|
||||
@@ -185,10 +190,12 @@ OnItemClickListener {
|
||||
final Collection<MessageHeader> headers) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
GroupId id = g.getId();
|
||||
groups.put(id, id);
|
||||
list.setVisibility(VISIBLE);
|
||||
loading.setVisibility(GONE);
|
||||
// Remove the old item, if any
|
||||
GroupListItem item = findGroup(g.getId());
|
||||
GroupListItem item = findGroup(id);
|
||||
if(item != null) adapter.remove(item);
|
||||
// Add a new item
|
||||
adapter.add(new GroupListItem(g, headers));
|
||||
@@ -243,7 +250,7 @@ OnItemClickListener {
|
||||
public void eventOccurred(DatabaseEvent e) {
|
||||
if(e instanceof MessageAddedEvent) {
|
||||
Group g = ((MessageAddedEvent) e).getGroup();
|
||||
if(!g.isPrivate()) {
|
||||
if(groups.containsKey(g.getId())) {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Message added, reloading");
|
||||
loadHeaders(g);
|
||||
}
|
||||
@@ -259,7 +266,7 @@ OnItemClickListener {
|
||||
loadHeaders();
|
||||
} else if(e instanceof SubscriptionRemovedEvent) {
|
||||
Group g = ((SubscriptionRemovedEvent) e).getGroup();
|
||||
if(!g.isPrivate()) {
|
||||
if(groups.containsKey(g.getId())) {
|
||||
// Reload the group, expecting NoSuchSubscriptionException
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Group removed, reloading");
|
||||
loadHeaders(g);
|
||||
@@ -299,6 +306,7 @@ OnItemClickListener {
|
||||
public void run() {
|
||||
GroupListItem item = findGroup(g);
|
||||
if(item != null) {
|
||||
groups.remove(g);
|
||||
adapter.remove(item);
|
||||
adapter.notifyDataSetChanged();
|
||||
selectFirstUnread();
|
||||
@@ -314,10 +322,8 @@ OnItemClickListener {
|
||||
lifecycleManager.waitForDatabase();
|
||||
int available = 0;
|
||||
long now = System.currentTimeMillis();
|
||||
for(GroupStatus s : db.getAvailableGroups()) {
|
||||
if(!s.isSubscribed() && !s.getGroup().isPrivate())
|
||||
available++;
|
||||
}
|
||||
for(GroupStatus s : db.getAvailableGroups())
|
||||
if(!s.isSubscribed()) available++;
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Loading available took " + duration + " ms");
|
||||
|
||||
@@ -5,7 +5,6 @@ import static java.util.logging.Level.WARNING;
|
||||
import static net.sf.briar.android.groups.ManageGroupsItem.NONE;
|
||||
import static net.sf.briar.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -76,10 +75,7 @@ implements DatabaseListener, OnItemClickListener {
|
||||
try {
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<GroupStatus> available =
|
||||
new ArrayList<GroupStatus>();
|
||||
for(GroupStatus s : db.getAvailableGroups())
|
||||
if(!s.getGroup().isPrivate()) available.add(s);
|
||||
Collection<GroupStatus> available = db.getAvailableGroups();
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Load took " + duration + " ms");
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.lifecycle.LifecycleManager;
|
||||
import net.sf.briar.api.messaging.Group;
|
||||
import net.sf.briar.api.messaging.GroupId;
|
||||
import net.sf.briar.api.messaging.GroupStatus;
|
||||
import net.sf.briar.api.messaging.Message;
|
||||
import net.sf.briar.api.messaging.MessageFactory;
|
||||
import net.sf.briar.api.messaging.MessageId;
|
||||
@@ -215,8 +216,8 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
lifecycleManager.waitForDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
Collection<Group> groups = new ArrayList<Group>();
|
||||
for(Group g : db.getGroups())
|
||||
if(!g.isPrivate()) groups.add(g);
|
||||
for(GroupStatus s : db.getAvailableGroups())
|
||||
if(s.isSubscribed()) groups.add(s.getGroup());
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Loading groups took " + duration + " ms");
|
||||
|
||||
Reference in New Issue
Block a user