Do not display admin button when adding a new user to an existing group chat
This commit is contained in:
parent
f3aa072cc9
commit
7f7f602d44
2 changed files with 21 additions and 0 deletions
|
@ -32,6 +32,8 @@ import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
import org.linphone.contacts.ContactAddress;
|
import org.linphone.contacts.ContactAddress;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
|
import org.linphone.core.ChatRoom;
|
||||||
|
import org.linphone.core.Participant;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -41,6 +43,7 @@ public class GroupInfoAdapter extends BaseAdapter {
|
||||||
private List<ContactAddress> mItems;
|
private List<ContactAddress> mItems;
|
||||||
private View.OnClickListener mDeleteListener;
|
private View.OnClickListener mDeleteListener;
|
||||||
private boolean mHideAdminFeatures;
|
private boolean mHideAdminFeatures;
|
||||||
|
private ChatRoom mChatRoom;
|
||||||
|
|
||||||
public GroupInfoAdapter(LayoutInflater inflater, List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) {
|
public GroupInfoAdapter(LayoutInflater inflater, List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) {
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
|
@ -48,6 +51,10 @@ public class GroupInfoAdapter extends BaseAdapter {
|
||||||
mHideAdminFeatures = hideAdminFeatures || isCreation;
|
mHideAdminFeatures = hideAdminFeatures || isCreation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChatRoom(ChatRoom room) {
|
||||||
|
mChatRoom = room;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mItems.size();
|
return mItems.size();
|
||||||
|
@ -119,6 +126,17 @@ public class GroupInfoAdapter extends BaseAdapter {
|
||||||
delete.setVisibility(View.INVISIBLE);
|
delete.setVisibility(View.INVISIBLE);
|
||||||
isAdmin.setOnClickListener(null); // Do not allow not admin to remove it's rights but display admins
|
isAdmin.setOnClickListener(null); // Do not allow not admin to remove it's rights but display admins
|
||||||
isNotAdmin.setVisibility(View.GONE); // Hide not admin button for not admin participants
|
isNotAdmin.setVisibility(View.GONE); // Hide not admin button for not admin participants
|
||||||
|
} else if (mChatRoom != null) {
|
||||||
|
boolean found = false;
|
||||||
|
for (Participant p : mChatRoom.getParticipants()) {
|
||||||
|
if (p.getAddress().asStringUriOnly().equals(ca.getAddress().asStringUriOnly())) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
isNotAdmin.setVisibility(View.GONE); // Hide not admin button for participant not yet added so even if user click it it won't have any effect
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
|
|
@ -112,6 +112,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mParticipantsList.setAdapter(mAdapter);
|
mParticipantsList.setAdapter(mAdapter);
|
||||||
|
mAdapter.setChatRoom(mChatRoom);
|
||||||
|
|
||||||
mBackButton = view.findViewById(R.id.back);
|
mBackButton = view.findViewById(R.id.back);
|
||||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -302,10 +303,12 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapter.updateDataSet(mParticipants);
|
mAdapter.updateDataSet(mParticipants);
|
||||||
|
mAdapter.setChatRoom(mChatRoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshAdminRights() {
|
private void refreshAdminRights() {
|
||||||
mAdapter.setAdminFeaturesVisible(mIsEditionEnabled);
|
mAdapter.setAdminFeaturesVisible(mIsEditionEnabled);
|
||||||
|
mAdapter.setChatRoom(mChatRoom);
|
||||||
mSubjectField.setEnabled(mIsEditionEnabled);
|
mSubjectField.setEnabled(mIsEditionEnabled);
|
||||||
mConfirmButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.INVISIBLE);
|
mConfirmButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.INVISIBLE);
|
||||||
mAddParticipantsButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.GONE);
|
mAddParticipantsButton.setVisibility(mIsEditionEnabled ? View.VISIBLE : View.GONE);
|
||||||
|
|
Loading…
Reference in a new issue