From 5910a468e401d41fd46ea8d13f2bebed8967d746 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 15 Feb 2018 11:19:26 +0100 Subject: [PATCH] Display last message sender in chat rooms list --- res/layout-land/chatlist_cell.xml | 30 +++++++++++----- res/layout-sw533dp-land/chatlist_cell.xml | 32 ++++++++++++----- res/layout-sw533dp/chatlist_cell.xml | 32 ++++++++++++----- res/layout/chatlist_cell.xml | 34 +++++++++++++------ res/values-fr/strings.xml | 1 + .../org/linphone/chat/ChatRoomsAdapter.java | 11 ++++++ 6 files changed, 104 insertions(+), 36 deletions(-) diff --git a/res/layout-land/chatlist_cell.xml b/res/layout-land/chatlist_cell.xml index 5f837ef92..adc15edd6 100644 --- a/res/layout-land/chatlist_cell.xml +++ b/res/layout-land/chatlist_cell.xml @@ -97,14 +97,28 @@ android:layout_alignParentEnd="true" android:layout_alignParentTop="true"/> - + + + + + + + diff --git a/res/layout-sw533dp-land/chatlist_cell.xml b/res/layout-sw533dp-land/chatlist_cell.xml index 9260677f0..e09c71406 100644 --- a/res/layout-sw533dp-land/chatlist_cell.xml +++ b/res/layout-sw533dp-land/chatlist_cell.xml @@ -93,15 +93,29 @@ android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> - + + + + + + + diff --git a/res/layout-sw533dp/chatlist_cell.xml b/res/layout-sw533dp/chatlist_cell.xml index 2b11dd93b..4750c1a27 100644 --- a/res/layout-sw533dp/chatlist_cell.xml +++ b/res/layout-sw533dp/chatlist_cell.xml @@ -94,15 +94,29 @@ android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> - + + + + + + + diff --git a/res/layout/chatlist_cell.xml b/res/layout/chatlist_cell.xml index 7b7926abf..6989dc64e 100644 --- a/res/layout/chatlist_cell.xml +++ b/res/layout/chatlist_cell.xml @@ -90,19 +90,33 @@ style="@style/font18" android:gravity="center" android:maxLines="1" - android:layout_above="@+id/lastMessage" + android:layout_above="@+id/lastMessageLayout" android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> - + + + + + + + diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 139485461..9c4ffb7d2 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -176,6 +176,7 @@ Vos amis pourront vous joindre plus facilement si vous associez votre compte à Traitement de l\'image, cela peut prendre quelques secondes selon sa taille Lu Reçu + Envoyé Renvoyer Enregistré diff --git a/src/android/org/linphone/chat/ChatRoomsAdapter.java b/src/android/org/linphone/chat/ChatRoomsAdapter.java index 90088932d..1a5baee4f 100644 --- a/src/android/org/linphone/chat/ChatRoomsAdapter.java +++ b/src/android/org/linphone/chat/ChatRoomsAdapter.java @@ -52,6 +52,7 @@ import java.util.List; public class ChatRoomsAdapter extends ListSelectionAdapter { private class ChatRoomViewHolder { + public TextView lastMessageSenderView; public TextView lastMessageView; public TextView date; public TextView displayName; @@ -60,6 +61,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter { public ImageView contactPicture; public ChatRoomViewHolder(View view) { + lastMessageSenderView = view.findViewById(R.id.lastMessageSender); lastMessageView = view.findViewById(R.id.lastMessage); date = view.findViewById(R.id.date); displayName = view.findViewById(R.id.sipUri); @@ -141,6 +143,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter { int unreadMessagesCount = chatRoom.getUnreadMessagesCount(); ChatMessage lastMessage = chatRoom.getLastMessageInHistory(); holder.lastMessageView.setText(""); + holder.lastMessageSenderView.setText(""); holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, chatRoom.getLastUpdateTime(), R.string.messages_list_date_format)); if (lastMessage != null) { @@ -150,6 +153,14 @@ public class ChatRoomsAdapter extends ListSelectionAdapter { holder.lastMessageView.setBackgroundResource(0); holder.lastMessageView.setText(lastMessage.getTextContent()); } + + Address lastMessageSenderAddress = lastMessage.getFromAddress(); + LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lastMessageSenderAddress); + if (contact != null) { + holder.lastMessageSenderView.setText(contact.getFullName() + ": "); + } else { + holder.lastMessageSenderView.setText(LinphoneUtils.getAddressDisplayName(lastMessageSenderAddress) + ": "); + } } holder.displayName.setSelected(true); // For animation