Show whether identities are anonymous, unknown, or verified.

Dev task #52. Known but unverified identities are also supported, but
currently unused. These will be used in future for contacts who've been
introduced but not verified face to face.
This commit is contained in:
akwizgran
2014-02-04 12:32:51 +00:00
parent 035fc4324f
commit a45d09ef5c
29 changed files with 197 additions and 95 deletions

View File

@@ -230,6 +230,7 @@ OnClickListener, OnItemClickListener {
i.putExtra("briar.AUTHOR_ID", author.getId().getBytes());
i.putExtra("briar.AUTHOR_NAME", author.getName());
}
i.putExtra("briar.AUTHOR_STATUS", item.getAuthorStatus().name());
i.putExtra("briar.CONTENT_TYPE", item.getContentType());
i.putExtra("briar.TIMESTAMP", item.getTimestamp());
startActivityForResult(i, position);

View File

@@ -7,6 +7,7 @@ import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
import java.util.ArrayList;
import org.briarproject.R;
import org.briarproject.android.util.AuthorView;
import org.briarproject.android.util.LayoutUtils;
import org.briarproject.api.Author;
import org.briarproject.api.db.MessageHeader;
@@ -32,34 +33,27 @@ class GroupAdapter extends ArrayAdapter<MessageHeader> {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MessageHeader item = getItem(position);
MessageHeader header = getItem(position);
Context ctx = getContext();
Resources res = ctx.getResources();
LinearLayout layout = new LinearLayout(ctx);
layout.setOrientation(HORIZONTAL);
if(!item.isRead())
if(!header.isRead()) {
Resources res = ctx.getResources();
layout.setBackgroundColor(res.getColor(R.color.unread_background));
TextView name = new TextView(ctx);
// Give me all the unused width
name.setLayoutParams(WRAP_WRAP_1);
name.setTextSize(18);
name.setMaxLines(1);
name.setPadding(pad, pad, pad, pad);
Author author = item.getAuthor();
if(author == null) {
name.setTextColor(res.getColor(R.color.anonymous_author));
name.setText(R.string.anonymous);
} else {
name.setText(author.getName());
}
layout.addView(name);
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());
layout.addView(authorView);
TextView date = new TextView(ctx);
date.setTextSize(14);
date.setPadding(pad, pad, pad, pad);
long then = item.getTimestamp(), now = System.currentTimeMillis();
date.setPadding(0, pad, pad, pad);
long then = header.getTimestamp(), now = System.currentTimeMillis();
date.setText(DateUtils.formatSameDayTime(then, now, SHORT, SHORT));
layout.addView(date);

View File

@@ -18,9 +18,11 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import org.briarproject.R;
import org.briarproject.android.util.HorizontalBorder;
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.Author;
import org.briarproject.api.android.DatabaseUiExecutor;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.db.DbException;
@@ -83,6 +85,9 @@ implements OnClickListener {
timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
if(timestamp == -1) throw new IllegalStateException();
String authorName = i.getStringExtra("briar.AUTHOR_NAME");
String s = i.getStringExtra("briar.AUTHOR_STATUS");
if(s == null) throw new IllegalStateException();
Author.Status authorStatus = Author.Status.valueOf(s);
if(state == null) {
read = false;
@@ -109,21 +114,12 @@ implements OnClickListener {
header.setOrientation(HORIZONTAL);
header.setGravity(CENTER_VERTICAL);
int pad = LayoutUtils.getPadding(this);
AuthorView author = new AuthorView(this);
author.setLayoutParams(WRAP_WRAP_1);
author.init(authorName, authorStatus);
header.addView(author);
TextView name = new TextView(this);
// Give me all the unused width
name.setLayoutParams(WRAP_WRAP_1);
name.setTextSize(18);
name.setMaxLines(1);
name.setPadding(pad, pad, pad, pad);
if(authorName == null) {
name.setTextColor(res.getColor(R.color.anonymous_author));
name.setText(R.string.anonymous);
} else {
name.setText(authorName);
}
header.addView(name);
int pad = LayoutUtils.getPadding(this);
TextView date = new TextView(this);
date.setTextSize(14);