Fix check of last message content

This commit is contained in:
Erwan Croze 2018-08-09 15:56:54 +02:00
parent d674105dc1
commit dcdda672d8
2 changed files with 14 additions and 1 deletions

View file

@ -55,6 +55,7 @@ import org.linphone.core.Call;
import org.linphone.core.Call.State;
import org.linphone.core.ChatRoom;
import org.linphone.core.ChatRoomSecurityLevel;
import org.linphone.core.Content;
import org.linphone.core.Core;
import org.linphone.core.Factory;
import org.linphone.core.Friend;
@ -806,5 +807,15 @@ public final class LinphoneUtils {
return ChatRoomSecurityLevel.ClearText;
}
public static boolean hasContentFileSharing(Content[] contents) {
if (contents == null) return false;
for (int i = 0 ; i < contents.length ; i++) {
if (contents[i].isFileTransfer()) return true;
}
return false;
}
}

View file

@ -53,6 +53,7 @@ import java.util.Comparator;
import java.util.List;
import static android.text.format.DateUtils.isToday;
import static org.linphone.LinphoneUtils.hasContentFileSharing;
public class ChatRoomsAdapter extends ListSelectionAdapter {
@ -174,7 +175,8 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
holder.date.setText(LinphoneUtils.timestampToHumanDate(mContext, chatRoom.getLastUpdateTime(), ((LinphoneUtils.isToday(chatRoom.getLastUpdateTime())) ? R.string.today_date_format2 : R.string.messages_list_date_format), false));
if (lastMessage != null) {
if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || lastMessage.getContents().length > 0) {
boolean hasContent = hasContentFileSharing(lastMessage.getContents());
if (lastMessage.getFileTransferInformation() != null || lastMessage.getExternalBodyUrl() != null || hasContent) {
holder.lastMessageView.setBackgroundResource(R.drawable.chat_file_message);
} else if (lastMessage.getTextContent() != null && lastMessage.getTextContent().length() > 0) {
holder.lastMessageView.setBackgroundResource(0);