diff --git a/briar-android/src/org/briarproject/android/forum/ForumActivity.java b/briar-android/src/org/briarproject/android/forum/ForumActivity.java index a67ebd12e702a697fcf8bde22b874ce0f0217136..c15d2667d9004d934987c8a10d1a1fbfb422592f 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumActivity.java +++ b/briar-android/src/org/briarproject/android/forum/ForumActivity.java @@ -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()); diff --git a/briar-android/src/org/briarproject/android/forum/ForumAdapter.java b/briar-android/src/org/briarproject/android/forum/ForumAdapter.java index 30ff7d0bf8367158b88af5c8178dc9c13d7bdb15..df2e4e425fe795756948ed1dc03f4cfd2a64d2b9 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumAdapter.java +++ b/briar-android/src/org/briarproject/android/forum/ForumAdapter.java @@ -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); diff --git a/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java b/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java index 540f428c61a9049246bca3025d2112d47d282ef8..45cec82f65259481fabfd74deca2eec5d74cea23 100644 --- a/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java +++ b/briar-android/src/org/briarproject/android/forum/ReadForumPostActivity.java @@ -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); + int pad = LayoutUtils.getPadding(this); + AuthorView authorView = new AuthorView(this); + authorView.setPadding(0, pad, pad, pad); authorView.setLayoutParams(WRAP_WRAP_1); - authorView.init(author, authorStatus); + authorView.init(authorName, authorId, authorStatus); header.addView(authorView); - int pad = LayoutUtils.getPadding(this); - 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); diff --git a/briar-android/src/org/briarproject/android/util/AuthorView.java b/briar-android/src/org/briarproject/android/util/AuthorView.java index dd20a28e7717cd0e54a2a9f745bf5aef0d414595..0f247ce7cddbe6cd1fa9e83cc7408c0694e0872d 100644 --- a/briar-android/src/org/briarproject/android/util/AuthorView.java +++ b/briar-android/src/org/briarproject/android/util/AuthorView.java @@ -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) {