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) {
mContactsSelectedLayout.removeAllViews();
} else {
// Pop the back stack twice so we don't have in stack Group -> Creation
// -> Group
// Pop the back stack twice so we don't have in stack
// Group -> Creation -> Group
getFragmentManager().popBackStack();
getFragmentManager().popBackStack();
}

View file

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

View file

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

View file

@ -32,6 +32,7 @@ import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.contacts.views.ContactAvatar;
import org.linphone.core.Address;
import org.linphone.core.Core;
import org.linphone.core.FriendCapability;
import org.linphone.core.PresenceBasicStatus;
import org.linphone.core.PresenceModel;
@ -118,8 +119,20 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
holder.name.setText(searchResult.getAddress().getDisplayName());
}
}
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.getFullName() == null
&& contact.getFirstName() == null
@ -137,15 +150,6 @@ public class SearchContactsAdapter extends RecyclerView.Adapter<SearchContactVie
&& !searchResult.hasCapability(FriendCapability.LimeX3Dh))) {
// Disable row, contact doesn't have the required capabilities
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 {
ContactAvatar.displayAvatar(holder.name.getText().toString(), holder.avatarLayout);