diff --git a/res/raw/linphone.db b/res/raw/linphone.db index 6fb3f9ab6..eed573f25 100644 Binary files a/res/raw/linphone.db and b/res/raw/linphone.db differ diff --git a/res/raw/linphonerc_factory b/res/raw/linphonerc_factory index fddb47a4a..ee636871d 100644 --- a/res/raw/linphonerc_factory +++ b/res/raw/linphonerc_factory @@ -34,7 +34,7 @@ dtmf_player_amp=0.1 ec_calibrator_cool_tones=1 [misc] -conference_factory_uri=sips:conference-factory@sip.linphone.org +conference_factory_uri=sip:conference-factory@conf.test.org max_calls=10 history_max_size=100 diff --git a/src/android/org/linphone/activities/LinphoneActivity.java b/src/android/org/linphone/activities/LinphoneActivity.java index 998459c11..461bc9916 100644 --- a/src/android/org/linphone/activities/LinphoneActivity.java +++ b/src/android/org/linphone/activities/LinphoneActivity.java @@ -123,12 +123,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.List; -import static org.linphone.activities.LinphoneActivity.ChatRoomContainer.createChatroomContainer; public class LinphoneActivity extends LinphoneGenericActivity implements OnClickListener, ContactPicked, ActivityCompat.OnRequestPermissionsResultCallback { public static final String PREF_FIRST_LAUNCH = "pref_first_launch"; @@ -909,62 +906,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick return statusFragment; } - static class ChatRoomContainer{ - private ChatRoom mCr; - long mTime; - static public ChatRoomContainer createChatroomContainer(ChatRoom chatRoom) { - if (chatRoom.getHistorySize() <= 0) return null; - return new ChatRoomContainer(chatRoom); - } - public ChatRoomContainer(ChatRoom chatroom){ - mCr = chatroom; - ChatMessage[] lastMsg = chatroom.getHistory(1); - if (lastMsg != null && lastMsg.length > 0 && lastMsg[0] != null) { - mTime = lastMsg[0].getTime(); - }else mTime = 0; - } - ChatRoom getChatRoom(){ - return mCr; - } - long getTime(){ - return mTime; - } - }; - public List getChatList() { - ArrayList chatList = new ArrayList(); - - ChatRoom[] chats = LinphoneManager.getLc().getChatRooms(); - List rooms = new ArrayList(); - - for (ChatRoom chatroom : chats) { - ChatRoomContainer crc = createChatroomContainer(chatroom); - if (crc != null) rooms.add(crc); - } - - if (rooms.size() > 1) { - Collections.sort(rooms, new Comparator() { - @Override - public int compare(ChatRoomContainer a, ChatRoomContainer b) { - long atime = a.getTime(); - long btime = b.getTime(); - - if (atime > btime) - return -1; - else if (btime > atime) - return 1; - else - return 0; - } - }); - } - - for (ChatRoomContainer chatroomContainer : rooms) { - chatList.add(chatroomContainer.getChatRoom().getPeerAddress().asStringUriOnly()); - } - - return chatList; - } - public void removeFromChatList(String sipUri) { ChatRoom chatroom = LinphoneManager.getLc().getChatRoomFromUri(sipUri); chatroom.deleteHistory(); diff --git a/src/android/org/linphone/chat/ChatListFragment.java b/src/android/org/linphone/chat/ChatListFragment.java index e2d2f63e1..a5d8a4267 100644 --- a/src/android/org/linphone/chat/ChatListFragment.java +++ b/src/android/org/linphone/chat/ChatListFragment.java @@ -58,6 +58,7 @@ import org.linphone.core.Core; import org.linphone.core.Factory; import org.linphone.core.CoreListenerStub; +import java.util.ArrayList; import java.util.List; import static org.linphone.fragments.FragmentsAvailable.CHAT_LIST; @@ -189,8 +190,16 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte } } + private void refreshConversations() { + mConversations = new ArrayList<>(); + ChatRoom[] chats = LinphoneManager.getLc().getChatRooms(); + for (ChatRoom room : chats) { + mConversations.add(room.getPeerAddress().asStringUriOnly()); + } + } + public void refresh() { - mConversations = LinphoneActivity.instance().getChatList(); + refreshConversations(); hideAndDisplayMessageIfNoChat(); } @@ -262,7 +271,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte String sipUri = chatList.getAdapter().getItem(info.position).toString(); LinphoneActivity.instance().removeFromChatList(sipUri); - mConversations = LinphoneActivity.instance().getChatList(); + refreshConversations(); if (getResources().getBoolean(R.bool.isTablet)) { quitEditMode(); } @@ -421,19 +430,21 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte ChatRoom chatRoom = LinphoneManager.getLc().getChatRoom(address); int unreadMessagesCount = chatRoom.getUnreadMessagesCount(); ChatMessage[] history = chatRoom.getHistory(1); - ChatMessage msg = history[0]; - if (msg.getFileTransferInformation() != null || msg.getExternalBodyUrl() != null || msg.getAppdata() != null) { - holder.lastMessageView.setBackgroundResource(R.drawable.chat_file_message); - time = msg.getTime(); - holder.date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format))); - holder.lastMessageView.setText(""); - } else if (msg.getText() != null && msg.getText().length() > 0 ){ - message = msg.getText(); - holder.lastMessageView.setBackgroundResource(0); - time = msg.getTime(); - holder.date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format))); - holder.lastMessageView.setText(message); + if (history.length > 0) { + ChatMessage msg = history[0]; + if (msg.getFileTransferInformation() != null || msg.getExternalBodyUrl() != null || msg.getAppdata() != null) { + holder.lastMessageView.setBackgroundResource(R.drawable.chat_file_message); + time = msg.getTime(); + holder.date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format))); + holder.lastMessageView.setText(""); + } else if (msg.getText() != null && msg.getText().length() > 0 ){ + message = msg.getText(); + holder.lastMessageView.setBackgroundResource(0); + time = msg.getTime(); + holder.date.setText(LinphoneUtils.timestampToHumanDate(getActivity(),time,getString(R.string.messages_list_date_format))); + holder.lastMessageView.setText(message); + } } holder.displayName.setSelected(true); // For animation diff --git a/submodules/belle-sip b/submodules/belle-sip index c390646fe..c09442f18 160000 --- a/submodules/belle-sip +++ b/submodules/belle-sip @@ -1 +1 @@ -Subproject commit c390646fe81934550781ec7470c0dcf440b03e58 +Subproject commit c09442f1808a0fa9e040b48485a1fa7c4c9fd5a3 diff --git a/submodules/linphone b/submodules/linphone index 2f97587d5..c30a7b48f 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 2f97587d53020be683a98a4b6404f76f9a8e24a5 +Subproject commit c30a7b48f5f212609546650efd24340943bd1542