mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49: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:
@@ -17,6 +17,7 @@ dependencies {
|
|||||||
compile "org.roboguice:roboguice:2.0"
|
compile "org.roboguice:roboguice:2.0"
|
||||||
compile "info.guardianproject.panic:panic:0.5"
|
compile "info.guardianproject.panic:panic:0.5"
|
||||||
compile "info.guardianproject.trustedintents:trustedintents:0.2"
|
compile "info.guardianproject.trustedintents:trustedintents:0.2"
|
||||||
|
compile "de.hdodenhof:circleimageview:2.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<im.delight.android.identicons.SymmetricIdenticon
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/identiconView"
|
android:id="@+id/avatarView"
|
||||||
android:layout_width="@dimen/listitem_picture_size"
|
android:layout_width="@dimen/listitem_picture_size"
|
||||||
android:layout_height="@dimen/listitem_picture_size"
|
android:layout_height="@dimen/listitem_picture_size"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<im.delight.android.identicons.SymmetricIdenticon
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/identiconView"
|
android:id="@+id/avatarView"
|
||||||
android:layout_width="@dimen/dropdown_picture_size"
|
android:layout_width="@dimen/dropdown_picture_size"
|
||||||
android:layout_height="@dimen/dropdown_picture_size"/>
|
android:layout_height="@dimen/dropdown_picture_size"/>
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
android:layout_height="@dimen/listitem_height_one_line_avatar"
|
android:layout_height="@dimen/listitem_height_one_line_avatar"
|
||||||
android:background="?attr/selectableItemBackground">
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<im.delight.android.identicons.SymmetricIdenticon
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/identiconView"
|
android:id="@+id/avatarView"
|
||||||
android:layout_width="@dimen/listitem_picture_size"
|
android:layout_width="@dimen/listitem_picture_size"
|
||||||
android:layout_height="@dimen/listitem_picture_size"
|
android:layout_height="@dimen/listitem_picture_size"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
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
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/msgIdenticon"
|
android:id="@+id/msgAvatar"
|
||||||
android:layout_width="@dimen/listitem_picture_size"
|
android:layout_width="@dimen/listitem_picture_size"
|
||||||
android:layout_height="@dimen/listitem_picture_size"
|
android:layout_height="@dimen/listitem_picture_size"
|
||||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||||
|
|||||||
@@ -48,6 +48,16 @@ public class IdenticonDrawable extends Drawable {
|
|||||||
mDelegate.show(toShow);
|
mDelegate.show(toShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIntrinsicHeight() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIntrinsicWidth() {
|
||||||
|
return 200;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBounds(Rect bounds) {
|
public void setBounds(Rect bounds) {
|
||||||
super.setBounds(bounds);
|
super.setBounds(bounds);
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.identity.Author;
|
import org.briarproject.api.identity.Author;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.List;
|
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;
|
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||||
|
|
||||||
@@ -86,9 +87,11 @@ public class ContactListAdapter
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
|
private CryptoComponent crypto;
|
||||||
|
|
||||||
public ContactListAdapter(Context context) {
|
public ContactListAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||||
ctx = context;
|
ctx = context;
|
||||||
|
crypto = cryptoComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,7 +120,8 @@ public class ContactListAdapter
|
|||||||
}
|
}
|
||||||
|
|
||||||
Author author = item.getContact().getAuthor();
|
Author author = item.getContact().getAuthor();
|
||||||
ui.identicon.show(author.getId().getBytes());
|
ui.avatar.setImageDrawable(
|
||||||
|
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||||
String contactName = author.getName();
|
String contactName = author.getName();
|
||||||
if (unread > 0) {
|
if (unread > 0) {
|
||||||
ui.name.setText(contactName + " (" + unread + ")");
|
ui.name.setText(contactName + " (" + unread + ")");
|
||||||
@@ -198,7 +202,7 @@ public class ContactListAdapter
|
|||||||
public static class ContactHolder extends RecyclerView.ViewHolder {
|
public static class ContactHolder extends RecyclerView.ViewHolder {
|
||||||
public ViewGroup layout;
|
public ViewGroup layout;
|
||||||
public ImageView bulb;
|
public ImageView bulb;
|
||||||
public IdenticonView identicon;
|
public ImageView avatar;
|
||||||
public TextView name;
|
public TextView name;
|
||||||
public TextView date;
|
public TextView date;
|
||||||
|
|
||||||
@@ -207,7 +211,7 @@ public class ContactListAdapter
|
|||||||
|
|
||||||
layout = (ViewGroup) v;
|
layout = (ViewGroup) v;
|
||||||
bulb = (ImageView) v.findViewById(R.id.bulbView);
|
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);
|
name = (TextView) v.findViewById(R.id.nameView);
|
||||||
date = (TextView) v.findViewById(R.id.dateView);
|
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.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
import org.briarproject.api.event.ContactAddedEvent;
|
import org.briarproject.api.event.ContactAddedEvent;
|
||||||
@@ -62,6 +63,8 @@ public class ContactListFragment extends BaseEventFragment {
|
|||||||
return TAG;
|
return TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CryptoComponent crypto;
|
||||||
@Inject
|
@Inject
|
||||||
private ConnectionRegistry connectionRegistry;
|
private ConnectionRegistry connectionRegistry;
|
||||||
private ContactListAdapter adapter = null;
|
private ContactListAdapter adapter = null;
|
||||||
@@ -83,7 +86,7 @@ public class ContactListFragment extends BaseEventFragment {
|
|||||||
inflater.inflate(R.layout.activity_contact_list, container,
|
inflater.inflate(R.layout.activity_contact_list, container,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
adapter = new ContactListAdapter(getContext());
|
adapter = new ContactListAdapter(getContext(), crypto);
|
||||||
list = (BriarRecyclerView) contentView.findViewById(R.id.contactList);
|
list = (BriarRecyclerView) contentView.findViewById(R.id.contactList);
|
||||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.briarproject.api.android.AndroidNotificationManager;
|
|||||||
import org.briarproject.api.contact.Contact;
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.crypto.CryptoExecutor;
|
import org.briarproject.api.crypto.CryptoExecutor;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
@@ -71,6 +72,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(ConversationActivity.class.getName());
|
Logger.getLogger(ConversationActivity.class.getName());
|
||||||
|
|
||||||
|
@Inject private CryptoComponent crypto;
|
||||||
@Inject private AndroidNotificationManager notificationManager;
|
@Inject private AndroidNotificationManager notificationManager;
|
||||||
@Inject private ConnectionRegistry connectionRegistry;
|
@Inject private ConnectionRegistry connectionRegistry;
|
||||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||||
@@ -102,7 +104,7 @@ public class ConversationActivity extends BriarActivity
|
|||||||
|
|
||||||
setContentView(R.layout.activity_conversation);
|
setContentView(R.layout.activity_conversation);
|
||||||
|
|
||||||
adapter = new ConversationAdapter(this);
|
adapter = new ConversationAdapter(this, crypto);
|
||||||
list = (BriarRecyclerView) findViewById(R.id.conversationView);
|
list = (BriarRecyclerView) findViewById(R.id.conversationView);
|
||||||
list.setLayoutManager(new LinearLayoutManager(this));
|
list.setLayoutManager(new LinearLayoutManager(this));
|
||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
|
|||||||
@@ -11,10 +11,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
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 im.delight.android.identicons.IdenticonDrawable;
|
||||||
|
|
||||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||||
|
|
||||||
@@ -72,10 +73,12 @@ class ConversationAdapter extends
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
|
private CryptoComponent crypto;
|
||||||
private byte[] identiconKey;
|
private byte[] identiconKey;
|
||||||
|
|
||||||
public ConversationAdapter(Context context) {
|
public ConversationAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||||
ctx = context;
|
ctx = context;
|
||||||
|
crypto = cryptoComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIdenticonKey(byte[] key) {
|
public void setIdenticonKey(byte[] key) {
|
||||||
@@ -129,7 +132,8 @@ class ConversationAdapter extends
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (identiconKey != null)
|
if (identiconKey != null)
|
||||||
ui.identicon.show(identiconKey);
|
ui.avatar.setImageDrawable(
|
||||||
|
new IdenticonDrawable(crypto, identiconKey));
|
||||||
if (!header.isRead()) {
|
if (!header.isRead()) {
|
||||||
int left = ui.layout.getPaddingLeft();
|
int left = ui.layout.getPaddingLeft();
|
||||||
int top = ui.layout.getPaddingTop();
|
int top = ui.layout.getPaddingTop();
|
||||||
@@ -198,7 +202,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 ImageView avatar;
|
||||||
|
|
||||||
public MessageHolder(View v, int type) {
|
public MessageHolder(View v, int type) {
|
||||||
super(v);
|
super(v);
|
||||||
@@ -211,7 +215,7 @@ class ConversationAdapter extends
|
|||||||
if (type == MSG_OUT) {
|
if (type == MSG_OUT) {
|
||||||
status = (ImageView) v.findViewById(R.id.msgStatus);
|
status = (ImageView) v.findViewById(R.id.msgStatus);
|
||||||
} else {
|
} else {
|
||||||
identicon = (IdenticonView) v.findViewById(R.id.msgIdenticon);
|
avatar = (ImageView) v.findViewById(R.id.msgAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ implements OnItemSelectedListener, OnClickListener {
|
|||||||
left.addRule(CENTER_VERTICAL);
|
left.addRule(CENTER_VERTICAL);
|
||||||
header.addView(from, left);
|
header.addView(from, left);
|
||||||
|
|
||||||
adapter = new LocalAuthorSpinnerAdapter(this, true);
|
adapter = new LocalAuthorSpinnerAdapter(this, crypto, true);
|
||||||
spinner = new Spinner(this);
|
spinner = new Spinner(this);
|
||||||
spinner.setId(2);
|
spinner.setId(2);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
|
|||||||
@@ -5,17 +5,19 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.SpinnerAdapter;
|
import android.widget.SpinnerAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import im.delight.android.identicons.IdenticonView;
|
import im.delight.android.identicons.IdenticonDrawable;
|
||||||
|
|
||||||
import static org.briarproject.android.identity.LocalAuthorItem.ANONYMOUS;
|
import static org.briarproject.android.identity.LocalAuthorItem.ANONYMOUS;
|
||||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||||
@@ -24,11 +26,14 @@ public class LocalAuthorSpinnerAdapter extends BaseAdapter
|
|||||||
implements SpinnerAdapter {
|
implements SpinnerAdapter {
|
||||||
|
|
||||||
private final Context ctx;
|
private final Context ctx;
|
||||||
|
private final CryptoComponent crypto;
|
||||||
private final boolean includeAnonymous;
|
private final boolean includeAnonymous;
|
||||||
private final List<LocalAuthorItem> list = new ArrayList<LocalAuthorItem>();
|
private final List<LocalAuthorItem> list = new ArrayList<LocalAuthorItem>();
|
||||||
|
|
||||||
public LocalAuthorSpinnerAdapter(Context ctx, boolean includeAnonymous) {
|
public LocalAuthorSpinnerAdapter(Context ctx,
|
||||||
|
CryptoComponent crypto, boolean includeAnonymous) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
this.crypto = crypto;
|
||||||
this.includeAnonymous = includeAnonymous;
|
this.includeAnonymous = includeAnonymous;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,20 +65,21 @@ implements SpinnerAdapter {
|
|||||||
view = convertView;
|
view = convertView;
|
||||||
|
|
||||||
TextView name = (TextView) view.findViewById(R.id.nameView);
|
TextView name = (TextView) view.findViewById(R.id.nameView);
|
||||||
IdenticonView identicon =
|
ImageView avatar =
|
||||||
(IdenticonView) view.findViewById(R.id.identiconView);
|
(ImageView) view.findViewById(R.id.avatarView);
|
||||||
|
|
||||||
LocalAuthorItem item = getItem(position);
|
LocalAuthorItem item = getItem(position);
|
||||||
if (item == ANONYMOUS) {
|
if (item == ANONYMOUS) {
|
||||||
name.setText(R.string.anonymous);
|
name.setText(R.string.anonymous);
|
||||||
identicon.setVisibility(View.INVISIBLE);
|
avatar.setVisibility(View.INVISIBLE);
|
||||||
} else if (item == NEW) {
|
} else if (item == NEW) {
|
||||||
name.setText(R.string.new_identity_item);
|
name.setText(R.string.new_identity_item);
|
||||||
identicon.setVisibility(View.INVISIBLE);
|
avatar.setVisibility(View.INVISIBLE);
|
||||||
} else {
|
} else {
|
||||||
name.setText(item.getLocalAuthor().getName());
|
name.setText(item.getLocalAuthor().getName());
|
||||||
identicon.setVisibility(View.VISIBLE);
|
avatar.setVisibility(View.VISIBLE);
|
||||||
identicon.show(item.getLocalAuthor().getId().getBytes());
|
avatar.setImageDrawable(new IdenticonDrawable(crypto,
|
||||||
|
item.getLocalAuthor().getId().getBytes()));
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,16 @@ import org.briarproject.android.identity.CreateIdentityActivity;
|
|||||||
import org.briarproject.android.identity.LocalAuthorItem;
|
import org.briarproject.android.identity.LocalAuthorItem;
|
||||||
import org.briarproject.android.identity.LocalAuthorItemComparator;
|
import org.briarproject.android.identity.LocalAuthorItemComparator;
|
||||||
import org.briarproject.android.identity.LocalAuthorSpinnerAdapter;
|
import org.briarproject.android.identity.LocalAuthorSpinnerAdapter;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.identity.AuthorId;
|
import org.briarproject.api.identity.AuthorId;
|
||||||
import org.briarproject.api.identity.LocalAuthor;
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import roboguice.RoboGuice;
|
||||||
|
|
||||||
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
||||||
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
||||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||||
@@ -30,6 +35,7 @@ import static org.briarproject.android.invitation.AddContactActivity.REQUEST_CRE
|
|||||||
class ChooseIdentityView extends AddContactView
|
class ChooseIdentityView extends AddContactView
|
||||||
implements OnItemSelectedListener, OnClickListener {
|
implements OnItemSelectedListener, OnClickListener {
|
||||||
|
|
||||||
|
@Inject private CryptoComponent crypto;
|
||||||
private LocalAuthorSpinnerAdapter adapter = null;
|
private LocalAuthorSpinnerAdapter adapter = null;
|
||||||
private Spinner spinner = null;
|
private Spinner spinner = null;
|
||||||
|
|
||||||
@@ -40,6 +46,7 @@ implements OnItemSelectedListener, OnClickListener {
|
|||||||
void populate() {
|
void populate() {
|
||||||
removeAllViews();
|
removeAllViews();
|
||||||
Context ctx = getContext();
|
Context ctx = getContext();
|
||||||
|
RoboGuice.injectMembers(ctx, this);
|
||||||
|
|
||||||
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService
|
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService
|
||||||
(Context.LAYOUT_INFLATER_SERVICE);
|
(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
@@ -50,7 +57,7 @@ implements OnItemSelectedListener, OnClickListener {
|
|||||||
TextView step = (TextView) view.findViewById(R.id.stepView);
|
TextView step = (TextView) view.findViewById(R.id.stepView);
|
||||||
step.setText(String.format(ctx.getString(R.string.step), 1, 3));
|
step.setText(String.format(ctx.getString(R.string.step), 1, 3));
|
||||||
|
|
||||||
adapter = new LocalAuthorSpinnerAdapter(ctx, false);
|
adapter = new LocalAuthorSpinnerAdapter(ctx, crypto, false);
|
||||||
spinner = (Spinner) view.findViewById(R.id.spinner);
|
spinner = (Spinner) view.findViewById(R.id.spinner);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
spinner.setOnItemSelectedListener(this);
|
spinner.setOnItemSelectedListener(this);
|
||||||
|
|||||||
@@ -9,13 +9,18 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
import org.briarproject.api.identity.Author;
|
import org.briarproject.api.identity.Author;
|
||||||
|
|
||||||
import im.delight.android.identicons.IdenticonView;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import im.delight.android.identicons.IdenticonDrawable;
|
||||||
|
import roboguice.RoboGuice;
|
||||||
|
|
||||||
public class AuthorView extends FrameLayout {
|
public class AuthorView extends FrameLayout {
|
||||||
|
|
||||||
private IdenticonView identiconView;
|
@Inject private CryptoComponent crypto;
|
||||||
|
private ImageView avatarView;
|
||||||
private TextView nameView;
|
private TextView nameView;
|
||||||
private ImageView statusView;
|
private ImageView statusView;
|
||||||
|
|
||||||
@@ -39,13 +44,14 @@ public class AuthorView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initViews() {
|
private void initViews() {
|
||||||
|
RoboGuice.injectMembers(getContext(), this);
|
||||||
if (isInEditMode())
|
if (isInEditMode())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
View v = LayoutInflater.from(getContext()).inflate(
|
View v = LayoutInflater.from(getContext()).inflate(
|
||||||
R.layout.author_view, this, true);
|
R.layout.author_view, this, true);
|
||||||
|
|
||||||
identiconView = (IdenticonView) v.findViewById(R.id.identiconView);
|
avatarView = (ImageView) v.findViewById(R.id.avatarView);
|
||||||
nameView = (TextView) v.findViewById(R.id.nameView);
|
nameView = (TextView) v.findViewById(R.id.nameView);
|
||||||
statusView = (ImageView) v.findViewById(R.id.statusView);
|
statusView = (ImageView) v.findViewById(R.id.statusView);
|
||||||
}
|
}
|
||||||
@@ -53,7 +59,8 @@ public class AuthorView extends FrameLayout {
|
|||||||
public void init(Author author, Author.Status status) {
|
public void init(Author author, Author.Status status) {
|
||||||
if (author == null) nameView.setText(R.string.anonymous);
|
if (author == null) nameView.setText(R.string.anonymous);
|
||||||
else {
|
else {
|
||||||
identiconView.show(author.getId().getBytes());
|
avatarView.setImageDrawable(
|
||||||
|
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||||
nameView.setText(author.getName());
|
nameView.setText(author.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user