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:
parent
a90a8f9fef
commit
e024554908
4 changed files with 34 additions and 32 deletions
|
@ -3,6 +3,8 @@
|
||||||
<!-- Do not translate any of the strings below -->
|
<!-- Do not translate any of the strings below -->
|
||||||
<bool name="isTablet">false</bool>
|
<bool name="isTablet">false</bool>
|
||||||
|
|
||||||
|
<string name="dummy_group_chat_subject">dummy subject</string>
|
||||||
|
|
||||||
<item type="id" name="contact_search_name" />
|
<item type="id" name="contact_search_name" />
|
||||||
<string name="pref_disable_account_key">pref_disable_account_key</string>
|
<string name="pref_disable_account_key">pref_disable_account_key</string>
|
||||||
<string name="pref_extra_accounts">pref_nb_accounts_extra</string>
|
<string name="pref_extra_accounts">pref_nb_accounts_extra</string>
|
||||||
|
|
|
@ -289,7 +289,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
//LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
|
//LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
|
||||||
//TODO create group chat room with only two participants ?
|
//TODO create group chat room with only two participants ?
|
||||||
//TODO what subject to set ?
|
//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() {
|
chatRoom.setListener(new ChatRoomListenerStub() {
|
||||||
@Override
|
@Override
|
||||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||||
|
|
|
@ -434,10 +434,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
holder.displayName.setSelected(true); // For animation
|
holder.displayName.setSelected(true); // For animation
|
||||||
|
|
||||||
if (chatRoom.canHandleParticipants()) {
|
if (!chatRoom.canHandleParticipants() || (chatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(chatRoom.getSubject()))) {
|
||||||
holder.displayName.setText(chatRoom.getSubject());
|
|
||||||
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);
|
|
||||||
} else {
|
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
holder.displayName.setText(contact.getFullName());
|
holder.displayName.setText(contact.getFullName());
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
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.displayName.setText(LinphoneUtils.getAddressDisplayName(address));
|
||||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
holder.displayName.setText(chatRoom.getSubject());
|
||||||
|
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unreadMessagesCount > 0) {
|
if (unreadMessagesCount > 0) {
|
||||||
|
|
|
@ -410,7 +410,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
|
|
||||||
private void getContactsForParticipants() {
|
private void getContactsForParticipants() {
|
||||||
mParticipants = new ArrayList<>();
|
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;
|
int index = 0;
|
||||||
StringBuilder participantsLabel = new StringBuilder();
|
StringBuilder participantsLabel = new StringBuilder();
|
||||||
for (Participant p : mChatRoom.getParticipants()) {
|
for (Participant p : mChatRoom.getParticipants()) {
|
||||||
|
@ -426,11 +431,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
if (index != mChatRoom.getNbParticipants()) participantsLabel.append(", ");
|
if (index != mChatRoom.getNbParticipants()) participantsLabel.append(", ");
|
||||||
}
|
}
|
||||||
mParticipantsLabel.setText(participantsLabel.toString());
|
mParticipantsLabel.setText(participantsLabel.toString());
|
||||||
} else {
|
|
||||||
LinphoneContact c = ContactsManager.getInstance().findContactFromAddress(mRemoteSipAddress);
|
|
||||||
if (c != null) {
|
|
||||||
mParticipants.add(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEventsAdapter != null) {
|
if (mEventsAdapter != null) {
|
||||||
|
@ -463,13 +463,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
mBackToCallButton.setVisibility(View.VISIBLE);
|
mBackToCallButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mBackToCallButton.setVisibility(View.GONE);
|
mBackToCallButton.setVisibility(View.GONE);
|
||||||
if (mChatRoom.canHandleParticipants()) {
|
if (!mChatRoom.canHandleParticipants() || (mChatRoom.getNbParticipants() == 1 && getString(R.string.dummy_group_chat_subject).equals(mChatRoom.getSubject()))) {
|
||||||
mCallButton.setVisibility(View.GONE);
|
|
||||||
mGroupInfosButton.setVisibility(View.VISIBLE);
|
|
||||||
mRoomLabel.setText(mChatRoom.getSubject());
|
|
||||||
mParticipantsLabel.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mCallButton.setVisibility(View.VISIBLE);
|
mCallButton.setVisibility(View.VISIBLE);
|
||||||
mGroupInfosButton.setVisibility(View.GONE);
|
mGroupInfosButton.setVisibility(View.GONE);
|
||||||
mParticipantsLabel.setVisibility(View.GONE);
|
mParticipantsLabel.setVisibility(View.GONE);
|
||||||
|
@ -481,6 +475,12 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
} else {
|
} else {
|
||||||
mRoomLabel.setText(mParticipants.get(0).getFullName());
|
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
|
@Override
|
||||||
public void onIsComposingReceived(ChatRoom cr, Address remoteAddr, boolean isComposing) {
|
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<>();
|
ArrayList<String> composing = new ArrayList<>();
|
||||||
for (Address a : cr.getComposingAddresses()) {
|
for (Address a : cr.getComposingAddresses()) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -753,19 +766,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
} else {
|
} else {
|
||||||
mRemoteComposing.setVisibility(View.GONE);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue