Hidden room unread count if 0 + fixed group chat icon + some cleanup

This commit is contained in:
Sylvain Berfini 2018-09-03 12:03:47 +02:00
parent 884f4d66c6
commit f020b2e2c4
10 changed files with 121 additions and 125 deletions

View file

@ -68,75 +68,75 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
public ChatBubbleViewHolder(Context context, View view, ClickListener listener) { public ChatBubbleViewHolder(Context context, View view, ClickListener listener) {
super(view); super(view);
this.mContext = context; mContext = context;
this.eventLayout = view.findViewById(R.id.event); eventLayout = view.findViewById(R.id.event);
//eventTime = view.findViewById(R.id.event_date); //eventTime = view.findViewById(R.id.event_date);
this.eventMessage = view.findViewById(R.id.event_text); eventMessage = view.findViewById(R.id.event_text);
this.bubbleLayout = view.findViewById(R.id.bubble); bubbleLayout = view.findViewById(R.id.bubble);
this.background = view.findViewById(R.id.background); background = view.findViewById(R.id.background);
this.contactPicture = view.findViewById(R.id.contact_picture); contactPicture = view.findViewById(R.id.contact_picture);
this.contactPictureMask = view.findViewById(R.id.mask); contactPictureMask = view.findViewById(R.id.mask);
this.contactName = view.findViewById(R.id.contact_header); contactName = view.findViewById(R.id.contact_header);
this.messageStatus = view.findViewById(R.id.status); messageStatus = view.findViewById(R.id.status);
this.messageSendingInProgress = view.findViewById(R.id.inprogress); messageSendingInProgress = view.findViewById(R.id.inprogress);
this.imdmLayout = view.findViewById(R.id.imdmLayout); imdmLayout = view.findViewById(R.id.imdmLayout);
this.imdmIcon = view.findViewById(R.id.imdmIcon); imdmIcon = view.findViewById(R.id.imdmIcon);
this.imdmLabel = view.findViewById(R.id.imdmText); imdmLabel = view.findViewById(R.id.imdmText);
this.messageText = view.findViewById(R.id.message); messageText = view.findViewById(R.id.message);
this.messageImage = view.findViewById(R.id.image); messageImage = view.findViewById(R.id.image);
this.separatorLayout = view.findViewById(R.id.separator); separatorLayout = view.findViewById(R.id.separator);
this.fileTransferLayout = view.findViewById(R.id.file_transfer_layout); fileTransferLayout = view.findViewById(R.id.file_transfer_layout);
this.fileTransferProgressBar = view.findViewById(R.id.progress_bar); fileTransferProgressBar = view.findViewById(R.id.progress_bar);
this.fileTransferAction = view.findViewById(R.id.file_transfer_action); fileTransferAction = view.findViewById(R.id.file_transfer_action);
this.fileName = view.findViewById(R.id.file_name); fileName = view.findViewById(R.id.file_name);
this.openFileButton = view.findViewById(R.id.open_file); openFileButton = view.findViewById(R.id.open_file);
this.delete = view.findViewById(R.id.delete_message); delete = view.findViewById(R.id.delete_message);
this.listener = listener; listener = listener;
view.setOnClickListener(this); view.setOnClickListener(this);
} }
public ChatBubbleViewHolder(View view) { public ChatBubbleViewHolder(View view) {
super(view); super(view);
this.eventLayout = view.findViewById(R.id.event); eventLayout = view.findViewById(R.id.event);
//eventTime = view.findViewById(R.id.event_date); //eventTime = view.findViewById(R.id.event_date);
this.eventMessage = view.findViewById(R.id.event_text); eventMessage = view.findViewById(R.id.event_text);
this.bubbleLayout = view.findViewById(R.id.bubble); bubbleLayout = view.findViewById(R.id.bubble);
this.background = view.findViewById(R.id.background); background = view.findViewById(R.id.background);
this.contactPicture = view.findViewById(R.id.contact_picture); contactPicture = view.findViewById(R.id.contact_picture);
this.contactPictureMask = view.findViewById(R.id.mask); contactPictureMask = view.findViewById(R.id.mask);
this.contactName = view.findViewById(R.id.contact_header); contactName = view.findViewById(R.id.contact_header);
this.messageStatus = view.findViewById(R.id.status); messageStatus = view.findViewById(R.id.status);
this.messageSendingInProgress = view.findViewById(R.id.inprogress); messageSendingInProgress = view.findViewById(R.id.inprogress);
this.imdmLayout = view.findViewById(R.id.imdmLayout); imdmLayout = view.findViewById(R.id.imdmLayout);
this.imdmIcon = view.findViewById(R.id.imdmIcon); imdmIcon = view.findViewById(R.id.imdmIcon);
this.imdmLabel = view.findViewById(R.id.imdmText); imdmLabel = view.findViewById(R.id.imdmText);
this.messageText = view.findViewById(R.id.message); messageText = view.findViewById(R.id.message);
this.messageImage = view.findViewById(R.id.image); messageImage = view.findViewById(R.id.image);
this.separatorLayout = view.findViewById(R.id.separator); separatorLayout = view.findViewById(R.id.separator);
this.fileTransferLayout = view.findViewById(R.id.file_transfer_layout); fileTransferLayout = view.findViewById(R.id.file_transfer_layout);
this.fileTransferProgressBar = view.findViewById(R.id.progress_bar); fileTransferProgressBar = view.findViewById(R.id.progress_bar);
this.fileTransferAction = view.findViewById(R.id.file_transfer_action); fileTransferAction = view.findViewById(R.id.file_transfer_action);
this.fileName = view.findViewById(R.id.file_name); fileName = view.findViewById(R.id.file_name);
this.openFileButton = view.findViewById(R.id.open_file); openFileButton = view.findViewById(R.id.open_file);
this.delete = view.findViewById(R.id.delete_message); delete = view.findViewById(R.id.delete_message);
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if(listener!=null) { if (listener != null) {
listener.onItemClicked(getAdapterPosition()); listener.onItemClicked(getAdapterPosition());
} }
} }

View file

@ -130,8 +130,8 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
@Override @Override
public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()) View v = LayoutInflater.from(parent.getContext())
.inflate(this.mItemResource, parent, false); .inflate(mItemResource, parent, false);
ChatBubbleViewHolder VH = new ChatBubbleViewHolder(this.mContext,v, mClickListener); ChatBubbleViewHolder VH = new ChatBubbleViewHolder(mContext,v, mClickListener);
//Allows onLongClick ContextMenu on bubbles //Allows onLongClick ContextMenu on bubbles
mFragment.registerForContextMenu(v); mFragment.registerForContextMenu(v);
@ -141,7 +141,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
@Override @Override
public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) { public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) {
final EventLog event = this.mHistory.get(position); final EventLog event = mHistory.get(position);
holder.eventLayout.setVisibility(View.GONE); holder.eventLayout.setVisibility(View.GONE);
holder.bubbleLayout.setVisibility(View.GONE); holder.bubbleLayout.setVisibility(View.GONE);
holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE); holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.GONE);
@ -402,7 +402,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
@Override @Override
public int getItemCount() { public int getItemCount() {
return this.mHistory.size(); return mHistory.size();
} }
public void addToHistory(EventLog log) { public void addToHistory(EventLog log) {
@ -430,7 +430,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
} }
public int getCount() { public int getCount() {
return this.mHistory.size(); return mHistory.size();
} }
public Object getItem(int i) { public Object getItem(int i) {

View file

@ -71,7 +71,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms())); mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
this.mContext = getActivity().getApplicationContext(); mContext = getActivity().getApplicationContext();
View view = inflater.inflate(R.layout.chatlist, container, false); View view = inflater.inflate(R.layout.chatlist, container, false);
mChatRoomsList = view.findViewById(R.id.chatList); mChatRoomsList = view.findViewById(R.id.chatList);

View file

