Improved code related to hiding empty one to one chat rooms
This commit is contained in:
parent
3c61e0e418
commit
0132c224c7
4 changed files with 18 additions and 10 deletions
|
@ -23,12 +23,12 @@ import android.content.Context;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.utils.SelectableAdapter;
|
||||
|
@ -72,9 +72,13 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomViewHolder> {
|
|||
}
|
||||
|
||||
public void refresh() {
|
||||
mRooms =
|
||||
LinphoneUtils.removeEmptyOneToOneChatRooms(
|
||||
new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms())));
|
||||
ChatRoom[] rooms = LinphoneManager.getLc().getChatRooms();
|
||||
if (mContext.getResources().getBoolean(R.bool.hide_empty_one_to_one_chat_rooms)) {
|
||||
mRooms = LinphoneUtils.removeEmptyOneToOneChatRooms(rooms);
|
||||
} else {
|
||||
mRooms = Arrays.asList(rooms);
|
||||
}
|
||||
|
||||
Collections.sort(
|
||||
mRooms,
|
||||
new Comparator<ChatRoom>() {
|
||||
|
@ -85,6 +89,7 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomViewHolder> {
|
|||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.linphone.LinphoneActivity;
|
||||
|
@ -75,11 +74,7 @@ public class ChatRoomsFragment extends Fragment
|
|||
@Override
|
||||
public View onCreateView(
|
||||
final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
mRooms =
|
||||
LinphoneUtils.removeEmptyOneToOneChatRooms(
|
||||
new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms())));
|
||||
|
||||
mContext = getActivity().getApplicationContext();
|
||||
View view = inflater.inflate(R.layout.chatlist, container, false);
|
||||
|
@ -91,6 +86,13 @@ public class ChatRoomsFragment extends Fragment
|
|||
mBackToCallButton = view.findViewById(R.id.back_in_call);
|
||||
mNoChatHistory = view.findViewById(R.id.noChatHistory);
|
||||
|
||||
ChatRoom[] rooms = LinphoneManager.getLc().getChatRooms();
|
||||
if (mContext.getResources().getBoolean(R.bool.hide_empty_one_to_one_chat_rooms)) {
|
||||
mRooms = LinphoneUtils.removeEmptyOneToOneChatRooms(rooms);
|
||||
} else {
|
||||
mRooms = Arrays.asList(rooms);
|
||||
}
|
||||
|
||||
mSelectionHelper = new SelectableHelper(view, this);
|
||||
mChatRoomsAdapter =
|
||||
new ChatRoomsAdapter(
|
||||
|
|
|
@ -489,7 +489,7 @@ public final class LinphoneUtils {
|
|||
return sContext;
|
||||
}
|
||||
|
||||
public static ArrayList<ChatRoom> removeEmptyOneToOneChatRooms(ArrayList<ChatRoom> rooms) {
|
||||
public static ArrayList<ChatRoom> removeEmptyOneToOneChatRooms(ChatRoom[] rooms) {
|
||||
ArrayList<ChatRoom> newRooms = new ArrayList<>();
|
||||
for (ChatRoom room : rooms) {
|
||||
if (room.hasCapability(ChatRoomCapabilities.OneToOne.toInt())
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
<bool name="use_new_chat_bubbles_layout">true</bool>
|
||||
<bool name="use_big_pictures_to_preview_images_file_transfers">true</bool>
|
||||
<bool name="show_sip_uri_in_chat">false</bool>
|
||||
<bool name="hide_empty_one_to_one_chat_rooms">true</bool>
|
||||
|
||||
<!-- Contacts -->
|
||||
<bool name="hide_contact_phone_numbers">false</bool>
|
||||
|
|
Loading…
Reference in a new issue