mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Don't use ReferenceManager for forum post author. #243
This commit is contained in:
@@ -18,7 +18,6 @@ import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||
@@ -71,8 +70,6 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
private ListLoadingProgressBar loading = null;
|
||||
private ImageButton composeButton = null, shareButton = null;
|
||||
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@@ -369,8 +366,10 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
i.putExtra("briar.FORUM_NAME", forum.getName());
|
||||
i.putExtra("briar.MESSAGE_ID", header.getId().getBytes());
|
||||
Author author = header.getAuthor();
|
||||
if (author != null) i.putExtra("briar.AUTHOR_HANDLE",
|
||||
referenceManager.putReference(author, Author.class));
|
||||
if (author != null) {
|
||||
i.putExtra("briar.AUTHOR_NAME", author.getName());
|
||||
i.putExtra("briar.AUTHOR_ID", author.getId().getBytes());
|
||||
}
|
||||
i.putExtra("briar.AUTHOR_STATUS", header.getAuthorStatus().name());
|
||||
i.putExtra("briar.CONTENT_TYPE", header.getContentType());
|
||||
i.putExtra("briar.TIMESTAMP", header.getTimestamp());
|
||||
|
||||
@@ -54,12 +54,18 @@ class ForumAdapter extends ArrayAdapter<ForumItem> {
|
||||
|
||||
AuthorView authorView = new AuthorView(ctx);
|
||||
authorView.setLayoutParams(WRAP_WRAP_1);
|
||||
authorView.setPadding(0, pad, pad, pad);
|
||||
Author author = header.getAuthor();
|
||||
authorView.init(author, header.getAuthorStatus());
|
||||
if (author == null) {
|
||||
authorView.init(null, null, header.getAuthorStatus());
|
||||
} else {
|
||||
authorView.init(author.getName(), author.getId(),
|
||||
header.getAuthorStatus());
|
||||
}
|
||||
headerLayout.addView(authorView);
|
||||
|
||||
TextView date = new TextView(ctx);
|
||||
date.setPadding(0, pad, pad, pad);
|
||||
date.setPadding(pad, pad, pad, pad);
|
||||
long timestamp = header.getTimestamp();
|
||||
date.setText(DateUtils.getRelativeTimeSpanString(ctx, timestamp));
|
||||
headerLayout.addView(date);
|
||||
|
||||
@@ -17,11 +17,11 @@ import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
@@ -58,8 +58,6 @@ implements OnClickListener {
|
||||
private TextView content = null;
|
||||
private int position = -1;
|
||||
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
private volatile MessageId messageId = null;
|
||||
@@ -86,12 +84,10 @@ implements OnClickListener {
|
||||
if (minTimestamp == -1) throw new IllegalStateException();
|
||||
position = i.getIntExtra("briar.POSITION", -1);
|
||||
if (position == -1) throw new IllegalStateException();
|
||||
Author author = null;
|
||||
long authorHandle = i.getLongExtra("briar.AUTHOR_HANDLE", -1);
|
||||
if (authorHandle != -1) {
|
||||
author = referenceManager.removeReference(authorHandle,
|
||||
Author.class);
|
||||
}
|
||||
String authorName = i.getStringExtra("briar.AUTHOR_NAME");
|
||||
AuthorId authorId = null;
|
||||
b = i.getByteArrayExtra("briar.AUTHOR_ID");
|
||||
if (b != null) authorId = new AuthorId(b);
|
||||
String s = i.getStringExtra("briar.AUTHOR_STATUS");
|
||||
if (s == null) throw new IllegalStateException();
|
||||
Author.Status authorStatus = Author.Status.valueOf(s);
|
||||
@@ -111,15 +107,16 @@ implements OnClickListener {
|
||||
header.setOrientation(HORIZONTAL);
|
||||
header.setGravity(CENTER_VERTICAL);
|
||||
|
||||
AuthorView authorView = new AuthorView(this);
|
||||
authorView.setLayoutParams(WRAP_WRAP_1);
|
||||
authorView.init(author, authorStatus);
|
||||
header.addView(authorView);
|
||||
|
||||
int pad = LayoutUtils.getPadding(this);
|
||||
|
||||
AuthorView authorView = new AuthorView(this);
|
||||
authorView.setPadding(0, pad, pad, pad);
|
||||
authorView.setLayoutParams(WRAP_WRAP_1);
|
||||
authorView.init(authorName, authorId, authorStatus);
|
||||
header.addView(authorView);
|
||||
|
||||
TextView date = new TextView(this);
|
||||
date.setPadding(0, pad, pad, pad);
|
||||
date.setPadding(pad, pad, pad, pad);
|
||||
date.setText(DateUtils.getRelativeTimeSpanString(this, timestamp));
|
||||
header.addView(date);
|
||||
message.addView(header);
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.TextView;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -56,12 +57,13 @@ public class AuthorView extends FrameLayout {
|
||||
statusView = (ImageView) v.findViewById(R.id.statusView);
|
||||
}
|
||||
|
||||
public void init(Author author, Author.Status status) {
|
||||
if (author == null) nameView.setText(R.string.anonymous);
|
||||
else {
|
||||
public void init(String name, AuthorId id, Author.Status status) {
|
||||
if (name == null) {
|
||||
nameView.setText(R.string.anonymous);
|
||||
} else {
|
||||
nameView.setText(name);
|
||||
avatarView.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||
nameView.setText(author.getName());
|
||||
new IdenticonDrawable(crypto, id.getBytes()));
|
||||
}
|
||||
|
||||
switch(status) {
|
||||
|
||||
Reference in New Issue
Block a user