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:layout_below="@id/separator"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingTop="10dp">
|
||||||
|
|
||||||
<ImageView
|
<include layout="@layout/contact_avatar"/>
|
||||||
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"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="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_toLeftOf="@id/time"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/avatar_layout"
|
android:layout_toRightOf="@id/avatar"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toLeftOf="@id/adminLayout"
|
android:layout_toLeftOf="@id/adminLayout"
|
||||||
android:layout_marginLeft="10dp">
|
android:layout_marginLeft="10dp">
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="45dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="35dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_centerHorizontal="true">
|
android:layout_centerHorizontal="true">
|
||||||
|
|
||||||
|
@ -30,4 +30,13 @@
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"/>
|
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>
|
</RelativeLayout>
|
|
@ -34,7 +34,7 @@
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_toRightOf="@id/avatar_layout"
|
android:layout_toRightOf="@id/avatar"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_toLeftOf="@id/friendLinphone"
|
android:layout_toLeftOf="@id/friendLinphone"
|
||||||
android:layout_marginLeft="10dp">
|
android:layout_marginLeft="10dp">
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
android:src="@drawable/call_status_incoming"
|
android:src="@drawable/call_status_incoming"
|
||||||
android:contentDescription="@string/content_description_call_direction"
|
android:contentDescription="@string/content_description_call_direction"
|
||||||
android:padding="7dp"
|
android:padding="7dp"
|
||||||
android:layout_toRightOf="@id/avatar_layout"
|
android:layout_toRightOf="@id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/avatar_layout"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginRight="70dp"
|
android:layout_marginRight="70dp"
|
||||||
android:layout_toRightOf="@id/avatar_layout"
|
android:layout_toRightOf="@id/avatar"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentBottom="true">
|
android:layout_alignParentBottom="true">
|
||||||
|
|
|
@ -55,8 +55,7 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
||||||
public ImageView detail;
|
public ImageView detail;
|
||||||
public CheckBox select;
|
public CheckBox select;
|
||||||
public ImageView callDirection;
|
public ImageView callDirection;
|
||||||
public ImageView contactPicture;
|
public RelativeLayout avatarLayout;
|
||||||
public TextView generatedAvatar;
|
|
||||||
public RelativeLayout CallContact;
|
public RelativeLayout CallContact;
|
||||||
public LinearLayout separator;
|
public LinearLayout separator;
|
||||||
public TextView separatorText;
|
public TextView separatorText;
|
||||||
|
@ -68,8 +67,7 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
||||||
detail = view.findViewById(R.id.detail);
|
detail = view.findViewById(R.id.detail);
|
||||||
select = view.findViewById(R.id.delete);
|
select = view.findViewById(R.id.delete);
|
||||||
callDirection = view.findViewById(R.id.icon);
|
callDirection = view.findViewById(R.id.icon);
|
||||||
contactPicture = view.findViewById(R.id.contact_picture);
|
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
|
||||||
CallContact = view.findViewById(R.id.history_click);
|
CallContact = view.findViewById(R.id.history_click);
|
||||||
separator = view.findViewById(R.id.separator);
|
separator = view.findViewById(R.id.separator);
|
||||||
separatorText = view.findViewById(R.id.separator_text);
|
separatorText = view.findViewById(R.id.separator_text);
|
||||||
|
@ -181,9 +179,9 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
ContactAvatar.displayAvatar(c, holder.contactPicture, holder.generatedAvatar);
|
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(displayName, holder.generatedAvatar);
|
ContactAvatar.displayAvatar(displayName, holder.avatarLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.detail.setVisibility(isEditionEnabled() ? View.INVISIBLE : View.VISIBLE);
|
holder.detail.setVisibility(isEditionEnabled() ? View.INVISIBLE : View.VISIBLE);
|
||||||
|
|
|
@ -43,8 +43,7 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
||||||
public RelativeLayout bubbleLayout;
|
public RelativeLayout bubbleLayout;
|
||||||
public LinearLayout separatorLayout;
|
public LinearLayout separatorLayout;
|
||||||
public LinearLayout background;
|
public LinearLayout background;
|
||||||
public ImageView contactPicture;
|
public RelativeLayout avatarLayout;
|
||||||
public ImageView contactPictureMask;
|
|
||||||
public TextView contactName;
|
public TextView contactName;
|
||||||
|
|
||||||
public ImageView messageStatus;
|
public ImageView messageStatus;
|
||||||
|
@ -67,40 +66,9 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
||||||
private ClickListener mListener;
|
private ClickListener mListener;
|
||||||
|
|
||||||
public ChatBubbleViewHolder(Context context, View view, ClickListener listener) {
|
public ChatBubbleViewHolder(Context context, View view, ClickListener listener) {
|
||||||
super(view);
|
this(view);
|
||||||
mContext = context;
|
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;
|
mListener = listener;
|
||||||
|
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +80,7 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
||||||
|
|
||||||
bubbleLayout = view.findViewById(R.id.bubble);
|
bubbleLayout = view.findViewById(R.id.bubble);
|
||||||
background = view.findViewById(R.id.background);
|
background = view.findViewById(R.id.background);
|
||||||
contactPicture = view.findViewById(R.id.contact_picture);
|
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||||
contactPictureMask = view.findViewById(R.id.mask);
|
|
||||||
contactName = view.findViewById(R.id.contact_header);
|
contactName = view.findViewById(R.id.contact_header);
|
||||||
|
|
||||||
messageStatus = view.findViewById(R.id.status);
|
messageStatus = view.findViewById(R.id.status);
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.linphone.core.Content;
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
import org.linphone.core.LimeState;
|
import org.linphone.core.LimeState;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
import org.linphone.ui.ContactAvatar;
|
||||||
import org.linphone.ui.SelectableAdapter;
|
import org.linphone.ui.SelectableAdapter;
|
||||||
import org.linphone.ui.SelectableHelper;
|
import org.linphone.ui.SelectableHelper;
|
||||||
|
|
||||||
|
@ -162,7 +163,6 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
holder.messageStatus.setVisibility(View.INVISIBLE);
|
holder.messageStatus.setVisibility(View.INVISIBLE);
|
||||||
holder.messageSendingInProgress.setVisibility(View.GONE);
|
holder.messageSendingInProgress.setVisibility(View.GONE);
|
||||||
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
holder.imdmLayout.setVisibility(View.INVISIBLE);
|
||||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
|
||||||
|
|
||||||
if (isEditionEnabled()) {
|
if (isEditionEnabled()) {
|
||||||
holder.delete.setOnCheckedChangeListener(null);
|
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.contactName, mContext, R.style.font3);
|
||||||
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font15);
|
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font15);
|
||||||
holder.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
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 {
|
} else {
|
||||||
for (LinphoneContact c : mParticipants) {
|
for (LinphoneContact c : mParticipants) {
|
||||||
if (c != null && c.hasAddress(remoteSender.asStringUriOnly())) {
|
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.contactName, mContext, R.style.font9);
|
||||||
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font8);
|
Compatibility.setTextAppearance(holder.fileTransferAction, mContext, R.style.font8);
|
||||||
holder.fileTransferAction.setBackgroundResource(R.drawable.resizable_assistant_button);
|
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) {
|
if (contact == null) {
|
||||||
|
@ -282,14 +282,10 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
} else {
|
} else {
|
||||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||||
}
|
}
|
||||||
|
ContactAvatar.displayAvatar(contact, holder.avatarLayout);
|
||||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
|
||||||
if (contact.hasPhoto()) {
|
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
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);
|
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.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
@ -51,8 +52,7 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
||||||
public TextView displayName;
|
public TextView displayName;
|
||||||
public TextView unreadMessages;
|
public TextView unreadMessages;
|
||||||
public CheckBox delete;
|
public CheckBox delete;
|
||||||
public ImageView contactPicture;
|
public RelativeLayout avatarLayout;
|
||||||
public TextView generatedAvatar;
|
|
||||||
public ImageView lastMessageFileTransfer;
|
public ImageView lastMessageFileTransfer;
|
||||||
public Context mContext;
|
public Context mContext;
|
||||||
public ChatRoom mRoom;
|
public ChatRoom mRoom;
|
||||||
|
@ -71,8 +71,7 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
||||||
displayName = itemView.findViewById(R.id.sipUri);
|
displayName = itemView.findViewById(R.id.sipUri);
|
||||||
unreadMessages = itemView.findViewById(R.id.unreadMessages);
|
unreadMessages = itemView.findViewById(R.id.unreadMessages);
|
||||||
delete = itemView.findViewById(R.id.delete_chatroom);
|
delete = itemView.findViewById(R.id.delete_chatroom);
|
||||||
contactPicture = itemView.findViewById(R.id.contact_picture);
|
avatarLayout = itemView.findViewById(R.id.avatar_layout);
|
||||||
generatedAvatar = itemView.findViewById(R.id.generated_avatar);
|
|
||||||
lastMessageFileTransfer = itemView.findViewById(R.id.lastMessageFileTransfer);
|
lastMessageFileTransfer = itemView.findViewById(R.id.lastMessageFileTransfer);
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
|
||||||
|
@ -159,17 +158,17 @@ public class ChatRoomViewHolder extends RecyclerView.ViewHolder implements View.
|
||||||
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||||
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
ContactAvatar.displayAvatar(contact, contactPicture, generatedAvatar);
|
ContactAvatar.displayAvatar(contact, avatarLayout);
|
||||||
} else {
|
} else {
|
||||||
String username = mRoom.getPeerAddress().getDisplayName();
|
String username = mRoom.getPeerAddress().getDisplayName();
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
username = mRoom.getPeerAddress().getUsername();
|
username = mRoom.getPeerAddress().getUsername();
|
||||||
}
|
}
|
||||||
ContactAvatar.displayAvatar(username, generatedAvatar);
|
ContactAvatar.displayAvatar(username, avatarLayout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
contactPicture.setImageBitmap(mDefaultGroupBitmap);
|
((ImageView)avatarLayout.findViewById(R.id.contact_picture)).setImageBitmap(mDefaultGroupBitmap);
|
||||||
generatedAvatar.setVisibility(View.GONE);
|
avatarLayout.findViewById(R.id.generated_avatar).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
|
@ -44,8 +45,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
public TextView name;
|
public TextView name;
|
||||||
public ImageView avatar;
|
public RelativeLayout avatarLayout;
|
||||||
public TextView generatedAvatar;
|
|
||||||
public ImageView delete;
|
public ImageView delete;
|
||||||
public LinearLayout isAdmin;
|
public LinearLayout isAdmin;
|
||||||
public LinearLayout isNotAdmin;
|
public LinearLayout isNotAdmin;
|
||||||
|
@ -53,8 +53,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
||||||
public ViewHolder(View view) {
|
public ViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
name = view.findViewById(R.id.name);
|
name = view.findViewById(R.id.name);
|
||||||
avatar = view.findViewById(R.id.contact_picture);
|
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
|
||||||
delete = view.findViewById(R.id.delete);
|
delete = view.findViewById(R.id.delete);
|
||||||
isAdmin = view.findViewById(R.id.isAdminLayout);
|
isAdmin = view.findViewById(R.id.isAdminLayout);
|
||||||
isNotAdmin = view.findViewById(R.id.isNotAdminLayout);
|
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());
|
(ca.getDisplayName() != null) ? ca.getDisplayName() : ca.getUsername());
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
ContactAvatar.displayAvatar(c, holder.avatar, holder.generatedAvatar);
|
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.generatedAvatar);
|
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.delete.setOnClickListener(new View.OnClickListener() {
|
holder.delete.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
|
@ -116,7 +116,6 @@ public class ImdnFragment extends Fragment {
|
||||||
mBubble.messageStatus.setVisibility(View.INVISIBLE);
|
mBubble.messageStatus.setVisibility(View.INVISIBLE);
|
||||||
mBubble.messageSendingInProgress.setVisibility(View.GONE);
|
mBubble.messageSendingInProgress.setVisibility(View.GONE);
|
||||||
mBubble.imdmLayout.setVisibility(View.INVISIBLE);
|
mBubble.imdmLayout.setVisibility(View.INVISIBLE);
|
||||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
|
||||||
|
|
||||||
mMessage = mRoom.findMessage(mMessageId);
|
mMessage = mRoom.findMessage(mMessageId);
|
||||||
mListener = new ChatMessageListenerStub() {
|
mListener = new ChatMessageListenerStub() {
|
||||||
|
@ -135,13 +134,13 @@ public class ImdnFragment extends Fragment {
|
||||||
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font3);
|
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font3);
|
||||||
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font15);
|
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font15);
|
||||||
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_confirm_delete_button);
|
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 {
|
} else {
|
||||||
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
|
mBubble.background.setBackgroundResource(R.drawable.resizable_chat_bubble_incoming);
|
||||||
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font9);
|
Compatibility.setTextAppearance(mBubble.contactName, getActivity(), R.style.font9);
|
||||||
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font8);
|
Compatibility.setTextAppearance(mBubble.fileTransferAction, getActivity(), R.style.font8);
|
||||||
mBubble.fileTransferAction.setBackgroundResource(R.drawable.resizable_assistant_button);
|
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;
|
return view;
|
||||||
|
@ -166,13 +165,10 @@ public class ImdnFragment extends Fragment {
|
||||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBubble.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
ContactAvatar.displayAvatar(contact, mBubble.avatarLayout);
|
||||||
if (contact.hasPhoto()) {
|
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(getActivity(), mBubble.contactPicture, contact.getThumbnailUri());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
displayName = LinphoneUtils.getAddressDisplayName(remoteSender);
|
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);
|
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);
|
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
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);
|
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.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact != null) {
|
if (participantContact != null) {
|
||||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
mRead.addView(v);
|
mRead.addView(v);
|
||||||
|
@ -231,15 +225,13 @@ public class ImdnFragment extends Fragment {
|
||||||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
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);
|
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.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact != null) {
|
if (participantContact != null) {
|
||||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
mDelivered.addView(v);
|
mDelivered.addView(v);
|
||||||
|
@ -256,15 +248,13 @@ public class ImdnFragment extends Fragment {
|
||||||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
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);
|
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.time)).setText(LinphoneUtils.timestampToHumanDate(getActivity(), participant.getStateChangeTime(), R.string.messages_date_format));
|
||||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact != null) {
|
if (participantContact != null) {
|
||||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
mSent.addView(v);
|
mSent.addView(v);
|
||||||
|
@ -281,14 +271,12 @@ public class ImdnFragment extends Fragment {
|
||||||
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
String participantDisplayName = participantContact != null ? participantContact.getFullName() : LinphoneUtils.getAddressDisplayName(address);
|
||||||
|
|
||||||
View v = mInflater.inflate(R.layout.chat_imdn_cell, mContainer, false);
|
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);
|
v.findViewById(R.id.separator).setVisibility(first ? View.GONE : View.VISIBLE);
|
||||||
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
((TextView) v.findViewById(R.id.name)).setText(participantDisplayName);
|
||||||
if (participantContact != null) {
|
if (participantContact != null) {
|
||||||
ContactAvatar.displayAvatar(participantContact, contactPicture, generatedAvatar);
|
ContactAvatar.displayAvatar(participantContact, v.findViewById(R.id.avatar_layout));
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(participantDisplayName, generatedAvatar);
|
ContactAvatar.displayAvatar(participantDisplayName, v.findViewById(R.id.avatar_layout));
|
||||||
}
|
}
|
||||||
|
|
||||||
mUndelivered.addView(v);
|
mUndelivered.addView(v);
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -52,8 +53,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
public TextView name;
|
public TextView name;
|
||||||
public LinearLayout separator;
|
public LinearLayout separator;
|
||||||
public TextView separatorText;
|
public TextView separatorText;
|
||||||
public ImageView contactPicture;
|
public RelativeLayout avatarLayout;
|
||||||
public TextView generatedAvatar;
|
|
||||||
public TextView organization;
|
public TextView organization;
|
||||||
//public ImageView friendStatus;
|
//public ImageView friendStatus;
|
||||||
private ClickListener mListener;
|
private ClickListener mListener;
|
||||||
|
@ -66,8 +66,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
name = view.findViewById(R.id.name);
|
name = view.findViewById(R.id.name);
|
||||||
separator = view.findViewById(R.id.separator);
|
separator = view.findViewById(R.id.separator);
|
||||||
separatorText = view.findViewById(R.id.separator_text);
|
separatorText = view.findViewById(R.id.separator_text);
|
||||||
contactPicture = view.findViewById(R.id.contact_picture);
|
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
|
||||||
organization = view.findViewById(R.id.contactOrganization);
|
organization = view.findViewById(R.id.contactOrganization);
|
||||||
//friendStatus = view.findViewById(R.id.friendStatus);
|
//friendStatus = view.findViewById(R.id.friendStatus);
|
||||||
mListener = listener;
|
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.separator.setVisibility(mIsSearchMode || (!mIsSearchMode && getPositionForSection(getSectionForPosition(position)) != position) ? View.GONE : View.VISIBLE);
|
||||||
holder.linphoneFriend.setVisibility(contact.isInFriendList() ? View.VISIBLE : View.GONE);
|
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);
|
boolean isOrgVisible = mContext.getResources().getBoolean(R.bool.display_contact_organization);
|
||||||
String org = contact.getOrganization();
|
String org = contact.getOrganization();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
@ -53,8 +54,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
public TextView address;
|
public TextView address;
|
||||||
public ImageView linphoneContact;
|
public ImageView linphoneContact;
|
||||||
public ImageView isSelect;
|
public ImageView isSelect;
|
||||||
public ImageView avatar;
|
public RelativeLayout avatarLayout;
|
||||||
public TextView generatedAvatar;
|
|
||||||
|
|
||||||
private ClickListener mListener;
|
private ClickListener mListener;
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
address = view.findViewById(R.id.contact_address);
|
address = view.findViewById(R.id.contact_address);
|
||||||
linphoneContact = view.findViewById(R.id.contact_linphone);
|
linphoneContact = view.findViewById(R.id.contact_linphone);
|
||||||
isSelect = view.findViewById(R.id.contact_is_select);
|
isSelect = view.findViewById(R.id.contact_is_select);
|
||||||
avatar = view.findViewById(R.id.contact_picture);
|
avatarLayout = view.findViewById(R.id.avatar_layout);
|
||||||
generatedAvatar = view.findViewById(R.id.generated_avatar);
|
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
@ -146,9 +145,9 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
ContactAvatar.displayAvatar(c, holder.avatar, holder.generatedAvatar);
|
ContactAvatar.displayAvatar(c, holder.avatarLayout);
|
||||||
} else {
|
} else {
|
||||||
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.generatedAvatar);
|
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.address.setText(a);
|
holder.address.setText(a);
|
||||||
|
|
|
@ -27,11 +27,25 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
|
import org.linphone.R;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
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 {
|
public class ContactAvatar {
|
||||||
|
|
||||||
private static String generateAvatar(String displayName) {
|
private static String generateAvatar(String displayName) {
|
||||||
|
@ -43,14 +57,31 @@ public class ContactAvatar {
|
||||||
return generatedAvatarText.toUpperCase();
|
return generatedAvatarText.toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setAvatarMask(View v, int resourceId) {
|
||||||
public static void displayAvatar(String displayName, TextView generatedAvatarView) {
|
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||||
generatedAvatarView.setText(generateAvatar(displayName));
|
holder.avatarMask.setImageResource(resourceId);
|
||||||
generatedAvatarView.setVisibility(View.VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
Bitmap bm = null;
|
||||||
|
ContactAvatarHolder holder = new ContactAvatarHolder(v);
|
||||||
|
|
||||||
if (contact.getThumbnailUri() != null && contact.getThumbnailUri().getScheme().startsWith("http")) {
|
if (contact.getThumbnailUri() != null && contact.getThumbnailUri().getScheme().startsWith("http")) {
|
||||||
bm = LinphoneUtils.downloadBitmap(contact.getThumbnailUri());
|
bm = LinphoneUtils.downloadBitmap(contact.getThumbnailUri());
|
||||||
|
@ -65,12 +96,32 @@ public class ContactAvatar {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bm != null) {
|
if (bm != null) {
|
||||||
contactPictureView.setImageBitmap(bm);
|
holder.contactPicture.setImageBitmap(bm);
|
||||||
contactPictureView.setVisibility(View.VISIBLE);
|
holder.contactPicture.setVisibility(View.VISIBLE);
|
||||||
generatedAvatarView.setVisibility(View.GONE);
|
holder.generatedAvatar.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
generatedAvatarView.setText(generateAvatar(contact.getFullName()));
|
holder.generatedAvatar.setText(generateAvatar(contact.getFullName()));
|
||||||
generatedAvatarView.setVisibility(View.VISIBLE);
|
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