@ -21,6 +21,7 @@ package org.linphone.chat;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -38,7 +39,6 @@ import org.linphone.contacts.LinphoneContact;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.ChatRoom; import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomCapabilities; import org.linphone.core.ChatRoomCapabilities;
import org.linphone.core.ChatRoomListenerStub;
import org.linphone.ui.SelectableAdapter; import org.linphone.ui.SelectableAdapter;
import org.linphone.ui.SelectableHelper; import org.linphone.ui.SelectableHelper;
@ -60,43 +60,43 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
public ImageView contactPicture; public ImageView contactPicture;
public Context mContext; public Context mContext;
public ChatRoom mRoom; public ChatRoom mRoom;
public ClickListener listener; private ClickListener mListener;
public ChatRoomViewHolder(Context context,View itemView, ClickListener listener) { public ChatRoomViewHolder(Context context,View itemView, ClickListener listener) {
super(itemView); super(itemView);
this.mContext= context; mContext = context;
this.lastMessageSenderView = itemView.findViewById(R.id.lastMessageSender); lastMessageSenderView = itemView.findViewById(R.id.lastMessageSender);
this.lastMessageView = itemView.findViewById(R.id.lastMessage); lastMessageView = itemView.findViewById(R.id.lastMessage);
this.date = itemView.findViewById(R.id.date); date = itemView.findViewById(R.id.date);
this.displayName = itemView.findViewById(R.id.sipUri); displayName = itemView.findViewById(R.id.sipUri);
this.unreadMessages = itemView.findViewById(R.id.unreadMessages); unreadMessages = itemView.findViewById(R.id.unreadMessages);
this.delete = itemView.findViewById(R.id.delete_chatroom); delete = itemView.findViewById(R.id.delete_chatroom);
this.contactPicture = itemView.findViewById(R.id.contact_picture); contactPicture = itemView.findViewById(R.id.contact_picture);
this.listener = listener; mListener = listener;
itemView.setOnClickListener(this); itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this); itemView.setOnLongClickListener(this);
} }
public void bindChatRoom(ChatRoom room) { public void bindChatRoom(ChatRoom room) {
this.mRoom = room; mRoom = room;
this.lastMessageSenderView.setText(getSender(mRoom)); lastMessageSenderView.setText(getSender(mRoom));
this.lastMessageView.setText(mRoom.getLastMessageInHistory() != null ? mRoom.getLastMessageInHistory().getTextContent(): ""); lastMessageView.setText(mRoom.getLastMessageInHistory() != null ? mRoom.getLastMessageInHistory().getTextContent(): "");
this.date.setText(mRoom.getLastMessageInHistory()!=null ? LinphoneUtils.timestampToHumanDate(this.mContext, mRoom.getLastUpdateTime(), R.string.messages_list_date_format) : ""); date.setText(mRoom.getLastMessageInHistory() != null ? LinphoneUtils.timestampToHumanDate(mContext, mRoom.getLastUpdateTime(), R.string.messages_list_date_format) : "");
this.displayName.setText(getContact(mRoom)); displayName.setText(getContact(mRoom));
this.unreadMessages.setText(String.valueOf(LinphoneManager.getInstance().getUnreadCountForChatRoom(mRoom))); unreadMessages.setText(String.valueOf(LinphoneManager.getInstance().getUnreadCountForChatRoom(mRoom)));
getAvatar(mRoom); getAvatar(mRoom);
} }
public void onClick(View v) { public void onClick(View v) {
if (listener != null) { if (mListener != null) {
listener.onItemClicked(getAdapterPosition()); mListener.onItemClicked(getAdapterPosition());
} }
} }
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
if (listener != null) { if (mListener != null) {
return listener.onItemLongClicked(getAdapterPosition()); return mListener.onItemLongClicked(getAdapterPosition());
} }
return false; return false;
} }
@ -107,7 +107,7 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
if (contact != null) { if (contact != null) {
return (contact.getFullName() + mContext.getString(R.string.separator)); return (contact.getFullName() + mContext.getString(R.string.separator));
} }
return (LinphoneUtils.getAddressDisplayName(mRoom.getLastMessageInHistory().getFromAddress()) + ":"); return (LinphoneUtils.getAddressDisplayName(mRoom.getLastMessageInHistory().getFromAddress()) + mContext.getString(R.string.separator));
} }
return null; return null;
} }
@ -138,12 +138,14 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
} }
public void getAvatar(ChatRoom mRoom) { public void getAvatar(ChatRoom mRoom) {
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress()); LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress());
if (contact != null) { if (contact != null) {
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), this.contactPicture, ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress()).getThumbnailUri()); LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), contactPicture, ContactsManager.getInstance().findContactFromAddress(mRoom.getPeerAddress()).getThumbnailUri());
} else { } else {
this.contactPicture.setImageBitmap(mDefaultBitmap); if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()))
contactPicture.setImageBitmap(mDefaultBitmap);
else
contactPicture.setImageBitmap(mDefaultGroupBitmap);
} }
} }
@ -156,34 +158,33 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
private Context mContext; private Context mContext;
public List<ChatRoom> mRooms; public List<ChatRoom> mRooms;
private static Bitmap mDefaultBitmap; private static Bitmap mDefaultBitmap;
//private Bitmap mDefaultGroupBitmap; private static Bitmap mDefaultGroupBitmap;
private ChatRoomListenerStub mListener; private int mItemResource;
private int itemResource; private ChatRoomViewHolder.ClickListener mClickListener;
private ChatRoomViewHolder.ClickListener clickListener;
public ChatRoomsAdapter(Context context, int itemResource, List<ChatRoom> mRooms, ChatRoomViewHolder.ClickListener clickListener, SelectableHelper helper) { public ChatRoomsAdapter(Context context, int itemResource, List<ChatRoom> rooms, ChatRoomViewHolder.ClickListener clickListener, SelectableHelper helper) {
super(helper); super(helper);
this.clickListener = clickListener; mClickListener = clickListener;
this.mRooms = mRooms; mRooms = rooms;
this.mContext = context; mContext = context;
this.itemResource = itemResource; mItemResource = itemResource;
mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap(); mDefaultBitmap = ContactsManager.getInstance().getDefaultAvatarBitmap();
//mDefaultGroupBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chat_group_avatar); mDefaultGroupBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.chat_group_avatar);
} }
@Override @Override
public ChatRoomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public ChatRoomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()) View view = LayoutInflater.from(parent.getContext())
.inflate(this.itemResource, parent, false); .inflate(mItemResource, parent, false);
return new ChatRoomViewHolder(this.mContext, view, clickListener); return new ChatRoomViewHolder(mContext, view, mClickListener);
} }
@Override @Override
public void onBindViewHolder(ChatRoomViewHolder holder, int position) { public void onBindViewHolder(ChatRoomViewHolder holder, int position) {
ChatRoom room = this.mRooms.get(position); ChatRoom room = mRooms.get(position);
holder.delete.setVisibility(this.isEditionEnabled() == true ? View.VISIBLE : View.INVISIBLE); holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.INVISIBLE);
holder.unreadMessages.setVisibility(this.isEditionEnabled() == false ? View.VISIBLE : View.INVISIBLE); holder.unreadMessages.setVisibility(isEditionEnabled() ? View.INVISIBLE : (room.getUnreadMessagesCount() > 0 ? View.VISIBLE : View.INVISIBLE));
holder.delete.setChecked(isSelected(position) ? true : false); holder.delete.setChecked(isSelected(position));
holder.bindChatRoom(room); holder.bindChatRoom(room);
} }
@ -201,9 +202,6 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
} }
public void clear() { public void clear() {
for (ChatRoom room : mRooms) {
room.removeListener(mListener);
}
mRooms.clear(); mRooms.clear();
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -214,7 +212,7 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
@Override @Override
public int getItemCount() { public int getItemCount() {
return this.mRooms.size(); return mRooms.size();
} }
@Override @Override

View file

@ -117,7 +117,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri); mRemoteSipAddress = LinphoneManager.getLc().createAddress(mRemoteSipUri);
} }
this.mContext = getActivity().getApplicationContext(); mContext = getActivity().getApplicationContext();
View view = inflater.inflate(R.layout.chat, container, false); View view = inflater.inflate(R.layout.chat, container, false);
@ -224,7 +224,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
addImageToPendingList(fileSharedUri); addImageToPendingList(fileSharedUri);
} else { } else {
if (fileSharedUri.startsWith("content://") || fileSharedUri.startsWith("file://")) { if (fileSharedUri.startsWith("content://") || fileSharedUri.startsWith("file://")) {
fileSharedUri = LinphoneUtils.getFilePath(this.getActivity().getApplicationContext(), Uri.parse(fileSharedUri)); fileSharedUri = LinphoneUtils.getFilePath(getActivity().getApplicationContext(), Uri.parse(fileSharedUri));
} else if (fileSharedUri.contains("com.android.contacts/contacts/")) { } else if (fileSharedUri.contains("com.android.contacts/contacts/")) {
fileSharedUri = LinphoneUtils.getCVSPathFromLookupUri(fileSharedUri).toString(); fileSharedUri = LinphoneUtils.getCVSPathFromLookupUri(fileSharedUri).toString();
} }
@ -309,7 +309,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
addImageToPendingList(fileToUploadPath); addImageToPendingList(fileToUploadPath);
} else { } else {
if (fileToUploadPath.startsWith("content://") || fileToUploadPath.startsWith("file://")) { if (fileToUploadPath.startsWith("content://") || fileToUploadPath.startsWith("file://")) {
fileToUploadPath = LinphoneUtils.getFilePath(this.getActivity().getApplicationContext(), Uri.parse(fileToUploadPath)); fileToUploadPath = LinphoneUtils.getFilePath(getActivity().getApplicationContext(), Uri.parse(fileToUploadPath));
} else if (fileToUploadPath.contains("com.android.contacts/contacts/")) { } else if (fileToUploadPath.contains("com.android.contacts/contacts/")) {
fileToUploadPath = LinphoneUtils.getCVSPathFromLookupUri(fileToUploadPath).toString(); fileToUploadPath = LinphoneUtils.getCVSPathFromLookupUri(fileToUploadPath).toString();
} }

View file

@ -66,7 +66,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
private View.OnClickListener mDeleteListener; private View.OnClickListener mDeleteListener;
private boolean mHideAdminFeatures; private boolean mHideAdminFeatures;
private ChatRoom mChatRoom; private ChatRoom mChatRoom;
public ImageView avatar; private ImageView mAavatar;
public GroupInfoAdapter(List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) { public GroupInfoAdapter(List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) {
mItems = items; mItems = items;
@ -84,11 +84,11 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) { public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
final ContactAddress ca = (ContactAddress)getItem(position); final ContactAddress ca = (ContactAddress)getItem(position);
LinphoneContact c = ca.getContact(); LinphoneContact c = ca.getContact();
this.avatar=holder.avatar; mAavatar = holder.avatar;
holder.name.setText((c.getFullName() != null) ? c.getFullName() : holder.name.setText((c.getFullName() != null) ? c.getFullName() :
(ca.getDisplayName() != null) ? ca.getDisplayName() : ca.getUsername()); (ca.getDisplayName() != null) ? ca.getDisplayName() : ca.getUsername());
if (c.hasPhoto()) { if (c.hasPhoto()) {
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), avatar, c.getThumbnailUri()); LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), mAavatar, c.getThumbnailUri());
} }
holder.delete.setOnClickListener(new View.OnClickListener() { holder.delete.setOnClickListener(new View.OnClickListener() {

View file

@ -89,7 +89,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
if (getArguments() == null || getArguments().isEmpty()) { if (getArguments() == null || getArguments().isEmpty()) {
return null; return null;
} }
this.mContext = getActivity().getApplicationContext(); mContext = getActivity().getApplicationContext();
mParticipants = (ArrayList<ContactAddress>) getArguments().getSerializable("ContactAddress"); mParticipants = (ArrayList<ContactAddress>) getArguments().getSerializable("ContactAddress");

View file

@ -118,10 +118,10 @@ public class ContactAddress implements Serializable {
} }
private void init(LinphoneContact c, String a, String pn, boolean isLC) { private void init(LinphoneContact c, String a, String pn, boolean isLC) {
this.contact = c; contact = c;
this.address = a; address = a;
this.phoneNumber = pn; phoneNumber = pn;
this.isLinphoneContact = isLC; isLinphoneContact = isLC;
} }
public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) { public ContactAddress(LinphoneContact c, String a, String pn, boolean isLC) {

View file

@ -55,7 +55,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
public ImageView contactPicture; public ImageView contactPicture;
public TextView organization; public TextView organization;
//public ImageView friendStatus; //public ImageView friendStatus;
private ClickListener listener; private ClickListener mListener;
private ViewHolder(View view, ClickListener listener) { private ViewHolder(View view, ClickListener listener) {
super(view); super(view);
@ -68,21 +68,21 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
contactPicture = (ImageView) view.findViewById(R.id.contact_picture); contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
organization = (TextView) view.findViewById(R.id.contactOrganization); organization = (TextView) view.findViewById(R.id.contactOrganization);
//friendStatus = (ImageView) view.findViewById(R.id.friendStatus); //friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
this.listener= listener; mListener = listener;
view.setOnClickListener(this); view.setOnClickListener(this);
view.setOnLongClickListener(this); view.setOnLongClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (listener != null) { if (mListener != null) {
listener.onItemClicked(getAdapterPosition()); mListener.onItemClicked(getAdapterPosition());
} }
} }
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
if (listener != null) { if (mListener != null) {
return listener.onItemLongClicked(getAdapterPosition()); return mListener.onItemLongClicked(getAdapterPosition());
} }
return false; return false;
} }
@ -145,7 +145,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
holder.organization.setVisibility(View.GONE); holder.organization.setVisibility(View.GONE);
} }
holder.delete.setVisibility(this.isEditionEnabled() ? View.VISIBLE : View.INVISIBLE); holder.delete.setVisibility(isEditionEnabled() ? View.VISIBLE : View.INVISIBLE);
holder.delete.setChecked(isSelected(position)); holder.delete.setChecked(isSelected(position));
} }

