Improved ContactAvatar class
This commit is contained in:
parent
54933523c3
commit
e69edc7ebe
16 changed files with 132 additions and 143 deletions
|
@ -77,29 +77,13 @@
|
|||
android:layout_below="@id/separator"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_picture"
|
||||
android:src="@drawable/avatar"
|
||||
android:contentDescription="@string/content_description_contact_picture"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:adjustViewBounds="true"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mask"
|
||||
android:src="@drawable/avatar_chat_mask"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:adjustViewBounds="true"/>
|
||||
<include layout="@layout/contact_avatar"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
@ -52,7 +52,7 @@
|
|||
android:maxLines="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/avatar_layout"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_toLeftOf="@id/time"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="5dp"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
@ -94,7 +94,7 @@
|
|||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/avatar_layout"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/adminLayout"
|
||||
android:layout_marginLeft="10dp">
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/avatar_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="35dp"
|
||||
android:gravity="center"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
|
@ -30,4 +30,13 @@
|
|||
android:gravity="center"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/security_level"
|
||||
android:visibility="gone"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@drawable/security_alert_indicator"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -34,7 +34,7 @@
|
|||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
@ -83,7 +83,7 @@
|
|||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/avatar_layout"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/friendLinphone"
|
||||
android:layout_marginLeft="10dp">
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
android:gravity="center_vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
@ -79,7 +79,7 @@
|
|||
android:src="@drawable/call_status_incoming"
|
||||
android:contentDescription="@string/content_description_call_direction"
|
||||
android:padding="7dp"
|
||||
android:layout_toRightOf="@id/avatar_layout"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:adjustViewBounds="true"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/avatar_layout"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
@ -25,7 +25,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginRight="70dp"
|
||||
android:layout_toRightOf="@id/avatar_layout"
|
||||
android:layout_toRightOf="@id/avatar"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
|
|
@ -55,8 +55,7 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
public ImageView detail;
|
||||
public CheckBox select;
|
||||
public ImageView callDirection;
|
||||
public ImageView contactPicture;
|
||||
public TextView generatedAvatar;
|
||||
public RelativeLayout avatarLayout;
|
||||
public RelativeLayout CallContact;
|
||||
public LinearLayout separator;
|
||||
public TextView separatorText;
|
||||
|
@ -68,8 +67,7 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
detail = view.findViewById(R.id.detail);
|
||||
select = view.findViewById(R.id.delete);
|
||||
callDirection = view.findViewById(R.id.icon);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
||||
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||
CallContact = view.findViewById(R.id.history_click);
|
||||
separator = view.findViewById(R.id.separator);
|
||||
separatorText = view.findViewById(R.id.separator_text);
|
||||
|
@ -181,9 +179,9 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
}
|
||||
|
||||
if (c != null) {
|
||||
ContactAvatar.displayAvatar(c, holder.contactPicture, holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(displayName, holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(displayName, holder.avatarLayout);
|
||||
}
|
||||
|
||||
holder.detail.setVisibility(isEditionEnabled() ? View.INVISIBLE : View.VISIBLE);
|
||||
|
|
|
@ -43,8 +43,7 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
public RelativeLayout bubbleLayout;
|
||||
public LinearLayout separatorLayout;
|
||||
public LinearLayout background;
|
||||
public ImageView contactPicture;
|
||||
public ImageView contactPictureMask;
|
||||
public RelativeLayout avatarLayout;
|
||||
public TextView contactName;
|
||||
|
||||
public ImageView messageStatus;
|
||||
|
@ -67,40 +66,9 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
private ClickListener mListener;
|
||||
|
||||
public ChatBubbleViewHolder(Context context, View view, ClickListener listener) {
|
||||
super(view);
|
||||
this(view);
|
||||
mContext = context;
|
||||
|
||||
eventLayout = view.findViewById(R.id.event);
|
||||
//eventTime = view.findViewById(R.id.event_date);
|
||||
eventMessage = view.findViewById(R.id.event_text);
|
||||
|
||||
bubbleLayout = view.findViewById(R.id.bubble);
|
||||
background = view.findViewById(R.id.background);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
contactPictureMask = view.findViewById(R.id.mask);
|
||||
contactName = view.findViewById(R.id.contact_header);
|
||||
|
||||
messageStatus = view.findViewById(R.id.status);
|
||||
messageSendingInProgress = view.findViewById(R.id.inprogress);
|
||||
imdmLayout = view.findViewById(R.id.imdmLayout);
|
||||
imdmIcon = view.findViewById(R.id.imdmIcon);
|
||||
imdmLabel = view.findViewById(R.id.imdmText);
|
||||
|
||||
messageText = view.findViewById(R.id.message);
|
||||
messageImage = view.findViewById(R.id.image);
|
||||
separatorLayout = view.findViewById(R.id.separator);
|
||||
|
||||
fileTransferLayout = view.findViewById(R.id.file_transfer_layout);
|
||||
fileTransferProgressBar = view.findViewById(R.id.progress_bar);
|
||||
fileTransferAction = view.findViewById(R.id.file_transfer_action);
|
||||
|
||||
fileName = view.findViewById(R.id.file_name);
|
||||
openFileButton = view.findViewById(R.id.open_file);
|
||||
|
||||
delete = view.findViewById(R.id.delete_message);
|
||||
|
||||
mListener = listener;
|
||||
|
||||
view.setOnClickListener(this);
|
||||
}
|
||||
|
||||
|
@ -112,8 +80,7 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
|
||||
bubbleLayout = view.findViewById(R.id.bubble);
|
||||
background = view.findViewById(R.id.background);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
contactPictureMask = view.findViewById(R.id.mask);
|
||||
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||
contactName = view.findViewById(R.id.contact_header);
|
||||
|
||||
messageStatus = view.findViewById(R.id.status);
|
||||
|
|
|
@ -59,6 +59,7 @@ import org.linphone.core.Content;
|
|||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.LimeState;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ContactAvatar;
|
||||
import org.linphone.ui.SelectableAdapter;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
|
@ -162,7 +163,6 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
holder.messageStatus.setVisibility(View.INVISIBLE);
|
||||
holder.messageSendingInProgress.setVisibility(View.GONE);
|
||||
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
|
||||
if (isEditionEnabled()) {
|
||||
holder.delete.setOnCheckedChangeListener(null);
|
||||
|
@ -249,7 +249,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font3);
|
||||
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font15);
|
||||
holder.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
||||
holder.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask_outgoing);
|
||||
ContactAvatar.setAvatarMask(holder.avatarLayout, R.drawable.avatar_chat_mask_outgoing);
|
||||
} else {
|
||||
for (LinphoneContact c : mParticipants) {
|
||||
if (c != null && c.hasAddress(remoteSender.asStringUriOnly())) {
|
||||
|
@ -270,7 +270,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
Compatibility.setTextAppearance(holder.contactName, mContext, R.style.font9);
|
||||
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font8);
|
||||
holder.fileTransferAction.setBackgroundResource(R.drawable.resizable_assistant_button);
|
||||
holder.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask);
|
||||
ContactAvatar.setAvatarMask(holder.avatarLayout, R.drawable.avatar_chat_mask);
|
||||
}
|
||||
|
||||
if (contact == null) {
|
||||
|
@ -282,14 +282,10 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
} else {
|
||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||
}
|
||||
|
||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
if (contact.hasPhoto()) {
|
||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
||||
}
|
||||
ContactAvatar.displayAvatar(contact, holder.avatarLayout);
|
||||
} else {
|
||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
ContactAvatar.displayAvatar(displayName, holder.avatarLayout);
|
||||
}
|
||||
holder.contactName.setText(LinphoneUtils.timestampToHumanDate(mContext, message.getTime(), R.string.messages_date_format) + " - " + displayName);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
|
@ -51,8 +52,7 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
public TextView displayName;
|
||||
public TextView unreadMessages;
|
||||
public CheckBox delete;
|
||||
public ImageView contactPicture;
|
||||
public TextView generatedAvatar;
|
||||
public RelativeLayout avatarLayout;
|
||||
public ImageView lastMessageFileTransfer;
|
||||
public Context mContext;
|
||||
public ChatRoom mRoom;
|
||||
|
@ -71,8 +71,7 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
displayName = itemView.findViewById(R.id.sipUri);
|
||||
unreadMessages = itemView.findViewById(R.id.unreadMessages);
|
||||
delete = itemView.findViewById(R.id.delete_chatroom);
|
||||
contactPicture = itemView.findViewById(R.id.contact_picture);
|
||||
generatedAvatar = itemView.findViewById(R.id.generated_avatar);
|
||||
avatarLayout = itemView.findViewById(R.id.avatar_layout);
|
||||
lastMessageFileTransfer = itemView.findViewById(R.id.lastMessageFileTransfer);
|
||||
mListener = listener;
|
||||
|
||||
|
@ -159,17 +158,17 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
|||
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||
if (contact != null) {
|
||||
ContactAvatar.displayAvatar(contact, contactPicture, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(contact, avatarLayout);
|
||||
} else {
|
||||
String username = mRoom.getPeerAddress().getDisplayName();
|
||||
if (username == null) {
|
||||
username = mRoom.getPeerAddress().getUsername();
|
||||
}
|
||||
ContactAvatar.displayAvatar(username, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(username, avatarLayout);
|
||||
}
|
||||
} else {
|
||||
contactPicture.setImageBitmap(mDefaultGroupBitmap);
|
||||
generatedAvatar.setVisibility(View.GONE);
|
||||
((ImageView)avatarLayout.findViewById(R.id.contact_picture)).setImageBitmap(mDefaultGroupBitmap);
|
||||
avatarLayout.findViewById(R.id.generated_avatar).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneUtils;
|
||||
|
@ -44,8 +45,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
|||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public TextView name;
|
||||
public ImageView avatar;
|
||||
public TextView generatedAvatar;
|
||||
public RelativeLayout avatarLayout;
|
||||
public ImageView delete;
|
||||
public LinearLayout isAdmin;
|
||||
public LinearLayout isNotAdmin;
|
||||
|
@ -53,8 +53,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
|||
public ViewHolder(View view) {
|
||||
super(view);
|
||||
name = view.findViewById(R.id.name);
|
||||
avatar = view.findViewById(R.id.contact_picture);
|
||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
||||
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||
delete = view.findViewById(R.id.delete);
|
||||
isAdmin = view.findViewById(R.id.isAdminLayout);
|
||||
isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
|
||||
|
@ -87,9 +86,9 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
|||
(ca.getDisplayName() != null) ? ca.getDisplayName() : ca.getUsername());
|
||||
|
||||
if (c != null) {
|
||||
ContactAvatar.displayAvatar(c, holder.avatar, holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);
|
||||
}
|
||||
|
||||
holder.delete.setOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -116,7 +116,6 @@ public class ImdnFragment extends Fragment {
|
|||
mBubble.messageStatus.setVisibility(View.INVISIBLE);
|
||||
mBubble.messageSendingInProgress.setVisibility(View.GONE);
|
||||
mBubble.imdmLayout.setVisibility(View.INVISIBLE);
|
||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
|
||||
mMessage = mRoom.findMessage(mMessageId);
|
||||
mListener = new ChatMessageListenerStub() {
|
||||
|
@ -135,13 +134,13 @@ public class ImdnFragment extends Fragment {
|
|||
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font3);
|
||||
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font15);
|
||||
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
||||
mBubble.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask_outgoing);
|
||||
ContactAvatar.setAvatarMask(mBubble.avatarLayout, R.drawable.avatar_chat_mask_outgoing);
|
||||
} else {
|
||||
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
|
||||
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font9);
|
||||
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font8);
|
||||
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_assistant_button);
|
||||
mBubble.contactPictureMask.setImageResource(R.drawable.avatar_chat_mask);
|
||||
ContactAvatar.setAvatarMask(mBubble.avatarLayout, R.drawable.avatar_chat_mask);
|
||||
}
|
||||
|
||||
return view;
|
||||
|
@ -166,13 +165,10 @@ public class ImdnFragment extends Fragment {
|
|||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||
}
|
||||
|
||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
if (contact.hasPhoto()) {
|
||||
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), mBubble.contactPicture, contact.getThumbnailUri());
|
||||
}
|
||||
ContactAvatar.displayAvatar(contact, mBubble.avatarLayout);
|
||||
} else {
|
||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
ContactAvatar.displayAvatar(displayName, mBubble.avatarLayout);
|
||||
}
|
||||
mBubble.contactName.setText(LinphoneUtils.timestampToHumanDate(getActivity(), mMessage.getTime(), R.string.messages_date_format) + " - " + displayName);
|
||||
|
||||
|
@ -206,15 +202,13 @@ public class ImdnFragment extends Fragment {
|
|||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||
|
||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
||||
ImageView contactPicture = v.findViewById(R.id.contact_picture);
|
||||
TextView generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||
((TextView) v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||
if (participantContact != null) {
|
||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||
}
|
||||
|
||||
mRead.addView(v);
|
||||
|
@ -231,15 +225,13 @@ public class ImdnFragment extends Fragment {
|
|||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||
|
||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
||||
ImageView contactPicture = v.findViewById(R.id.contact_picture);
|
||||
TextView generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||
((TextView) v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||
if (participantContact != null) {
|
||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||
}
|
||||
|
||||
mDelivered.addView(v);
|
||||
|
@ -256,15 +248,13 @@ public class ImdnFragment extends Fragment {
|
|||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||
|
||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
||||
ImageView contactPicture = v.findViewById(R.id.contact_picture);
|
||||
TextView generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||
((TextView) v.findViewById(R.id.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||
if (participantContact != null) {
|
||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||
}
|
||||
|
||||
mSent.addView(v);
|
||||
|
@ -281,14 +271,12 @@ public class ImdnFragment extends Fragment {
|
|||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||
|
||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
||||
ImageView contactPicture = v.findViewById(R.id.contact_picture);
|
||||
TextView generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||
if (participantContact != null) {
|
||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
||||
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||
}
|
||||
|
||||
mUndelivered.addView(v);
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.view.ViewGroup;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SectionIndexer;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -52,8 +53,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
|||
public TextView name;
|
||||
public LinearLayout separator;
|
||||
public TextView separatorText;
|
||||
public ImageView contactPicture;
|
||||
public TextView generatedAvatar;
|
||||
public RelativeLayout avatarLayout;
|
||||
public TextView organization;
|
||||
//public ImageView friendStatus;
|
||||
private ClickListener mListener;
|
||||
|
@ -66,8 +66,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
|||
name = view.findViewById(R.id.name);
|
||||
separator = view.findViewById(R.id.separator);
|
||||
separatorText = view.findViewById(R.id.separator_text);
|
||||
contactPicture = view.findViewById(R.id.contact_picture);
|
||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
||||
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||
organization = view.findViewById(R.id.contactOrganization);
|
||||
//friendStatus = view.findViewById(R.id.friendStatus);
|
||||
mListener = listener;
|
||||
|
@ -133,7 +132,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
|||
holder.separator.setVisibility(mIsSearchMode || (!mIsSearchMode && getPositionForSection(getSectionForPosition(position)) != position) ? View.GONE : View.VISIBLE);
|
||||
holder.linphoneFriend.setVisibility(contact.isInFriendList() ? View.VISIBLE : View.GONE);
|
||||
|
||||
ContactAvatar.displayAvatar(contact, holder.contactPicture, holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(contact, holder.avatarLayout);
|
||||
|
||||
boolean isOrgVisible = mContext.getResources().getBoolean(R.bool.display_contact_organization);
|
||||
String org = contact.getOrganization();
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
|
@ -53,8 +54,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
public TextView address;
|
||||
public ImageView linphoneContact;
|
||||
public ImageView isSelect;
|
||||
public ImageView avatar;
|
||||
public TextView generatedAvatar;
|
||||
public RelativeLayout avatarLayout;
|
||||
|
||||
private ClickListener mListener;
|
||||
|
||||
|
@ -64,8 +64,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
address = view.findViewById(R.id.contact_address);
|
||||
linphoneContact = view.findViewById(R.id.contact_linphone);
|
||||
isSelect = view.findViewById(R.id.contact_is_select);
|
||||
avatar = view.findViewById(R.id.contact_picture);
|
||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
||||
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||
mListener = listener;
|
||||
view.setOnClickListener(this);
|
||||
}
|
||||
|
@ -146,9 +145,9 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
}
|
||||
|
||||
if (c != null) {
|
||||
ContactAvatar.displayAvatar(c, holder.avatar, holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||
} else {
|
||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.generatedAvatar);
|
||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);
|
||||
}
|
||||
|
||||
holder.address.setText(a);
|
||||
|
|
|
@ -27,11 +27,25 @@ import android.widget.TextView;
|
|||
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
class ContactAvatarHolder {
|
||||
public ImageView contactPicture, avatarMask, securityLevel;
|
||||
public TextView generatedAvatar;
|
||||
|
||||
public ContactAvatarHolder(View v) {
|
||||
contactPicture = v.findViewById(R.id.contact_picture);
|
||||
avatarMask = v.findViewById(R.id.mask);
|
||||
securityLevel = v.findViewById(R.id.security_level);
|
||||
generatedAvatar = v.findViewById(R.id.generated_avatar);
|
||||
}
|
||||
}
|
||||
|
||||
public class ContactAvatar {
|
||||
|
||||
private static String generateAvatar(String displayName) {
|
||||
|
@ -43,14 +57,31 @@ public class ContactAvatar {
|
|||
return generatedAvatarText.toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
public static void displayAvatar(String displayName, TextView generatedAvatarView) {
|
||||
generatedAvatarView.setText(generateAvatar(displayName));
|
||||
generatedAvatarView.setVisibility(View.VISIBLE);
|
||||
public static void setAvatarMask(View v, int resourceId) {
|
||||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
holder.avatarMask.setImageResource(resourceId);
|
||||
}
|
||||
|
||||
public static void displayAvatar(LinphoneContact contact, ImageView contactPictureView, TextView generatedAvatarView) {
|
||||
public static void displayAvatar(String displayName, View v) {
|
||||
if (displayName == null || v == null) return;
|
||||
|
||||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
|
||||
if (displayName.startsWith("+")) {
|
||||
// If display name is a phone number, use default avatar because generated one will be +...
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
holder.generatedAvatar.setText(generateAvatar(displayName));
|
||||
holder.generatedAvatar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public static void displayAvatar(LinphoneContact contact, View v) {
|
||||
if (contact == null || v == null) return;
|
||||
|
||||
Bitmap bm = null;
|
||||
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||
|
||||
if (contact.getThumbnailUri() != null && contact.getThumbnailUri().getScheme().startsWith("http")) {
|
||||
bm = LinphoneUtils.downloadBitmap(contact.getThumbnailUri());
|
||||
|
@ -65,12 +96,32 @@ public class ContactAvatar {
|
|||
}
|
||||
|
||||
if (bm != null) {
|
||||
contactPictureView.setImageBitmap(bm);
|
||||
contactPictureView.setVisibility(View.VISIBLE);
|
||||
generatedAvatarView.setVisibility(View.GONE);
|
||||
holder.contactPicture.setImageBitmap(bm);
|
||||
holder.contactPicture.setVisibility(View.VISIBLE);
|
||||
holder.generatedAvatar.setVisibility(View.GONE);
|
||||
} else {
|
||||
generatedAvatarView.setText(generateAvatar(contact.getFullName()));
|
||||
generatedAvatarView.setVisibility(View.VISIBLE);
|
||||
holder.generatedAvatar.setText(generateAvatar(contact.getFullName()));
|
||||
holder.generatedAvatar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if (holder.securityLevel != null) {
|
||||
//TODO when security level will be available
|
||||
/*if (contact.hasSecurity()) {
|
||||
holder.securityLevel.setVisibility(View.VISIBLE);
|
||||
switch(contact.getSecurityLevel()) {
|
||||
case 0:
|
||||
holder.securityLevel.setImageResource(R.drawable.security_alert_indicator);
|
||||
break;
|
||||
case 1:
|
||||
holder.securityLevel.setImageResource(R.drawable.security_1_indicator.png);
|
||||
break;
|
||||
case 2:
|
||||
holder.securityLevel.setImageResource(R.drawable.security_2_indicator);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
holder.securityLevel.setVisibility(View.GONE);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue