Keep participants list when navigating between ChatCreation and GroupInfo
This commit is contained in:
parent
7225998156
commit
cb4051c9ff
4 changed files with 43 additions and 16 deletions
|
@ -721,6 +721,12 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
}
|
||||
|
||||
public void goToChatCreator(ArrayList<ContactAddress> selectedContacts) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putSerializable("selectedContacts", selectedContacts);
|
||||
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
|
||||
}
|
||||
|
||||
public void goToChat(String sipUri) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
|
|
|
@ -66,7 +66,12 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mInflater = inflater;
|
||||
View view = inflater.inflate(R.layout.chat_create, container, false);
|
||||
|
||||
if (getArguments() != null && getArguments().getSerializable("selectedContacts") != null) {
|
||||
contactsSelected = (ArrayList<ContactAddress>) getArguments().getSerializable("selectedContacts");
|
||||
} else {
|
||||
contactsSelected = new ArrayList<>();
|
||||
}
|
||||
|
||||
contactsList = view.findViewById(R.id.contactsList);
|
||||
contactsSelectedLayout = view.findViewById(R.id.contactsSelected);
|
||||
|
@ -186,6 +191,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
|
||||
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
||||
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
||||
|
||||
if (contactsSelected.size() > 0) {
|
||||
searchAdapter.setContactsSelectedList(contactsSelected);
|
||||
for (ContactAddress ca : contactsSelected) {
|
||||
addSelectedContactAddress(ca);
|
||||
}
|
||||
contactsSelectLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
|
@ -212,14 +225,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
return -1;
|
||||
}
|
||||
|
||||
private void updateContactsClick(ContactAddress ca, List<ContactAddress> caSelectedList) {
|
||||
ca.setSelect((getIndexOfCa(ca, caSelectedList) == -1));
|
||||
if (ca.isSelect()) {
|
||||
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
|
||||
csv.setListener(this);
|
||||
csv.setContactName(ca);
|
||||
contactsSelected.add(ca);
|
||||
|
||||
private void addSelectedContactAddress(ContactAddress ca) {
|
||||
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
||||
if (ca.getContact() != null) {
|
||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
|
||||
|
@ -232,6 +238,18 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
viewContact.setOnClickListener(this);
|
||||
ca.setView(viewContact);
|
||||
contactsSelectedLayout.addView(viewContact);
|
||||
contactsSelectedLayout.invalidate();
|
||||
}
|
||||
|
||||
private void updateContactsClick(ContactAddress ca, List<ContactAddress> caSelectedList) {
|
||||
ca.setSelect((getIndexOfCa(ca, caSelectedList) == -1));
|
||||
if (ca.isSelect()) {
|
||||
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
|
||||
csv.setListener(this);
|
||||
csv.setContactName(ca);
|
||||
contactsSelected.add(ca);
|
||||
addSelectedContactAddress(ca);
|
||||
|
||||
} else {
|
||||
contactsSelected.remove(getIndexOfCa(ca, contactsSelected));
|
||||
contactsSelectedLayout.removeAllViews();
|
||||
|
@ -283,11 +301,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
allContactsSelected.setVisibility(View.INVISIBLE);
|
||||
updateList();
|
||||
} else if (id == R.id.back) {
|
||||
contactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().popBackStack();
|
||||
} else if (id == R.id.next) {
|
||||
if (contactsSelected.size() == 1) {
|
||||
contactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
|
||||
} else {
|
||||
contactsSelectedLayout.removeAllViews();
|
||||
LinphoneActivity.instance().displayChatGroupInfos(contactsSelected, null, false, true);
|
||||
}
|
||||
} else if (id == R.id.clearSearchField) {
|
||||
|
|
|
@ -331,7 +331,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
enabledDeleteButton(false);
|
||||
}
|
||||
else if (id == R.id.new_discussion) {
|
||||
LinphoneActivity.instance().displayChat(null, null, null);
|
||||
LinphoneActivity.instance().goToChatCreator(null);
|
||||
/*String sipUri = fastNewChat.getText().toString();
|
||||
if (sipUri.equals("")) {
|
||||
LinphoneActivity.instance().displayContacts(true);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class GroupInfoFragment extends Fragment {
|
|||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LinphoneActivity.instance().popBackStack();
|
||||
LinphoneActivity.instance().goToChatCreator(mParticipants);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class GroupInfoFragment extends Fragment {
|
|||
if (mIsAlreadyCreatedGroup) {
|
||||
//TODO
|
||||
} else {
|
||||
LinphoneActivity.instance().popBackStack();
|
||||
LinphoneActivity.instance().goToChatCreator(mParticipants);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue