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) {
|
public void goToChat(String sipUri) {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("SipUri", sipUri);
|
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) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
View view = inflater.inflate(R.layout.chat_create, container, false);
|
View view = inflater.inflate(R.layout.chat_create, container, false);
|
||||||
contactsSelected = new ArrayList<>();
|
|
||||||
|
if (getArguments() != null && getArguments().getSerializable("selectedContacts") != null) {
|
||||||
|
contactsSelected = (ArrayList<ContactAddress>) getArguments().getSerializable("selectedContacts");
|
||||||
|
} else {
|
||||||
|
contactsSelected = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
contactsList = view.findViewById(R.id.contactsList);
|
contactsList = view.findViewById(R.id.contactsList);
|
||||||
contactsSelectedLayout = view.findViewById(R.id.contactsSelected);
|
contactsSelectedLayout = view.findViewById(R.id.contactsSelected);
|
||||||
|
@ -186,6 +191,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
|
|
||||||
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
||||||
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
||||||
|
|
||||||
|
if (contactsSelected.size() > 0) {
|
||||||
|
searchAdapter.setContactsSelectedList(contactsSelected);
|
||||||
|
for (ContactAddress ca : contactsSelected) {
|
||||||
|
addSelectedContactAddress(ca);
|
||||||
|
}
|
||||||
|
contactsSelectLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateList() {
|
private void updateList() {
|
||||||
|
@ -212,6 +225,22 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
} else {
|
||||||
|
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddress());
|
||||||
|
}
|
||||||
|
View removeContact = viewContact.findViewById(R.id.contactChatDelete);
|
||||||
|
removeContact.setTag(ca);
|
||||||
|
removeContact.setOnClickListener(this);
|
||||||
|
viewContact.setOnClickListener(this);
|
||||||
|
ca.setView(viewContact);
|
||||||
|
contactsSelectedLayout.addView(viewContact);
|
||||||
|
contactsSelectedLayout.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
private void updateContactsClick(ContactAddress ca, List<ContactAddress> caSelectedList) {
|
private void updateContactsClick(ContactAddress ca, List<ContactAddress> caSelectedList) {
|
||||||
ca.setSelect((getIndexOfCa(ca, caSelectedList) == -1));
|
ca.setSelect((getIndexOfCa(ca, caSelectedList) == -1));
|
||||||
if (ca.isSelect()) {
|
if (ca.isSelect()) {
|
||||||
|
@ -219,19 +248,8 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
csv.setListener(this);
|
csv.setListener(this);
|
||||||
csv.setContactName(ca);
|
csv.setContactName(ca);
|
||||||
contactsSelected.add(ca);
|
contactsSelected.add(ca);
|
||||||
|
addSelectedContactAddress(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());
|
|
||||||
} else {
|
|
||||||
((TextView) viewContact.findViewById(R.id.sipUri)).setText(ca.getAddress());
|
|
||||||
}
|
|
||||||
View removeContact = viewContact.findViewById(R.id.contactChatDelete);
|
|
||||||
removeContact.setTag(ca);
|
|
||||||
removeContact.setOnClickListener(this);
|
|
||||||
viewContact.setOnClickListener(this);
|
|
||||||
ca.setView(viewContact);
|
|
||||||
contactsSelectedLayout.addView(viewContact);
|
|
||||||
} else {
|
} else {
|
||||||
contactsSelected.remove(getIndexOfCa(ca, contactsSelected));
|
contactsSelected.remove(getIndexOfCa(ca, contactsSelected));
|
||||||
contactsSelectedLayout.removeAllViews();
|
contactsSelectedLayout.removeAllViews();
|
||||||
|
@ -283,11 +301,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
allContactsSelected.setVisibility(View.INVISIBLE);
|
allContactsSelected.setVisibility(View.INVISIBLE);
|
||||||
updateList();
|
updateList();
|
||||||
} else if (id == R.id.back) {
|
} else if (id == R.id.back) {
|
||||||
|
contactsSelectedLayout.removeAllViews();
|
||||||
LinphoneActivity.instance().popBackStack();
|
LinphoneActivity.instance().popBackStack();
|
||||||
} else if (id == R.id.next) {
|
} else if (id == R.id.next) {
|
||||||
if (contactsSelected.size() == 1) {
|
if (contactsSelected.size() == 1) {
|
||||||
|
contactsSelectedLayout.removeAllViews();
|
||||||
LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
|
LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
|
||||||
} else {
|
} else {
|
||||||
|
contactsSelectedLayout.removeAllViews();
|
||||||
LinphoneActivity.instance().displayChatGroupInfos(contactsSelected, null, false, true);
|
LinphoneActivity.instance().displayChatGroupInfos(contactsSelected, null, false, true);
|
||||||
}
|
}
|
||||||
} else if (id == R.id.clearSearchField) {
|
} else if (id == R.id.clearSearchField) {
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
enabledDeleteButton(false);
|
enabledDeleteButton(false);
|
||||||
}
|
}
|
||||||
else if (id == R.id.new_discussion) {
|
else if (id == R.id.new_discussion) {
|
||||||
LinphoneActivity.instance().displayChat(null, null, null);
|
LinphoneActivity.instance().goToChatCreator(null);
|
||||||
/*String sipUri = fastNewChat.getText().toString();
|
/*String sipUri = fastNewChat.getText().toString();
|
||||||
if (sipUri.equals("")) {
|
if (sipUri.equals("")) {
|
||||||
LinphoneActivity.instance().displayContacts(true);
|
LinphoneActivity.instance().displayContacts(true);
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class GroupInfoFragment extends Fragment {
|
||||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
LinphoneActivity.instance().popBackStack();
|
LinphoneActivity.instance().goToChatCreator(mParticipants);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class GroupInfoFragment extends Fragment {
|
||||||
if (mIsAlreadyCreatedGroup) {
|
if (mIsAlreadyCreatedGroup) {
|
||||||
//TODO
|
//TODO
|
||||||
} else {
|
} else {
|
||||||
LinphoneActivity.instance().popBackStack();
|
LinphoneActivity.instance().goToChatCreator(mParticipants);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue