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