mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Merge branch '41-alias-author-info' into 'master'
Refactor Author.Status into dedicated AuthorInfo class and add alias See merge request briar/briar!968
This commit is contained in:
@@ -3,7 +3,7 @@ package org.briarproject.briar.android.blog;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.blog.BlogPostHeader;
|
||||
@@ -15,6 +15,7 @@ import javax.annotation.concurrent.NotThreadSafe;
|
||||
public class BlogPostItem implements Comparable<BlogPostItem> {
|
||||
|
||||
private final BlogPostHeader header;
|
||||
@Nullable
|
||||
protected String text;
|
||||
private boolean read;
|
||||
|
||||
@@ -40,10 +41,11 @@ public class BlogPostItem implements Comparable<BlogPostItem> {
|
||||
return header.getAuthor();
|
||||
}
|
||||
|
||||
Status getAuthorStatus() {
|
||||
return header.getAuthorStatus();
|
||||
AuthorInfo getAuthorInfo() {
|
||||
return header.getAuthorInfo();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
BlogPostHeader post = item.getPostHeader();
|
||||
Author a = post.getAuthor();
|
||||
author.setAuthor(a);
|
||||
author.setAuthorStatus(post.getAuthorStatus());
|
||||
author.setAuthorInfo(post.getAuthorInfo());
|
||||
author.setDate(post.getTimestamp());
|
||||
author.setPersona(
|
||||
item.isRssFeed() ? AuthorView.RSS_FEED : AuthorView.NORMAL);
|
||||
@@ -144,7 +144,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
private void onBindComment(BlogCommentItem item) {
|
||||
// reblogger
|
||||
reblogger.setAuthor(item.getAuthor());
|
||||
reblogger.setAuthorStatus(item.getAuthorStatus());
|
||||
reblogger.setAuthorInfo(item.getAuthorInfo());
|
||||
reblogger.setDate(item.getTimestamp());
|
||||
if (!fullText) {
|
||||
reblogger.setAuthorClickable(v -> listener.onAuthorClick(item));
|
||||
@@ -166,7 +166,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView text = v.findViewById(R.id.textView);
|
||||
|
||||
author.setAuthor(c.getAuthor());
|
||||
author.setAuthorStatus(c.getAuthorStatus());
|
||||
author.setAuthorInfo(c.getAuthorInfo());
|
||||
author.setDate(c.getTimestamp());
|
||||
// TODO make author clickable #624
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.briar.android.forum;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.android.threaded.ThreadItem;
|
||||
import org.briarproject.briar.api.forum.ForumPostHeader;
|
||||
@@ -14,12 +14,12 @@ class ForumItem extends ThreadItem {
|
||||
|
||||
ForumItem(ForumPostHeader h, String text) {
|
||||
super(h.getId(), h.getParentId(), text, h.getTimestamp(), h.getAuthor(),
|
||||
h.getAuthorStatus(), h.isRead());
|
||||
h.getAuthorInfo(), h.isRead());
|
||||
}
|
||||
|
||||
ForumItem(MessageId messageId, @Nullable MessageId parentId, String text,
|
||||
long timestamp, Author author, Status status) {
|
||||
super(messageId, parentId, text, timestamp, author, status, true);
|
||||
long timestamp, Author author, AuthorInfo authorInfo) {
|
||||
super(messageId, parentId, text, timestamp, author, authorInfo, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.R;
|
||||
@@ -22,14 +22,14 @@ class GroupMessageItem extends ThreadItem {
|
||||
|
||||
private GroupMessageItem(MessageId messageId, GroupId groupId,
|
||||
@Nullable MessageId parentId, String text, long timestamp,
|
||||
Author author, Status status, boolean isRead) {
|
||||
super(messageId, parentId, text, timestamp, author, status, isRead);
|
||||
Author author, AuthorInfo authorInfo, boolean isRead) {
|
||||
super(messageId, parentId, text, timestamp, author, authorInfo, isRead);
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
GroupMessageItem(GroupMessageHeader h, String text) {
|
||||
this(h.getId(), h.getGroupId(), h.getParentId(), text, h.getTimestamp(),
|
||||
h.getAuthor(), h.getAuthorStatus(), h.isRead());
|
||||
h.getAuthor(), h.getAuthorInfo(), h.isRead());
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.threaded.BaseThreadItemViewHolder;
|
||||
import org.briarproject.briar.android.threaded.ThreadItemAdapter.ThreadItemListener;
|
||||
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.OURSELVES;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
@@ -49,7 +49,7 @@ class JoinMessageItemViewHolder
|
||||
textView.setText(ctx.getString(R.string.groups_member_created,
|
||||
item.getAuthor().getName()));
|
||||
} else {
|
||||
if (item.getStatus() == OURSELVES) {
|
||||
if (item.getAuthorInfo().getStatus() == OURSELVES) {
|
||||
textView.setText(R.string.groups_member_joined_you);
|
||||
} else {
|
||||
textView.setText(ctx.getString(R.string.groups_member_joined,
|
||||
|
||||
@@ -2,7 +2,8 @@ package org.briarproject.briar.android.privategroup.memberlist;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo.Status;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.api.privategroup.GroupMember;
|
||||
|
||||
@@ -25,8 +26,12 @@ class MemberListItem {
|
||||
return groupMember.getAuthor();
|
||||
}
|
||||
|
||||
AuthorInfo getAuthorInfo() {
|
||||
return groupMember.getAuthorInfo();
|
||||
}
|
||||
|
||||
Status getStatus() {
|
||||
return groupMember.getStatus();
|
||||
return groupMember.getAuthorInfo().getStatus();
|
||||
}
|
||||
|
||||
boolean isCreator() {
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.view.AuthorView;
|
||||
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.OURSELVES;
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
@@ -28,25 +30,25 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
|
||||
protected void bind(MemberListItem item) {
|
||||
// member name, avatar and status
|
||||
// member name, avatar and author info
|
||||
author.setAuthor(item.getMember());
|
||||
author.setAuthorStatus(item.getStatus());
|
||||
author.setAuthorInfo(item.getAuthorInfo());
|
||||
|
||||
// online status of visible contacts
|
||||
if (item.getContactId() != null) {
|
||||
bulb.setVisibility(View.VISIBLE);
|
||||
bulb.setVisibility(VISIBLE);
|
||||
if (item.isOnline()) {
|
||||
bulb.setImageResource(R.drawable.contact_connected);
|
||||
} else {
|
||||
bulb.setImageResource(R.drawable.contact_disconnected);
|
||||
}
|
||||
} else {
|
||||
bulb.setVisibility(View.GONE);
|
||||
bulb.setVisibility(GONE);
|
||||
}
|
||||
|
||||
// text shown for creator
|
||||
if (item.isCreator()) {
|
||||
creator.setVisibility(View.VISIBLE);
|
||||
creator.setVisibility(VISIBLE);
|
||||
if (item.getStatus() == OURSELVES) {
|
||||
creator.setText(R.string.groups_member_created_you);
|
||||
} else {
|
||||
@@ -55,7 +57,7 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
|
||||
item.getMember().getName()));
|
||||
}
|
||||
} else {
|
||||
creator.setVisibility(View.GONE);
|
||||
creator.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class BaseThreadItemViewHolder<I extends ThreadItem>
|
||||
|
||||
author.setAuthor(item.getAuthor());
|
||||
author.setDate(item.getTimestamp());
|
||||
author.setAuthorStatus(item.getStatus());
|
||||
author.setAuthorInfo(item.getAuthorInfo());
|
||||
|
||||
if (item.isHighlighted()) {
|
||||
layout.setActivated(true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.briarproject.briar.android.threaded;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.MessageTree.MessageNode;
|
||||
@@ -21,19 +21,19 @@ public abstract class ThreadItem implements MessageNode {
|
||||
private final String text;
|
||||
private final long timestamp;
|
||||
private final Author author;
|
||||
private final Status status;
|
||||
private final AuthorInfo authorInfo;
|
||||
private int level = UNDEFINED;
|
||||
private boolean isRead, highlighted;
|
||||
|
||||
public ThreadItem(MessageId messageId, @Nullable MessageId parentId,
|
||||
String text, long timestamp, Author author, Status status,
|
||||
String text, long timestamp, Author author, AuthorInfo authorInfo,
|
||||
boolean isRead) {
|
||||
this.messageId = messageId;
|
||||
this.parentId = parentId;
|
||||
this.text = text;
|
||||
this.timestamp = timestamp;
|
||||
this.author = author;
|
||||
this.status = status;
|
||||
this.authorInfo = authorInfo;
|
||||
this.isRead = isRead;
|
||||
this.highlighted = false;
|
||||
}
|
||||
@@ -66,8 +66,8 @@ public abstract class ThreadItem implements MessageNode {
|
||||
return author;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
public AuthorInfo getAuthorInfo() {
|
||||
return authorInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.util.UiUtils;
|
||||
|
||||
@@ -24,8 +24,8 @@ import im.delight.android.identicons.IdenticonDrawable;
|
||||
import static android.content.Context.LAYOUT_INFLATER_SERVICE;
|
||||
import static android.graphics.Typeface.BOLD;
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.NONE;
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.OURSELVES;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.NONE;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||
import static org.briarproject.briar.android.util.UiUtils.resolveAttribute;
|
||||
|
||||
@UiThread
|
||||
@@ -79,15 +79,15 @@ public class AuthorView extends ConstraintLayout {
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setAuthorStatus(Status status) {
|
||||
if (status != NONE) {
|
||||
trustIndicator.setTrustLevel(status);
|
||||
public void setAuthorInfo(AuthorInfo authorInfo) {
|
||||
if (authorInfo.getStatus() != NONE) {
|
||||
trustIndicator.setTrustLevel(authorInfo.getStatus());
|
||||
trustIndicator.setVisibility(VISIBLE);
|
||||
} else {
|
||||
trustIndicator.setVisibility(GONE);
|
||||
}
|
||||
|
||||
if (status == OURSELVES) {
|
||||
if (authorInfo.getStatus() == OURSELVES) {
|
||||
authorName.setTypeface(authorNameTypeface, BOLD);
|
||||
} else {
|
||||
authorName.setTypeface(authorNameTypeface, NORMAL);
|
||||
|
||||
@@ -3,14 +3,14 @@ package org.briarproject.briar.android.view;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.briarproject.bramble.api.identity.Author.Status;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo.Status;
|
||||
import org.briarproject.briar.R;
|
||||
|
||||
@UiThread
|
||||
public class TrustIndicatorView extends ImageView {
|
||||
public class TrustIndicatorView extends AppCompatImageView {
|
||||
|
||||
public TrustIndicatorView(Context context) {
|
||||
super(context);
|
||||
|
||||
@@ -6,6 +6,7 @@ import junit.framework.Assert;
|
||||
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.android.TestBriarApplication;
|
||||
import org.briarproject.briar.android.controller.handler.UiResultExceptionHandler;
|
||||
@@ -26,7 +27,7 @@ import java.util.Arrays;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.briarproject.bramble.api.identity.Author.Status.UNKNOWN;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.UNKNOWN;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAuthor;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
@@ -87,7 +88,8 @@ public class ForumActivityTest {
|
||||
Author author = getAuthor();
|
||||
String text = getRandomString(MAX_FORUM_POST_TEXT_LENGTH);
|
||||
forumItems[i] = new ForumItem(MESSAGE_IDS[i], PARENT_IDS[i],
|
||||
text, System.currentTimeMillis(), author, UNKNOWN);
|
||||
text, System.currentTimeMillis(), author,
|
||||
new AuthorInfo(UNKNOWN));
|
||||
forumItems[i].setLevel(LEVELS[i]);
|
||||
}
|
||||
ThreadItemList<ForumItem> list = new ThreadItemListImpl<>();
|
||||
|
||||
Reference in New Issue
Block a user