mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Add identicons to conversations
This commit is contained in:
@@ -4,12 +4,20 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingRight="@dimen/margin_medium"
|
||||
android:paddingEnd="@dimen/margin_medium"
|
||||
android:paddingTop="@dimen/margin_small"
|
||||
android:paddingBottom="@dimen/margin_small">
|
||||
|
||||
<im.delight.android.identicons.SymmetricIdenticon
|
||||
android:id="@+id/msgIdenticon"
|
||||
android:layout_width="@dimen/listitem_picture_size"
|
||||
android:layout_height="@dimen/listitem_picture_size"
|
||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/msgLayout"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -88,6 +88,7 @@ public class ConversationActivity extends BriarActivity
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile ContactId contactId = null;
|
||||
private volatile String contactName = null;
|
||||
private volatile byte[] contactIdenticonKey = null;
|
||||
private volatile boolean connected = false;
|
||||
|
||||
@Override
|
||||
@@ -165,6 +166,7 @@ public class ConversationActivity extends BriarActivity
|
||||
contactId = messagingManager.getContactId(groupId);
|
||||
Contact contact = contactManager.getContact(contactId);
|
||||
contactName = contact.getAuthor().getName();
|
||||
contactIdenticonKey = contact.getAuthor().getId().getBytes();
|
||||
connected = connectionRegistry.isConnected(contactId);
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
@@ -192,6 +194,7 @@ public class ConversationActivity extends BriarActivity
|
||||
actionBar.setSubtitle(getString(R.string.offline));
|
||||
}
|
||||
}
|
||||
adapter.setIdenticonKey(contactIdenticonKey);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import org.briarproject.R;
|
||||
import org.briarproject.api.messaging.PrivateMessageHeader;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import im.delight.android.identicons.IdenticonView;
|
||||
|
||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||
|
||||
class ConversationAdapter extends
|
||||
@@ -70,11 +72,17 @@ class ConversationAdapter extends
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private byte[] identiconKey;
|
||||
|
||||
public ConversationAdapter(Context context) {
|
||||
ctx = context;
|
||||
}
|
||||
|
||||
public void setIdenticonKey(byte[] key) {
|
||||
this.identiconKey = key;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
// return different type for incoming and outgoing (local) messages
|
||||
@@ -119,18 +127,22 @@ class ConversationAdapter extends
|
||||
} else {
|
||||
ui.status.setImageResource(R.drawable.message_stored);
|
||||
}
|
||||
} else if (!header.isRead()) {
|
||||
int left = ui.layout.getPaddingLeft();
|
||||
int top = ui.layout.getPaddingTop();
|
||||
int right = ui.layout.getPaddingRight();
|
||||
int bottom = ui.layout.getPaddingBottom();
|
||||
} else {
|
||||
if (identiconKey != null)
|
||||
ui.identicon.show(identiconKey);
|
||||
if (!header.isRead()) {
|
||||
int left = ui.layout.getPaddingLeft();
|
||||
int top = ui.layout.getPaddingTop();
|
||||
int right = ui.layout.getPaddingRight();
|
||||
int bottom = ui.layout.getPaddingBottom();
|
||||
|
||||
// show unread messages in different color to not miss them
|
||||
ui.layout.setBackgroundResource(R.drawable.msg_in_unread);
|
||||
// show unread messages in different color to not miss them
|
||||
ui.layout.setBackgroundResource(R.drawable.msg_in_unread);
|
||||
|
||||
// re-apply the previous padding due to bug in some Android versions
|
||||
// see: https://code.google.com/p/android/issues/detail?id=17885
|
||||
ui.layout.setPadding(left, top, right, bottom);
|
||||
// re-apply the previous padding due to bug in some Android versions
|
||||
// see: https://code.google.com/p/android/issues/detail?id=17885
|
||||
ui.layout.setPadding(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getBody() == null) {
|
||||
@@ -186,6 +198,7 @@ class ConversationAdapter extends
|
||||
public TextView body;
|
||||
public TextView date;
|
||||
public ImageView status;
|
||||
public IdenticonView identicon;
|
||||
|
||||
public MessageHolder(View v, int type) {
|
||||
super(v);
|
||||
@@ -197,6 +210,8 @@ class ConversationAdapter extends
|
||||
// outgoing message (local)
|
||||
if (type == MSG_OUT) {
|
||||
status = (ImageView) v.findViewById(R.id.msgStatus);
|
||||
} else {
|
||||
identicon = (IdenticonView) v.findViewById(R.id.msgIdenticon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user