Material design: contact chips
This commit is contained in:
@@ -201,9 +201,13 @@ public class NewEmailFragment extends Fragment {
|
||||
private void setViewContent(View v, int position) {
|
||||
Person person = getItem(position);
|
||||
((TextView)v.findViewById(R.id.contact_name)).setText(person.getName());
|
||||
if (person.getPicture() != null)
|
||||
((ImageView)v.findViewById(R.id.contact_picture))
|
||||
.setImageBitmap(person.getPicture());
|
||||
ImageView picView = (ImageView) v.findViewById(R.id.contact_picture);
|
||||
Bitmap picture = person.getPicture();
|
||||
if (picture == null) {
|
||||
ViewGroup.LayoutParams lp = picView.getLayoutParams();
|
||||
picture = BoteHelper.getIdenticonForAddress(person.getAddress(), lp.width, lp.height);
|
||||
}
|
||||
picView.setImageBitmap(picture);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ import i2p.bote.fileencryption.PasswordException;
|
||||
import i2p.bote.packet.dht.Contact;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -33,6 +35,14 @@ public class ContactsCompletionView extends TokenCompleteTextView {
|
||||
LinearLayout view = (LinearLayout)l.inflate(R.layout.contact_token, (ViewGroup)ContactsCompletionView.this.getParent(), false);
|
||||
((TextView)view.findViewById(R.id.contact_name)).setText(person.getName());
|
||||
|
||||
ImageView picView = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
Bitmap picture = person.getPicture();
|
||||
if (picture == null) {
|
||||
ViewGroup.LayoutParams lp = picView.getLayoutParams();
|
||||
picture = BoteHelper.getIdenticonForAddress(person.getAddress(), lp.width, lp.height);
|
||||
}
|
||||
picView.setImageBitmap(picture);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<solid android:color="#ffafafaf" />
|
||||
|
||||
<corners
|
||||
android:bottomLeftRadius="5dp"
|
||||
android:bottomRightRadius="5dp"
|
||||
android:topLeftRadius="5dp"
|
||||
android:topRightRadius="5dp" />
|
||||
android:bottomRightRadius="@dimen/contact_chip_corner_radius"
|
||||
android:topRightRadius="@dimen/contact_chip_corner_radius" />
|
||||
|
||||
</shape>
|
||||
@@ -1,16 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/contact_chip_height"
|
||||
android:background="@drawable/token_background"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:layout_width="@dimen/contact_chip_height"
|
||||
android:layout_height="@dimen/contact_chip_height"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/ic_contact_picture" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/token_background"
|
||||
android:padding="5dp"
|
||||
android:layout_height="@dimen/contact_chip_height"
|
||||
android:layout_marginEnd="@dimen/contact_chip_right_margin"
|
||||
android:layout_marginLeft="@dimen/contact_chip_main_margins"
|
||||
android:layout_marginRight="@dimen/contact_chip_right_margin"
|
||||
android:layout_marginStart="@dimen/contact_chip_main_margins"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp" />
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -11,4 +11,9 @@
|
||||
<dimen name="listitem_horizontal_margin">16dp</dimen>
|
||||
<dimen name="listitem_picture_size">40dp</dimen>
|
||||
<dimen name="listitem_text_left_margin">72dp</dimen>
|
||||
|
||||
<dimen name="contact_chip_height">32dp</dimen>
|
||||
<dimen name="contact_chip_main_margins">8dp</dimen>
|
||||
<dimen name="contact_chip_right_margin">12dp</dimen>
|
||||
<dimen name="contact_chip_corner_radius">16dp</dimen>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user