mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Add identicons to contact list
This commit is contained in:
@@ -2,49 +2,71 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="12dp">
|
||||
android:layout_height="@dimen/listitem_height_one_line_avatar"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bulbView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:layout_gravity="center_vertical"
|
||||
tools:src="@drawable/contact_disconnected"/>
|
||||
<im.delight.android.identicons.SymmetricIdenticon
|
||||
android:id="@+id/identiconView"
|
||||
android:layout_width="@dimen/listitem_picture_size"
|
||||
android:layout_height="@dimen/listitem_picture_size"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/margin_small"
|
||||
android:layout_marginEnd="@dimen/margin_small"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="This is a name of a contact. It can be quite long."/>
|
||||
<LinearLayout
|
||||
android:id="@+id/bulbHolder"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/listitem_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/listitem_horizontal_margin"
|
||||
android:gravity="right"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="@dimen/margin_small"
|
||||
android:layout_marginEnd="@dimen/margin_small"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/no_private_messages"
|
||||
tools:text="Dec 24"/>
|
||||
<ImageView
|
||||
android:id="@+id/bulbView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:src="@drawable/contact_disconnected"/>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/dateView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/no_private_messages"
|
||||
tools:text="Dec 24"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/margin_small"
|
||||
android:layout_marginLeft="@dimen/listitem_text_left_margin"
|
||||
android:layout_marginRight="@dimen/margin_small"
|
||||
android:layout_marginStart="@dimen/listitem_text_left_margin"
|
||||
android:layout_toLeftOf="@id/bulbHolder"
|
||||
android:layout_toStartOf="@id/bulbHolder"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
tools:text="This is a name of a contact. It can be quite long."/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View style="@style/Divider.Horizontal"/>
|
||||
|
||||
|
||||
@@ -20,4 +20,10 @@
|
||||
<dimen name="nav_drawer_width">300dp</dimen>
|
||||
<dimen name="nav_seperator_height">1dp</dimen>
|
||||
|
||||
<dimen name="listitem_horizontal_margin">16dp</dimen>
|
||||
<dimen name="listitem_picture_size">40dp</dimen>
|
||||
<dimen name="listitem_text_left_margin">72dp</dimen>
|
||||
|
||||
<dimen name="listitem_height_one_line_avatar">56dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -14,10 +14,13 @@ import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import im.delight.android.identicons.IdenticonView;
|
||||
|
||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||
|
||||
public class ContactListAdapter
|
||||
@@ -113,7 +116,9 @@ public class ContactListAdapter
|
||||
ui.bulb.setImageResource(R.drawable.contact_disconnected);
|
||||
}
|
||||
|
||||
String contactName = item.getContact().getAuthor().getName();
|
||||
Author author = item.getContact().getAuthor();
|
||||
ui.identicon.show(author.getId().getBytes());
|
||||
String contactName = author.getName();
|
||||
if (unread > 0) {
|
||||
ui.name.setText(contactName + " (" + unread + ")");
|
||||
} else {
|
||||
@@ -193,6 +198,7 @@ public class ContactListAdapter
|
||||
public static class ContactHolder extends RecyclerView.ViewHolder {
|
||||
public ViewGroup layout;
|
||||
public ImageView bulb;
|
||||
public IdenticonView identicon;
|
||||
public TextView name;
|
||||
public TextView date;
|
||||
|
||||
@@ -201,6 +207,7 @@ public class ContactListAdapter
|
||||
|
||||
layout = (ViewGroup) v;
|
||||
bulb = (ImageView) v.findViewById(R.id.bulbView);
|
||||
identicon = (IdenticonView) v.findViewById(R.id.identiconView);
|
||||
name = (TextView) v.findViewById(R.id.nameView);
|
||||
date = (TextView) v.findViewById(R.id.dateView);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user