Added code to display group chat room with only 1 participant other than ourself with the dummy subject like an old simple chat room

This commit is contained in:
Sylvain Berfini 2017-11-03 12:52:19 +01:00
parent a90a8f9fef
commit e024554908
4 changed files with 34 additions and 32 deletions

View file

@ -3,6 +3,8 @@
<!-- Do not translate any of the strings below -->
<bool name="isTablet">false</bool>
<string name="dummy_group_chat_subject">dummy subject</string>
<item type="id" name="contact_search_name" />
<string name="pref_disable_account_key">pref_disable_account_key</string>
<string name="pref_extra_accounts">pref_nb_accounts_extra</string>

View file

@ -289,7 +289,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
//LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
//TODO create group chat room with only two participants ?
//TODO what subject to set ?
ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom("dummy subject");
ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom(getString(R.string.dummy_group_chat_subject));
chatRoom.setListener(new ChatRoomListenerStub() {
@Override
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {

View file

@ -434,10 +434,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
holder.displayName.setSelected(true); // For animation
if (chatRoom.canHandleParticipants()) {
holder.displayName.setText(chatRoom.getSubject());
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);
} else {
if (!chatRoom.canHandleParticipants() || (chatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(chatRoom.getSubject()))) {
if (contact != null) {
holder.displayName.setText(contact.getFullName());
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
@ -445,6 +442,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
holder.displayName.setText(LinphoneUtils.getAddressDisplayName(address));
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
}
} else {
holder.displayName.setText(chatRoom.getSubject());
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);
}
if (unreadMessagesCount > 0) {

View file

@ -410,7 +410,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
private void getContactsForParticipants() {
mParticipants = new ArrayList<>();
if (mChatRoom.canHandleParticipants()) {
if (!mChatRoom.canHandleParticipants() || (mChatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(mChatRoom.getSubject()))) {
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(mRemoteSipAddress);
if (c != null) {
mParticipants.add(c);
}
} else {
int index = 0;
StringBuilder participantsLabel = new StringBuilder();
for (Participant p : mChatRoom.getParticipants()) {
@ -426,11 +431,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
if (index != mChatRoom.getNbParticipants()) participantsLabel.append(", ");
}
mParticipantsLabel.setText(participantsLabel.toString());
} else {
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(mRemoteSipAddress);
if (c != null) {
mParticipants.add(c);
}
}
if (mEventsAdapter != null) {
@ -463,13 +463,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
mBackToCallButton.setVisibility(View.VISIBLE);
} else {
mBackToCallButton.setVisibility(View.GONE);
if (mChatRoom.canHandleParticipants()) {
mCallButton.setVisibility(View.GONE);
mGroupInfosButton.setVisibility(View.VISIBLE);
mRoomLabel.setText(mChatRoom.getSubject());
mParticipantsLabel.setVisibility(View.VISIBLE);
} else {
if (!mChatRoom.canHandleParticipants() || (mChatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(mChatRoom.getSubject()))) {
mCallButton.setVisibility(View.VISIBLE);
mGroupInfosButton.setVisibility(View.GONE);
mParticipantsLabel.setVisibility(View.GONE);
@ -481,6 +475,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
} else {
mRoomLabel.setText(mParticipants.get(0).getFullName());
}
} else {
mCallButton.setVisibility(View.GONE);
mGroupInfosButton.setVisibility(View.VISIBLE);
mRoomLabel.setText(mChatRoom.getSubject());
mParticipantsLabel.setVisibility(View.VISIBLE);
}
}
}
@ -718,7 +718,20 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
@Override
public void onIsComposingReceived(ChatRoom cr, Address remoteAddr, boolean isComposing) {
if (cr.canHandleParticipants()) {
if (!cr.canHandleParticipants() || (cr.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(cr.getSubject()))) {
if (isComposing) {
String displayName;
if (mParticipants.size() > 0) {
displayName = mParticipants.get(0).getFullName();
} else {
displayName = LinphoneUtils.getAddressDisplayName(remoteAddr);
}
mRemoteComposing.setText(getString(R.string.remote_composing_single).replace("%s", displayName));
mRemoteComposing.setVisibility(View.VISIBLE);
} else {
mRemoteComposing.setVisibility(View.GONE);
}
} else {
ArrayList<String> composing = new ArrayList<>();
for (Address a : cr.getComposingAddresses()) {
boolean found = false;
@ -753,19 +766,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
} else {
mRemoteComposing.setVisibility(View.GONE);
}
} else {
if (isComposing) {
String displayName;
if (mParticipants.size() > 0) {
displayName = mParticipants.get(0).getFullName();
} else {
displayName = LinphoneUtils.getAddressDisplayName(remoteAddr);
}
mRemoteComposing.setText(getString(R.string.remote_composing_single).replace("%s", displayName));
mRemoteComposing.setVisibility(View.VISIBLE);
} else {
mRemoteComposing.setVisibility(View.GONE);
}
}
}