mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Don't try to load a group before subscribing to it.
This commit is contained in:
@@ -58,7 +58,7 @@
|
|||||||
<string name="groups_title">Groups</string>
|
<string name="groups_title">Groups</string>
|
||||||
<plurals name="groups_available">
|
<plurals name="groups_available">
|
||||||
<item quantity="one">%1$d group available from contacts</item>
|
<item quantity="one">%1$d group available from contacts</item>
|
||||||
<item quantity="two">$1$d groups available from contacts</item>
|
<item quantity="other">$1$d groups available from contacts</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="no_posts">No posts</string>
|
<string name="no_posts">No posts</string>
|
||||||
<string name="subscribe_to_this_group">Subscribe to this group</string>
|
<string name="subscribe_to_this_group">Subscribe to this group</string>
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
<string name="blogs_title">Blogs</string>
|
<string name="blogs_title">Blogs</string>
|
||||||
<plurals name="blogs_available">
|
<plurals name="blogs_available">
|
||||||
<item quantity="one">%1$d blog available from contacts</item>
|
<item quantity="one">%1$d blog available from contacts</item>
|
||||||
<item quantity="two">$1$d blogs available from contacts</item>
|
<item quantity="other">$1$d blogs available from contacts</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
<string name="manage_subscriptions_title">Manage Subscriptions</string>
|
<string name="manage_subscriptions_title">Manage Subscriptions</string>
|
||||||
<string name="subscribed_all">Subscribed, shared with all contacts</string>
|
<string name="subscribed_all">Subscribed, shared with all contacts</string>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import net.sf.briar.api.ContactId;
|
|||||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||||
import net.sf.briar.api.db.DatabaseComponent;
|
import net.sf.briar.api.db.DatabaseComponent;
|
||||||
import net.sf.briar.api.db.DbException;
|
import net.sf.briar.api.db.DbException;
|
||||||
|
import net.sf.briar.api.messaging.Group;
|
||||||
import net.sf.briar.api.messaging.GroupId;
|
import net.sf.briar.api.messaging.GroupId;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -60,7 +61,7 @@ SelectContactsDialog.Listener {
|
|||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile DatabaseComponent db;
|
||||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||||
private volatile GroupId groupId = null;
|
private volatile Group group = null;
|
||||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,10 +71,13 @@ SelectContactsDialog.Listener {
|
|||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
||||||
if(b == null) throw new IllegalStateException();
|
if(b == null) throw new IllegalStateException();
|
||||||
groupId = new GroupId(b);
|
GroupId id = new GroupId(b);
|
||||||
String groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
String name = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||||
if(groupName == null) throw new IllegalArgumentException();
|
if(name == null) throw new IllegalStateException();
|
||||||
setTitle(groupName);
|
setTitle(name);
|
||||||
|
byte[] publicKey = i.getByteArrayExtra("net.sf.briar.PUBLIC_KEY");
|
||||||
|
if(publicKey == null) throw new IllegalStateException();
|
||||||
|
group = new Group(id, name, publicKey);
|
||||||
wasSubscribed = i.getBooleanExtra("net.sf.briar.SUBSCRIBED", false);
|
wasSubscribed = i.getBooleanExtra("net.sf.briar.SUBSCRIBED", false);
|
||||||
boolean all = i.getBooleanExtra("net.sf.briar.VISIBLE_TO_ALL", false);
|
boolean all = i.getBooleanExtra("net.sf.briar.VISIBLE_TO_ALL", false);
|
||||||
|
|
||||||
@@ -90,17 +94,18 @@ SelectContactsDialog.Listener {
|
|||||||
|
|
||||||
radioGroup = new RadioGroup(this);
|
radioGroup = new RadioGroup(this);
|
||||||
radioGroup.setOrientation(VERTICAL);
|
radioGroup.setOrientation(VERTICAL);
|
||||||
radioGroup.setEnabled(wasSubscribed);
|
|
||||||
|
|
||||||
visibleToAll = new RadioButton(this);
|
visibleToAll = new RadioButton(this);
|
||||||
visibleToAll.setId(1);
|
visibleToAll.setId(1);
|
||||||
visibleToAll.setText(R.string.blog_visible_to_all);
|
visibleToAll.setText(R.string.blog_visible_to_all);
|
||||||
|
visibleToAll.setEnabled(wasSubscribed);
|
||||||
visibleToAll.setOnClickListener(this);
|
visibleToAll.setOnClickListener(this);
|
||||||
radioGroup.addView(visibleToAll);
|
radioGroup.addView(visibleToAll);
|
||||||
|
|
||||||
visibleToSome = new RadioButton(this);
|
visibleToSome = new RadioButton(this);
|
||||||
visibleToSome.setId(2);
|
visibleToSome.setId(2);
|
||||||
visibleToSome.setText(R.string.blog_visible_to_some);
|
visibleToSome.setText(R.string.blog_visible_to_some);
|
||||||
|
visibleToSome.setEnabled(wasSubscribed);
|
||||||
visibleToSome.setOnClickListener(this);
|
visibleToSome.setOnClickListener(this);
|
||||||
radioGroup.addView(visibleToSome);
|
radioGroup.addView(visibleToSome);
|
||||||
|
|
||||||
@@ -135,7 +140,9 @@ SelectContactsDialog.Listener {
|
|||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(view == subscribeCheckBox) {
|
if(view == subscribeCheckBox) {
|
||||||
radioGroup.setEnabled(subscribeCheckBox.isChecked());
|
boolean subscribe = subscribeCheckBox.isChecked();
|
||||||
|
visibleToAll.setEnabled(subscribe);
|
||||||
|
visibleToSome.setEnabled(subscribe);
|
||||||
} else if(view == visibleToSome) {
|
} else if(view == visibleToSome) {
|
||||||
loadContacts();
|
loadContacts();
|
||||||
} else if(view == doneButton) {
|
} else if(view == doneButton) {
|
||||||
@@ -203,11 +210,11 @@ SelectContactsDialog.Listener {
|
|||||||
serviceConnection.waitForStartup();
|
serviceConnection.waitForStartup();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if(subscribe) {
|
if(subscribe) {
|
||||||
if(!wasSubscribed) db.subscribe(db.getGroup(groupId));
|
if(!wasSubscribed) db.subscribe(group);
|
||||||
db.setVisibleToAll(groupId, all);
|
db.setVisibleToAll(group.getId(), all);
|
||||||
if(!all) db.setVisibility(groupId, visible);
|
if(!all) db.setVisibility(group.getId(), visible);
|
||||||
} else if(wasSubscribed) {
|
} else if(wasSubscribed) {
|
||||||
db.unsubscribe(db.getGroup(groupId));
|
db.unsubscribe(group);
|
||||||
}
|
}
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import net.sf.briar.android.BriarFragmentActivity;
|
import net.sf.briar.android.BriarFragmentActivity;
|
||||||
import net.sf.briar.android.BriarService;
|
import net.sf.briar.android.BriarService;
|
||||||
import net.sf.briar.android.ManageGroupsAdapter;
|
|
||||||
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
import net.sf.briar.android.BriarService.BriarServiceConnection;
|
||||||
|
import net.sf.briar.android.ManageGroupsAdapter;
|
||||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||||
import net.sf.briar.api.db.DatabaseComponent;
|
import net.sf.briar.api.db.DatabaseComponent;
|
||||||
import net.sf.briar.api.db.DbException;
|
import net.sf.briar.api.db.DbException;
|
||||||
@@ -147,9 +147,11 @@ implements DatabaseListener, OnItemClickListener {
|
|||||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||||
long id) {
|
long id) {
|
||||||
GroupStatus item = adapter.getItem(position);
|
GroupStatus item = adapter.getItem(position);
|
||||||
|
Group g = item.getGroup();
|
||||||
Intent i = new Intent(this, ConfigureBlogActivity.class);
|
Intent i = new Intent(this, ConfigureBlogActivity.class);
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", item.getGroup().getId().getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", g.getId().getBytes());
|
||||||
i.putExtra("net.sf.briar.GROUP_NAME", item.getGroup().getName());
|
i.putExtra("net.sf.briar.GROUP_NAME", g.getName());
|
||||||
|
i.putExtra("net.sf.briar.PUBLIC_KEY", g.getPublicKey());
|
||||||
i.putExtra("net.sf.briar.SUBSCRIBED", item.isSubscribed());
|
i.putExtra("net.sf.briar.SUBSCRIBED", item.isSubscribed());
|
||||||
i.putExtra("net.sf.briar.VISIBLE_TO_ALL", item.isVisibleToAll());
|
i.putExtra("net.sf.briar.VISIBLE_TO_ALL", item.isVisibleToAll());
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import net.sf.briar.api.ContactId;
|
|||||||
import net.sf.briar.api.android.DatabaseUiExecutor;
|
import net.sf.briar.api.android.DatabaseUiExecutor;
|
||||||
import net.sf.briar.api.db.DatabaseComponent;
|
import net.sf.briar.api.db.DatabaseComponent;
|
||||||
import net.sf.briar.api.db.DbException;
|
import net.sf.briar.api.db.DbException;
|
||||||
|
import net.sf.briar.api.messaging.Group;
|
||||||
import net.sf.briar.api.messaging.GroupId;
|
import net.sf.briar.api.messaging.GroupId;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -60,7 +61,7 @@ SelectContactsDialog.Listener {
|
|||||||
// Fields that are accessed from background threads must be volatile
|
// Fields that are accessed from background threads must be volatile
|
||||||
@Inject private volatile DatabaseComponent db;
|
@Inject private volatile DatabaseComponent db;
|
||||||
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
|
||||||
private volatile GroupId groupId = null;
|
private volatile Group group = null;
|
||||||
private volatile Collection<ContactId> selected = Collections.emptyList();
|
private volatile Collection<ContactId> selected = Collections.emptyList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -70,10 +71,11 @@ SelectContactsDialog.Listener {
|
|||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
byte[] b = i.getByteArrayExtra("net.sf.briar.GROUP_ID");
|
||||||
if(b == null) throw new IllegalStateException();
|
if(b == null) throw new IllegalStateException();
|
||||||
groupId = new GroupId(b);
|
GroupId id = new GroupId(b);
|
||||||
String groupName = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
String name = i.getStringExtra("net.sf.briar.GROUP_NAME");
|
||||||
if(groupName == null) throw new IllegalArgumentException();
|
if(name == null) throw new IllegalStateException();
|
||||||
setTitle(groupName);
|
setTitle(name);
|
||||||
|
group = new Group(id, name, null);
|
||||||
wasSubscribed = i.getBooleanExtra("net.sf.briar.SUBSCRIBED", false);
|
wasSubscribed = i.getBooleanExtra("net.sf.briar.SUBSCRIBED", false);
|
||||||
boolean all = i.getBooleanExtra("net.sf.briar.VISIBLE_TO_ALL", false);
|
boolean all = i.getBooleanExtra("net.sf.briar.VISIBLE_TO_ALL", false);
|
||||||
|
|
||||||
@@ -90,17 +92,18 @@ SelectContactsDialog.Listener {
|
|||||||
|
|
||||||
radioGroup = new RadioGroup(this);
|
radioGroup = new RadioGroup(this);
|
||||||
radioGroup.setOrientation(VERTICAL);
|
radioGroup.setOrientation(VERTICAL);
|
||||||
radioGroup.setEnabled(wasSubscribed);
|
|
||||||
|
|
||||||
visibleToAll = new RadioButton(this);
|
visibleToAll = new RadioButton(this);
|
||||||
visibleToAll.setId(1);
|
visibleToAll.setId(1);
|
||||||
visibleToAll.setText(R.string.group_visible_to_all);
|
visibleToAll.setText(R.string.group_visible_to_all);
|
||||||
|
visibleToAll.setEnabled(wasSubscribed);
|
||||||
visibleToAll.setOnClickListener(this);
|
visibleToAll.setOnClickListener(this);
|
||||||
radioGroup.addView(visibleToAll);
|
radioGroup.addView(visibleToAll);
|
||||||
|
|
||||||
visibleToSome = new RadioButton(this);
|
visibleToSome = new RadioButton(this);
|
||||||
visibleToSome.setId(2);
|
visibleToSome.setId(2);
|
||||||
visibleToSome.setText(R.string.group_visible_to_some);
|
visibleToSome.setText(R.string.group_visible_to_some);
|
||||||
|
visibleToSome.setEnabled(wasSubscribed);
|
||||||
visibleToSome.setOnClickListener(this);
|
visibleToSome.setOnClickListener(this);
|
||||||
radioGroup.addView(visibleToSome);
|
radioGroup.addView(visibleToSome);
|
||||||
|
|
||||||
@@ -135,7 +138,9 @@ SelectContactsDialog.Listener {
|
|||||||
|
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(view == subscribeCheckBox) {
|
if(view == subscribeCheckBox) {
|
||||||
radioGroup.setEnabled(subscribeCheckBox.isChecked());
|
boolean subscribe = subscribeCheckBox.isChecked();
|
||||||
|
visibleToAll.setEnabled(subscribe);
|
||||||
|
visibleToSome.setEnabled(subscribe);
|
||||||
} else if(view == visibleToSome) {
|
} else if(view == visibleToSome) {
|
||||||
loadContacts();
|
loadContacts();
|
||||||
} else if(view == doneButton) {
|
} else if(view == doneButton) {
|
||||||
@@ -203,11 +208,11 @@ SelectContactsDialog.Listener {
|
|||||||
serviceConnection.waitForStartup();
|
serviceConnection.waitForStartup();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if(subscribe) {
|
if(subscribe) {
|
||||||
if(!wasSubscribed) db.subscribe(db.getGroup(groupId));
|
if(!wasSubscribed) db.subscribe(group);
|
||||||
db.setVisibleToAll(groupId, all);
|
db.setVisibleToAll(group.getId(), all);
|
||||||
if(!all) db.setVisibility(groupId, visible);
|
if(!all) db.setVisibility(group.getId(), visible);
|
||||||
} else if(wasSubscribed) {
|
} else if(wasSubscribed) {
|
||||||
db.unsubscribe(db.getGroup(groupId));
|
db.unsubscribe(group);
|
||||||
}
|
}
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
|
|||||||
@@ -147,9 +147,10 @@ implements DatabaseListener, OnItemClickListener {
|
|||||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||||
long id) {
|
long id) {
|
||||||
GroupStatus item = adapter.getItem(position);
|
GroupStatus item = adapter.getItem(position);
|
||||||
|
Group g = item.getGroup();
|
||||||
Intent i = new Intent(this, ConfigureGroupActivity.class);
|
Intent i = new Intent(this, ConfigureGroupActivity.class);
|
||||||
i.putExtra("net.sf.briar.GROUP_ID", item.getGroup().getId().getBytes());
|
i.putExtra("net.sf.briar.GROUP_ID", g.getId().getBytes());
|
||||||
i.putExtra("net.sf.briar.GROUP_NAME", item.getGroup().getName());
|
i.putExtra("net.sf.briar.GROUP_NAME", g.getName());
|
||||||
i.putExtra("net.sf.briar.SUBSCRIBED", item.isSubscribed());
|
i.putExtra("net.sf.briar.SUBSCRIBED", item.isSubscribed());
|
||||||
i.putExtra("net.sf.briar.VISIBLE_TO_ALL", item.isVisibleToAll());
|
i.putExtra("net.sf.briar.VISIBLE_TO_ALL", item.isVisibleToAll());
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user