View file

@ -51,7 +51,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
public ImageView isSelect; public ImageView isSelect;
public ImageView avatar; public ImageView avatar;
private ClickListener listener; private ClickListener mListener;
public ViewHolder(View view, ClickListener listener) { public ViewHolder(View view, ClickListener listener) {
super(view); super(view);
@ -60,28 +60,27 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
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); avatar = view.findViewById(R.id.contact_picture);
this.listener=listener; mListener = listener;
view.setOnClickListener(this); view.setOnClickListener(this);
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (listener != null) { if (mListener != null) {
listener.onItemClicked(getAdapterPosition()); mListener.onItemClicked(getAdapterPosition());
} }
} }
public interface ClickListener { public interface ClickListener {
void onItemClicked(int position); void onItemClicked(int position);
} }
} }
private List<ContactAddress> contacts; private List<ContactAddress> contacts;
private List<ContactAddress> contactsSelected; private List<ContactAddress> contactsSelected;
private ProgressBar progressBar; private ProgressBar progressBar;
private boolean mOnlySipContact = false; private boolean mOnlySipContact = false;
private ViewHolder.ClickListener listener; private ViewHolder.ClickListener mListener;
public List<ContactAddress> getContacts() { public List<ContactAddress> getContacts() {
return contacts; return contacts;
@ -92,11 +91,11 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
} }
public void setListener(ViewHolder.ClickListener listener) { public void setListener(ViewHolder.ClickListener listener) {
this.listener = listener; mListener = listener;
} }
public SearchContactsListAdapter(List<ContactAddress> contactsList, ProgressBar pB, ViewHolder.ClickListener clickListener) { public SearchContactsListAdapter(List<ContactAddress> contactsList, ProgressBar pB, ViewHolder.ClickListener clickListener) {
this.listener=clickListener; mListener = clickListener;
progressBar = pB; progressBar = pB;
setContactsSelectedList(null); setContactsSelectedList(null);
setContactsList(contactsList); setContactsList(contactsList);
@ -106,8 +105,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
@Override @Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_contact_cell, parent, false); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_contact_cell, parent, false);
return new ViewHolder(v, listener); return new ViewHolder(v, mListener);
} }
@Override @Override
@ -285,7 +283,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
contacts = result; contacts = result;
resultContactsSearch.setAdapter(this); resultContactsSearch.setAdapter(this);
this.notifyDataSetChanged(); notifyDataSetChanged();
} }
} }