Migrate AuthorView to XML, add identicon

This commit is contained in:
str4d
2016-01-05 07:19:10 +00:00
parent 88d81634ca
commit 35c59fdb39
5 changed files with 100 additions and 34 deletions

View File

@@ -18,6 +18,7 @@ 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;
@@ -70,6 +71,8 @@ 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;
@@ -366,7 +369,8 @@ 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_NAME", author.getName());
if (author != null) i.putExtra("briar.AUTHOR_HANDLE",
referenceManager.putReference(author, Author.class));
i.putExtra("briar.AUTHOR_STATUS", header.getAuthorStatus().name());
i.putExtra("briar.CONTENT_TYPE", header.getContentType());
i.putExtra("briar.TIMESTAMP", header.getTimestamp());

View File

@@ -55,8 +55,7 @@ class ForumAdapter extends ArrayAdapter<ForumItem> {
AuthorView authorView = new AuthorView(ctx);
authorView.setLayoutParams(WRAP_WRAP_1);
Author author = header.getAuthor();
if (author == null) authorView.init(null, header.getAuthorStatus());
else authorView.init(author.getName(), header.getAuthorStatus());
authorView.init(author, header.getAuthorStatus());
headerLayout.addView(authorView);
TextView date = new TextView(ctx);

View File

@@ -17,6 +17,7 @@ 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;
@@ -56,6 +57,8 @@ 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;
@@ -82,7 +85,9 @@ implements OnClickListener {
if (minTimestamp == -1) throw new IllegalStateException();
position = i.getIntExtra("briar.POSITION", -1);
if (position == -1) throw new IllegalStateException();
String authorName = i.getStringExtra("briar.AUTHOR_NAME");
long authorHandle = i.getLongExtra("briar.AUTHOR_HANDLE", -1);
if (authorHandle == -1) throw new IllegalStateException();
Author author = referenceManager.removeReference(authorHandle, Author.class);
String s = i.getStringExtra("briar.AUTHOR_STATUS");
if (s == null) throw new IllegalStateException();
Author.Status authorStatus = Author.Status.valueOf(s);
@@ -102,10 +107,10 @@ implements OnClickListener {
header.setOrientation(HORIZONTAL);
header.setGravity(CENTER_VERTICAL);
AuthorView author = new AuthorView(this);
author.setLayoutParams(WRAP_WRAP_1);
author.init(authorName, authorStatus);
header.addView(author);
AuthorView authorView = new AuthorView(this);
authorView.setLayoutParams(WRAP_WRAP_1);
authorView.init(author, authorStatus);
header.addView(authorView);
int pad = LayoutUtils.getPadding(this);