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