Fixed group chat room creation issues

This commit is contained in:
Sylvain Berfini 2019-11-20 17:31:26 +01:00
parent a2e1240641
commit 28caf7a5b0
4 changed files with 22 additions and 14 deletions

View file

@ -143,8 +143,8 @@ public class ChatRoomCreationFragment extends Fragment
if (mChatRoomAddress == null && mChatRoomSubject == null) { if (mChatRoomAddress == null && mChatRoomSubject == null) {
mContactsSelectedLayout.removeAllViews(); mContactsSelectedLayout.removeAllViews();
} else { } else {
// Pop the back stack twice so we don't have in stack Group -> Creation // Pop the back stack twice so we don't have in stack
// -> Group // Group -> Creation -> Group
getFragmentManager().popBackStack(); getFragmentManager().popBackStack();
getFragmentManager().popBackStack(); getFragmentManager().popBackStack();
} }

View file

@ -476,7 +476,9 @@ public class GroupInfoFragment extends Fragment {
} }
Address[] participantsToAdd = new Address[toAdd.size()]; Address[] participantsToAdd = new Address[toAdd.size()];
toAdd.toArray(participantsToAdd); toAdd.toArray(participantsToAdd);
mChatRoom.addParticipants(participantsToAdd); if (!mChatRoom.addParticipants(participantsToAdd)) {
// TODO error
}
// Pop back stack to go back to the Messages fragment // Pop back stack to go back to the Messages fragment
getFragmentManager().popBackStack(); getFragmentManager().popBackStack();
} }

View file

@ -54,7 +54,9 @@ public class SearchContactViewHolder extends RecyclerView.ViewHolder
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (mListener != null) { if (mListener != null) {
mListener.onItemClicked(getAdapterPosition()); if (disabled.getVisibility() == View.GONE) {
mListener.onItemClicked(getAdapterPosition());
}
} }
} }

View file

@ -32,6 +32,7 @@ import org.linphone.LinphoneManager;
import org.linphone.R; import org.linphone.R;
import org.linphone.contacts.views.ContactAvatar; import org.linphone.contacts.views.ContactAvatar;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.Core;
import org.linphone.core.FriendCapability; import org.linphone.core.FriendCapability;
import org.linphone.core.PresenceBasicStatus; import org.linphone.core.PresenceBasicStatus;
import org.linphone.core.PresenceModel; import org.linphone.core.PresenceModel;
@ -118,8 +119,20 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
holder.name.setText(searchResult.getAddress().getDisplayName()); holder.name.setText(searchResult.getAddress().getDisplayName());
} }
} }
holder.disabled.setVisibility(View.GONE); holder.disabled.setVisibility(View.GONE);
if (mSecurityEnabled || !mIsOnlyOnePersonSelection) {
Core core = LinphoneManager.getCore();
ProxyConfig defaultProxyConfig = core.getDefaultProxyConfig();
if (defaultProxyConfig != null) {
// SDK won't accept ourselves in the list of participants
if (defaultProxyConfig.getIdentityAddress().weakEqual(searchResult.getAddress())) {
// Disable row, we can't use our own address in a group chat room
holder.disabled.setVisibility(View.VISIBLE);
}
}
}
if (contact != null) { if (contact != null) {
if (contact.getFullName() == null if (contact.getFullName() == null
&& contact.getFirstName() == null && contact.getFirstName() == null
@ -137,15 +150,6 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
&& !searchResult.hasCapability(FriendCapability.LimeX3Dh))) { && !searchResult.hasCapability(FriendCapability.LimeX3Dh))) {
// Disable row, contact doesn't have the required capabilities // Disable row, contact doesn't have the required capabilities
holder.disabled.setVisibility(View.VISIBLE); holder.disabled.setVisibility(View.VISIBLE);
} else if (mSecurityEnabled || !mIsOnlyOnePersonSelection) {
ProxyConfig lpc =
Objects.requireNonNull(LinphoneManager.getCore()).getDefaultProxyConfig();
if (lpc != null
&& searchResult.getAddress() != null
&& lpc.getIdentityAddress().weakEqual(searchResult.getAddress())) {
// Disable row, we can't use our own address in a group chat room
holder.disabled.setVisibility(View.VISIBLE);
}
} }
} else { } else {
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout); ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);