Started group chat room features like subject change and leave
This commit is contained in:
parent
b3382daf26
commit
7f5c586489
4 changed files with 57 additions and 12 deletions
|
@ -730,9 +730,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
public void goToChatGroupInfos(ArrayList<ContactAddress> contacts, String subject, boolean isAlreadyCreatedGroup, boolean isEditionEnabled) {
|
||||
public void goToChatGroupInfos(String address, ArrayList<ContactAddress> contacts, String subject, boolean isEditionEnabled) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean("isAlreadyCreatedGroup", isAlreadyCreatedGroup);
|
||||
extras.putString("groupChatRoomAddress", address);
|
||||
extras.putBoolean("isEditionEnabled", isEditionEnabled);
|
||||
extras.putSerializable("ContactAddress", contacts);
|
||||
extras.putString("subject", subject);
|
||||
|
|
|
@ -310,7 +310,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
chatRoom.addParticipants(addresses);
|
||||
} else {
|
||||
contactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().goToChatGroupInfos(contactsSelected, null, false, true);
|
||||
LinphoneActivity.instance().goToChatGroupInfos(null, contactsSelected, null, true);
|
||||
}
|
||||
} else if (id == R.id.clearSearchField) {
|
||||
searchField.setText("");
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.Participant;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.receivers.ContactsUpdatedListener;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -84,6 +85,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
private ListView mChatEventsList;
|
||||
private LinearLayout mFilesUploadLayout;
|
||||
private LinearLayout mTopBar, mEditTopBar;
|
||||
private boolean mIsReadOnly;
|
||||
|
||||
private ViewTreeObserver.OnGlobalLayoutListener mKeyboardListener;
|
||||
private Uri mImageToUploadUri;
|
||||
|
@ -151,7 +153,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
ContactAddress ca = new ContactAddress(c, a.asString(), c.isFriend());
|
||||
participants.add(ca);
|
||||
}
|
||||
LinphoneActivity.instance().goToChatGroupInfos(participants, mChatRoom.getSubject(), true, mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false);
|
||||
LinphoneActivity.instance().goToChatGroupInfos(mRemoteSipAddress.asString(), participants, mChatRoom.getSubject(), mChatRoom.getMe() != null ? mChatRoom.getMe().isAdmin() : false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -408,6 +410,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
* View initialization
|
||||
*/
|
||||
|
||||
private void setReadOnly() {
|
||||
mMessageTextToSend.setEnabled(false);
|
||||
mAttachImageButton.setEnabled(false);
|
||||
mSendMessageButton.setEnabled(false);
|
||||
}
|
||||
|
||||
private void getContactsForParticipants() {
|
||||
mParticipants = new ArrayList<>();
|
||||
if (!mChatRoom.canHandleParticipants() || (mChatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(mChatRoom.getSubject()))) {
|
||||
|
@ -455,6 +463,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
mRemoteParticipantAddress = mChatRoom.getParticipants()[0].getAddress();
|
||||
}
|
||||
|
||||
mIsReadOnly = mChatRoom.getState() == ChatRoom.State.Terminated;
|
||||
|
||||
getContactsForParticipants();
|
||||
}
|
||||
|
||||
|
@ -485,9 +495,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
mGroupInfosButton.setVisibility(View.VISIBLE);
|
||||
mRoomLabel.setText(mChatRoom.getSubject());
|
||||
mParticipantsLabel.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (mIsReadOnly) {
|
||||
setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayChatRoomHistory() {
|
||||
|
@ -807,7 +820,10 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
|
||||
mIsReadOnly = mChatRoom.getState() == ChatRoom.State.Terminated;
|
||||
if (mIsReadOnly) {
|
||||
setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.ArrayList;
|
|||
|
||||
public class GroupInfoFragment extends Fragment {
|
||||
private ImageView mBackButton, mConfirmButton, mAddParticipantsButton;
|
||||
private Address mGroupChatRoomAddress;
|
||||
private EditText mSubjectField;
|
||||
private LayoutInflater mInflater;
|
||||
private ListView mParticipantsList;
|
||||
|
@ -55,6 +56,8 @@ public class GroupInfoFragment extends Fragment {
|
|||
private boolean mIsAlreadyCreatedGroup;
|
||||
private boolean mIsEditionEnabled;
|
||||
private ArrayList<ContactAddress> mParticipants;
|
||||
private String mSubject;
|
||||
private ChatRoom mChatRoom;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -65,9 +68,26 @@ public class GroupInfoFragment extends Fragment {
|
|||
return null;
|
||||
}
|
||||
mParticipants = (ArrayList<ContactAddress>) getArguments().getSerializable("ContactAddress");
|
||||
mIsAlreadyCreatedGroup = getArguments().getBoolean("isAlreadyCreatedGroup");
|
||||
|
||||
mGroupChatRoomAddress = null;
|
||||
mChatRoom = null;
|
||||
|
||||
String address = getArguments().getString("groupChatRoomAddress");
|
||||
if (address != null && address.length() > 0) {
|
||||
mGroupChatRoomAddress = LinphoneManager.getLc().createAddress(address);
|
||||
}
|
||||
mIsAlreadyCreatedGroup = mGroupChatRoomAddress != null;
|
||||
if (mIsAlreadyCreatedGroup) {
|
||||
mChatRoom = LinphoneManager.getLc().getChatRoom(mGroupChatRoomAddress);
|
||||
}
|
||||
if (mChatRoom == null) mIsAlreadyCreatedGroup = false;
|
||||
|
||||
mIsEditionEnabled = getArguments().getBoolean("isEditionEnabled");
|
||||
String subject = getArguments().getString("subject");
|
||||
mSubject = getArguments().getString("subject");
|
||||
|
||||
if (mChatRoom != null && mChatRoom.getState() == ChatRoom.State.Terminated) {
|
||||
mIsEditionEnabled = false;
|
||||
}
|
||||
|
||||
mParticipantsList = view.findViewById(R.id.chat_room_participants);
|
||||
mAdapter = new GroupInfoAdapter(mInflater, mParticipants, !mIsEditionEnabled, !mIsAlreadyCreatedGroup);
|
||||
|
@ -101,10 +121,15 @@ public class GroupInfoFragment extends Fragment {
|
|||
mLeaveGroupButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//TODO
|
||||
if (mChatRoom != null) {
|
||||
mChatRoom.leave();
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString());
|
||||
} else {
|
||||
Log.e("Can't leave, chatRoom for address " + mGroupChatRoomAddress.asString() + " is null...");
|
||||
}
|
||||
}
|
||||
});
|
||||
mLeaveGroupButton.setVisibility(mIsAlreadyCreatedGroup ? View.VISIBLE : View.GONE);
|
||||
mLeaveGroupButton.setVisibility(mIsAlreadyCreatedGroup && mChatRoom.getState() != ChatRoom.State.Terminated ? View.VISIBLE : View.GONE);
|
||||
|
||||
mAddParticipantsButton = view.findViewById(R.id.addParticipants);
|
||||
mAddParticipantsButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -131,7 +156,7 @@ public class GroupInfoFragment extends Fragment {
|
|||
mConfirmButton.setEnabled(mSubjectField.getText().length() > 0 && mParticipants.size() > 1);
|
||||
}
|
||||
});
|
||||
mSubjectField.setText(subject);
|
||||
mSubjectField.setText(mSubject);
|
||||
|
||||
mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -161,7 +186,11 @@ public class GroupInfoFragment extends Fragment {
|
|||
}
|
||||
chatRoom.addParticipants(addresses);
|
||||
} else {
|
||||
//TODO
|
||||
String newSubject = mSubjectField.getText().toString();
|
||||
if (!newSubject.equals(mSubject)) {
|
||||
mChatRoom.setSubject(newSubject);
|
||||
}
|
||||
LinphoneActivity.instance().goToChat(mGroupChatRoomAddress.asString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue