mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Make identicons round
This commit renames identicons to avatars in field names, and uses an ImageView derivative to show the identicons, which should make implementing #214 easier.
This commit is contained in:
@@ -14,12 +14,13 @@ import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import im.delight.android.identicons.IdenticonView;
|
||||
import im.delight.android.identicons.IdenticonDrawable;
|
||||
|
||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||
|
||||
@@ -86,9 +87,11 @@ public class ContactListAdapter
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
|
||||
public ContactListAdapter(Context context) {
|
||||
public ContactListAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,7 +120,8 @@ public class ContactListAdapter
|
||||
}
|
||||
|
||||
Author author = item.getContact().getAuthor();
|
||||
ui.identicon.show(author.getId().getBytes());
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||
String contactName = author.getName();
|
||||
if (unread > 0) {
|
||||
ui.name.setText(contactName + " (" + unread + ")");
|
||||
@@ -198,7 +202,7 @@ public class ContactListAdapter
|
||||
public static class ContactHolder extends RecyclerView.ViewHolder {
|
||||
public ViewGroup layout;
|
||||
public ImageView bulb;
|
||||
public IdenticonView identicon;
|
||||
public ImageView avatar;
|
||||
public TextView name;
|
||||
public TextView date;
|
||||
|
||||
@@ -207,7 +211,7 @@ public class ContactListAdapter
|
||||
|
||||
layout = (ViewGroup) v;
|
||||
bulb = (ImageView) v.findViewById(R.id.bulbView);
|
||||
identicon = (IdenticonView) v.findViewById(R.id.identiconView);
|
||||
avatar = (ImageView) v.findViewById(R.id.avatarView);
|
||||
name = (TextView) v.findViewById(R.id.nameView);
|
||||
date = (TextView) v.findViewById(R.id.dateView);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.briarproject.android.util.BriarRecyclerView;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchContactException;
|
||||
import org.briarproject.api.event.ContactAddedEvent;
|
||||
@@ -62,6 +63,8 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private CryptoComponent crypto;
|
||||
@Inject
|
||||
private ConnectionRegistry connectionRegistry;
|
||||
private ContactListAdapter adapter = null;
|
||||
@@ -83,7 +86,7 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
inflater.inflate(R.layout.activity_contact_list, container,
|
||||
false);
|
||||
|
||||
adapter = new ContactListAdapter(getContext());
|
||||
adapter = new ContactListAdapter(getContext(), crypto);
|
||||
list = (BriarRecyclerView) contentView.findViewById(R.id.contactList);
|
||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchContactException;
|
||||
@@ -71,6 +72,7 @@ public class ConversationActivity extends BriarActivity
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
@Inject private ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@@ -102,7 +104,7 @@ public class ConversationActivity extends BriarActivity
|
||||
|
||||
setContentView(R.layout.activity_conversation);
|
||||
|
||||
adapter = new ConversationAdapter(this);
|
||||
adapter = new ConversationAdapter(this, crypto);
|
||||
list = (BriarRecyclerView) findViewById(R.id.conversationView);
|
||||
list.setLayoutManager(new LinearLayoutManager(this));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
@@ -11,10 +11,11 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import im.delight.android.identicons.IdenticonView;
|
||||
import im.delight.android.identicons.IdenticonDrawable;
|
||||
|
||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||
|
||||
@@ -72,10 +73,12 @@ class ConversationAdapter extends
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
private byte[] identiconKey;
|
||||
|
||||
public ConversationAdapter(Context context) {
|
||||
public ConversationAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
public void setIdenticonKey(byte[] key) {
|
||||
@@ -129,7 +132,8 @@ class ConversationAdapter extends
|
||||
}
|
||||
} else {
|
||||
if (identiconKey != null)
|
||||
ui.identicon.show(identiconKey);
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, identiconKey));
|
||||
if (!header.isRead()) {
|
||||
int left = ui.layout.getPaddingLeft();
|
||||
int top = ui.layout.getPaddingTop();
|
||||
@@ -198,7 +202,7 @@ class ConversationAdapter extends
|
||||
public TextView body;
|
||||
public TextView date;
|
||||
public ImageView status;
|
||||
public IdenticonView identicon;
|
||||
public ImageView avatar;
|
||||
|
||||
public MessageHolder(View v, int type) {
|
||||
super(v);
|
||||
@@ -211,7 +215,7 @@ class ConversationAdapter extends
|
||||
if (type == MSG_OUT) {
|
||||
status = (ImageView) v.findViewById(R.id.msgStatus);
|
||||
} else {
|
||||
identicon = (IdenticonView) v.findViewById(R.id.msgIdenticon);
|
||||
avatar = (ImageView) v.findViewById(R.id.msgAvatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user