Fixed issues with new chat room API + hide empty one to one chat rooms
This commit is contained in:
parent
15cf3663ae
commit
ce35ff3f40
6 changed files with 38 additions and 6 deletions
|
@ -51,6 +51,7 @@ import org.linphone.contacts.SearchContactViewHolder;
|
|||
import org.linphone.contacts.SearchContactsAdapter;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomBackend;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.ChatRoomParams;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -567,8 +568,9 @@ public class ChatRoomCreationFragment extends Fragment
|
|||
mShareInfos);
|
||||
} else {
|
||||
ChatRoomParams params = lc.createDefaultChatRoomParams();
|
||||
// This will set the backend to FlexisipChat automatically
|
||||
params.enableEncryption(true);
|
||||
params.enableGroup(true);
|
||||
params.enableGroup(false);
|
||||
|
||||
Address participants[] = new Address[1];
|
||||
participants[0] = address;
|
||||
|
@ -595,7 +597,9 @@ public class ChatRoomCreationFragment extends Fragment
|
|||
|
||||
ChatRoomParams params = lc.createDefaultChatRoomParams();
|
||||
params.enableEncryption(false);
|
||||
params.enableGroup(true);
|
||||
params.enableGroup(false);
|
||||
// We don't want a basic chat room
|
||||
params.setBackend(ChatRoomBackend.FlexisipChat);
|
||||
|
||||
Address participants[] = new Address[1];
|
||||
participants[0] = address;
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.utils.SelectableAdapter;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
|
||||
|
@ -71,7 +72,9 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomViewHolder> {
|
|||
}
|
||||
|
||||
public void refresh() {
|
||||
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
||||
mRooms =
|
||||
LinphoneUtils.removeEmptyOneToOneChatRooms(
|
||||
new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms())));
|
||||
Collections.sort(
|
||||
mRooms,
|
||||
new Comparator<ChatRoom>() {
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.linphone.core.EventLog;
|
|||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
|
||||
public class ChatRoomsFragment extends Fragment
|
||||
|
@ -76,7 +77,9 @@ public class ChatRoomsFragment extends Fragment
|
|||
final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
||||
mRooms =
|
||||
LinphoneUtils.removeEmptyOneToOneChatRooms(
|
||||
new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms())));
|
||||
|
||||
mContext = getActivity().getApplicationContext();
|
||||
View view = inflater.inflate(R.layout.chatlist, container, false);
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.linphone.LinphoneManager;
|
|||
import org.linphone.R;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomBackend;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.ChatRoomParams;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -109,7 +110,10 @@ public class ContactDetailsFragment extends Fragment
|
|||
|
||||
ChatRoomParams params = lc.createDefaultChatRoomParams();
|
||||
params.enableEncryption(isSecured);
|
||||
params.enableGroup(true);
|
||||
params.enableGroup(false);
|
||||
// We don't want a basic chat room,
|
||||
// so if isSecured is false we have to set this manually
|
||||
params.setBackend(ChatRoomBackend.FlexisipChat);
|
||||
|
||||
Address participants[] = new Address[1];
|
||||
participants[0] = participant;
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.linphone.contacts.ContactsManager;
|
|||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomBackend;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.ChatRoomParams;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -232,7 +233,9 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
|
||||
ChatRoomParams params = lc.createDefaultChatRoomParams();
|
||||
params.enableEncryption(false);
|
||||
params.enableGroup(true);
|
||||
params.enableGroup(false);
|
||||
// We don't want a basic chat room
|
||||
params.setBackend(ChatRoomBackend.FlexisipChat);
|
||||
|
||||
Address participants[] = new Address[1];
|
||||
participants[0] = participant;
|
||||
|
|
|
@ -49,6 +49,8 @@ import org.linphone.core.AccountCreator;
|
|||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Call.State;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomCapabilities;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.LogCollectionState;
|
||||
|
@ -486,4 +488,17 @@ public final class LinphoneUtils {
|
|||
sContext = LinphoneManager.getInstance().getContext();
|
||||
return sContext;
|
||||
}
|
||||
|
||||
public static ArrayList<ChatRoom> removeEmptyOneToOneChatRooms(ArrayList<ChatRoom> rooms) {
|
||||
ArrayList<ChatRoom> newRooms = new ArrayList<>();
|
||||
for (ChatRoom room : rooms) {
|
||||
if (room.hasCapability(ChatRoomCapabilities.OneToOne.toInt())
|
||||
&& room.getLastMessageInHistory() == null) {
|
||||
// Hide 1-1 chat rooms without messages
|
||||
} else {
|
||||
newRooms.add(room);
|
||||
}
|
||||
}
|
||||
return newRooms;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue