diff --git a/briar-android/artwork/trust-indicator.svg b/briar-android/artwork/trust-indicator.svg new file mode 100644 index 000000000..c8f94b6f6 --- /dev/null +++ b/briar-android/artwork/trust-indicator.svg @@ -0,0 +1,92 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/briar-android/res/drawable-hdpi/identity_anonymous.png b/briar-android/res/drawable-hdpi/identity_anonymous.png deleted file mode 100644 index aa539d31b..000000000 Binary files a/briar-android/res/drawable-hdpi/identity_anonymous.png and /dev/null differ diff --git a/briar-android/res/drawable-hdpi/identity_unknown.png b/briar-android/res/drawable-hdpi/identity_unknown.png deleted file mode 100644 index b098e93aa..000000000 Binary files a/briar-android/res/drawable-hdpi/identity_unknown.png and /dev/null differ diff --git a/briar-android/res/drawable-hdpi/identity_unverified.png b/briar-android/res/drawable-hdpi/identity_unverified.png deleted file mode 100644 index f9e248626..000000000 Binary files a/briar-android/res/drawable-hdpi/identity_unverified.png and /dev/null differ diff --git a/briar-android/res/drawable-hdpi/identity_verified.png b/briar-android/res/drawable-hdpi/identity_verified.png deleted file mode 100644 index 02e819fa1..000000000 Binary files a/briar-android/res/drawable-hdpi/identity_verified.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/identity_anonymous.png b/briar-android/res/drawable-mdpi/identity_anonymous.png deleted file mode 100644 index c91a016de..000000000 Binary files a/briar-android/res/drawable-mdpi/identity_anonymous.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/identity_unknown.png b/briar-android/res/drawable-mdpi/identity_unknown.png deleted file mode 100644 index 6ad29f8a0..000000000 Binary files a/briar-android/res/drawable-mdpi/identity_unknown.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/identity_unverified.png b/briar-android/res/drawable-mdpi/identity_unverified.png deleted file mode 100644 index 9b8a13d4b..000000000 Binary files a/briar-android/res/drawable-mdpi/identity_unverified.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/identity_verified.png b/briar-android/res/drawable-mdpi/identity_verified.png deleted file mode 100644 index 79cbaedc2..000000000 Binary files a/briar-android/res/drawable-mdpi/identity_verified.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/identity_anonymous.png b/briar-android/res/drawable-xhdpi/identity_anonymous.png deleted file mode 100644 index c8f254fda..000000000 Binary files a/briar-android/res/drawable-xhdpi/identity_anonymous.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/identity_unknown.png b/briar-android/res/drawable-xhdpi/identity_unknown.png deleted file mode 100644 index e3b91a858..000000000 Binary files a/briar-android/res/drawable-xhdpi/identity_unknown.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/identity_unverified.png b/briar-android/res/drawable-xhdpi/identity_unverified.png deleted file mode 100644 index 85785c09c..000000000 Binary files a/briar-android/res/drawable-xhdpi/identity_unverified.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/identity_verified.png b/briar-android/res/drawable-xhdpi/identity_verified.png deleted file mode 100644 index d93ae1df2..000000000 Binary files a/briar-android/res/drawable-xhdpi/identity_verified.png and /dev/null differ diff --git a/briar-android/res/drawable/trust_indicator_anonymous.xml b/briar-android/res/drawable/trust_indicator_anonymous.xml new file mode 100644 index 000000000..99ccadd1b --- /dev/null +++ b/briar-android/res/drawable/trust_indicator_anonymous.xml @@ -0,0 +1,40 @@ + + + + + + \ No newline at end of file diff --git a/briar-android/res/drawable/trust_indicator_unknown.xml b/briar-android/res/drawable/trust_indicator_unknown.xml new file mode 100644 index 000000000..ec65b5a55 --- /dev/null +++ b/briar-android/res/drawable/trust_indicator_unknown.xml @@ -0,0 +1,40 @@ + + + + + + \ No newline at end of file diff --git a/briar-android/res/drawable/trust_indicator_unverified.xml b/briar-android/res/drawable/trust_indicator_unverified.xml new file mode 100644 index 000000000..3697685b0 --- /dev/null +++ b/briar-android/res/drawable/trust_indicator_unverified.xml @@ -0,0 +1,40 @@ + + + + + + \ No newline at end of file diff --git a/briar-android/res/drawable/trust_indicator_verified.xml b/briar-android/res/drawable/trust_indicator_verified.xml new file mode 100644 index 000000000..40a8ff035 --- /dev/null +++ b/briar-android/res/drawable/trust_indicator_verified.xml @@ -0,0 +1,40 @@ + + + + + + \ No newline at end of file diff --git a/briar-android/res/layout/author_view.xml b/briar-android/res/layout/author_view.xml deleted file mode 100644 index 4fb0b9d6b..000000000 --- a/briar-android/res/layout/author_view.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/briar-android/res/layout/forum_discussion_cell.xml b/briar-android/res/layout/forum_discussion_cell.xml index 57383a720..e8fbf8aa3 100644 --- a/briar-android/res/layout/forum_discussion_cell.xml +++ b/briar-android/res/layout/forum_discussion_cell.xml @@ -131,6 +131,9 @@ android:layout_height="wrap_content" android:layout_alignBaseline="@id/btn_reply" android:layout_toLeftOf="@id/btn_reply" + android:layout_toRightOf="@+id/trustIndicator" + android:gravity="right|end" + android:maxLines="1" android:padding="@dimen/margin_medium" android:textSize="@dimen/text_size_tiny" tools:text="2 replies"/> @@ -140,13 +143,23 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@id/replies" - android:layout_toLeftOf="@id/replies" android:layout_toRightOf="@id/avatar" android:ellipsize="end" android:maxLines="1" android:textSize="@dimen/text_size_tiny" tools:text="09:09 John Smith"/> + + { - - private final int pad; - - ForumAdapter(Context ctx) { - super(ctx, android.R.layout.simple_expandable_list_item_1, - new ArrayList()); - pad = LayoutUtils.getPadding(ctx); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ForumItem item = getItem(position); - ForumPostHeader header = item.getHeader(); - Context ctx = getContext(); - Resources res = ctx.getResources(); - - LinearLayout layout = new LinearLayout(ctx); - layout.setOrientation(VERTICAL); - layout.setGravity(CENTER_HORIZONTAL); - if (!header.isRead()) - layout.setBackgroundColor(res.getColor(R.color.unread_background)); - - LinearLayout headerLayout = new LinearLayout(ctx); - headerLayout.setOrientation(HORIZONTAL); - headerLayout.setGravity(CENTER_VERTICAL); - - AuthorView authorView = new AuthorView(ctx); - authorView.setLayoutParams(WRAP_WRAP_1); - authorView.setPadding(0, pad, pad, pad); - Author author = header.getAuthor(); - 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(pad, pad, pad, pad); - long timestamp = header.getTimestamp(); - date.setText(DateUtils.getRelativeTimeSpanString(ctx, timestamp)); - headerLayout.addView(date); - layout.addView(headerLayout); - - if (item.getBody() == null) { - TextView ellipsis = new TextView(ctx); - ellipsis.setPadding(pad, 0, pad, pad); - ellipsis.setText("\u2026"); - layout.addView(ellipsis); - } else if (header.getContentType().equals("text/plain")) { - TextView text = new TextView(ctx); - text.setPadding(pad, 0, pad, pad); - text.setText(StringUtils.fromUtf8(item.getBody())); - layout.addView(text); - } else { - ImageButton attachment = new ImageButton(ctx); - attachment.setPadding(pad, 0, pad, pad); - attachment.setImageResource(R.drawable.content_attachment); - layout.addView(attachment); - } - - return layout; - } -} \ No newline at end of file diff --git a/briar-android/src/org/briarproject/android/forum/ForumEntry.java b/briar-android/src/org/briarproject/android/forum/ForumEntry.java index c3c668f7a..a24d94bbc 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumEntry.java +++ b/briar-android/src/org/briarproject/android/forum/ForumEntry.java @@ -1,6 +1,7 @@ package org.briarproject.android.forum; import org.briarproject.api.forum.ForumPostHeader; +import org.briarproject.api.identity.Author.Status; import org.briarproject.api.identity.AuthorId; import org.briarproject.api.sync.MessageId; @@ -12,23 +13,25 @@ public class ForumEntry { private final long timestamp; private final String author; private final AuthorId authorId; + private Status status; private boolean isShowingDescendants = true; private boolean isRead = true; public ForumEntry(ForumPostHeader h, String text, int level) { this(h.getId(), text, level, h.getTimestamp(), h.getAuthor().getName(), - h.getAuthor().getId()); + h.getAuthor().getId(), h.getAuthorStatus()); this.isRead = h.isRead(); } public ForumEntry(MessageId messageId, String text, int level, - long timestamp, String author, AuthorId authorId) { + long timestamp, String author, AuthorId authorId, Status status) { this.messageId = messageId; this.text = text; this.level = level; this.timestamp = timestamp; this.author = author; this.authorId = authorId; + this.status = status; } public String getText() { @@ -51,6 +54,10 @@ public class ForumEntry { return authorId; } + public Status getStatus() { + return status; + } + public boolean isShowingDescendants() { return isShowingDescendants; } diff --git a/briar-android/src/org/briarproject/android/forum/ForumTestControllerImpl.java b/briar-android/src/org/briarproject/android/forum/ForumTestControllerImpl.java index ec1470ed8..2aef2ae5e 100644 --- a/briar-android/src/org/briarproject/android/forum/ForumTestControllerImpl.java +++ b/briar-android/src/org/briarproject/android/forum/ForumTestControllerImpl.java @@ -15,6 +15,8 @@ import java.util.logging.Logger; import javax.inject.Inject; +import static org.briarproject.api.identity.Author.Status.UNVERIFIED; + public class ForumTestControllerImpl implements ForumController { private static final Logger LOG = @@ -115,7 +117,7 @@ public class ForumTestControllerImpl implements ForumController { forumEntries[e] = new ForumEntry(new MessageId(b), SAGA.substring(0, i[e]), l[e], timestamp, AUTHORS[authorIndex], - AUTHOR_ID[authorIndex]); + AUTHOR_ID[authorIndex], UNVERIFIED); } LOG.info("forum entries: " + forumEntries.length); resultHandler.onResult(true); diff --git a/briar-android/src/org/briarproject/android/util/AuthorView.java b/briar-android/src/org/briarproject/android/util/AuthorView.java deleted file mode 100644 index 4b11d51e8..000000000 --- a/briar-android/src/org/briarproject/android/util/AuthorView.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.briarproject.android.util; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.FrameLayout; -import android.widget.ImageView; -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; - -import im.delight.android.identicons.IdenticonDrawable; - -public class AuthorView extends FrameLayout { - - private ImageView avatarView; - private TextView nameView; - private ImageView statusView; - - public AuthorView(Context ctx) { - super(ctx); - - initViews(); - } - - public AuthorView(Context context, AttributeSet attrs) { - super(context, attrs); - - initViews(); - } - - public AuthorView(Context context, AttributeSet attrs, - int defStyle) { - super(context, attrs, defStyle); - - initViews(); - } - - private void initViews() { - if (isInEditMode()) - return; - - View v = LayoutInflater.from(getContext()).inflate( - R.layout.author_view, this, true); - - avatarView = (ImageView) v.findViewById(R.id.avatarView); - nameView = (TextView) v.findViewById(R.id.nameView); - statusView = (ImageView) v.findViewById(R.id.statusView); - } - - 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(id.getBytes())); - } - - switch(status) { - case ANONYMOUS: - statusView.setImageResource(R.drawable.identity_anonymous); - break; - case UNKNOWN: - statusView.setImageResource(R.drawable.identity_unknown); - break; - case UNVERIFIED: - statusView.setImageResource(R.drawable.identity_unverified); - break; - case VERIFIED: - statusView.setImageResource(R.drawable.identity_verified); - break; - } - } -} diff --git a/briar-android/src/org/briarproject/android/util/TrustIndicatorView.java b/briar-android/src/org/briarproject/android/util/TrustIndicatorView.java new file mode 100644 index 000000000..ce01bf301 --- /dev/null +++ b/briar-android/src/org/briarproject/android/util/TrustIndicatorView.java @@ -0,0 +1,44 @@ +package org.briarproject.android.util; + +import android.content.Context; +import android.support.v4.content.ContextCompat; +import android.util.AttributeSet; +import android.widget.ImageView; + +import org.briarproject.R; +import org.briarproject.api.identity.Author.Status; + +public class TrustIndicatorView extends ImageView { + + public TrustIndicatorView(Context context) { + super(context); + } + + public TrustIndicatorView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public TrustIndicatorView(Context context, AttributeSet attrs, + int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public void setTrustLevel(Status status) { + int res; + switch (status) { + case ANONYMOUS: + res = R.drawable.trust_indicator_anonymous; + break; + case UNVERIFIED: + res = R.drawable.trust_indicator_unverified; + break; + case VERIFIED: + res = R.drawable.trust_indicator_verified; + break; + default: + res = R.drawable.trust_indicator_unknown; + } + setImageDrawable(ContextCompat.getDrawable(getContext(), res)); + } + +}