Chat and group chat will use the same layout. For the time being, group chat will be in separated fragment, but once it will be finished, we will merge chat fragment into it

This commit is contained in:
Sylvain Berfini 2017-10-23 11:29:28 +02:00
parent 9a703ded12
commit 2077995128
6 changed files with 23 additions and 36 deletions

View file

@ -3,6 +3,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/event"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/bubble" android:id="@+id/bubble"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -699,9 +699,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
private void displayChat(String sipUri, String message, String fileUri, String pictureUri, String thumbnailUri, String displayName, Address lAddress) { private void displayChat(String sipUri, String message, String fileUri, String pictureUri, String thumbnailUri, String displayName, Address lAddress) {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("SipUri", sipUri); extras.putString("SipUri", sipUri);
if(message != null) if (message != null)
extras.putString("messageDraft", message); extras.putString("messageDraft", message);
if(fileUri != null) if (fileUri != null)
extras.putString("fileSharedUri", fileUri); extras.putString("fileSharedUri", fileUri);
if (sipUri != null && lAddress.getDisplayName() != null) { if (sipUri != null && lAddress.getDisplayName() != null) {
extras.putString("DisplayName", displayName); extras.putString("DisplayName", displayName);
@ -710,10 +710,15 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
} }
if(sipUri == null && message == null && fileUri == null) { if(sipUri == null && message == null && fileUri == null) {
changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras); changeCurrentFragment(FragmentsAvailable.CREATE_CHAT, extras);
} else {
ChatRoom room = LinphoneManager.getLc().getChatRoom(lAddress);
if (room.canHandleParticipants()) {
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
} else { } else {
changeCurrentFragment(FragmentsAvailable.CHAT, extras); changeCurrentFragment(FragmentsAvailable.CHAT, extras);
} }
} }
}
public void displayChat(String sipUri, String message, String fileUri) { public void displayChat(String sipUri, String message, String fileUri) {
if (getResources().getBoolean(R.bool.disable_chat)) { if (getResources().getBoolean(R.bool.disable_chat)) {
@ -725,7 +730,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
String displayName = null; String displayName = null;
Address lAddress = null; Address lAddress = null;
if(sipUri != null) { if (sipUri != null) {
lAddress = LinphoneManager.getLc().interpretUrl(sipUri); lAddress = LinphoneManager.getLc().interpretUrl(sipUri);
if (lAddress == null) return; if (lAddress == null) return;
LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lAddress); LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(lAddress);

View file

@ -310,7 +310,8 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
displayChatGroupCreation(); displayChatGroupCreation();
} }
} else if (id == R.id.confirm) { } else if (id == R.id.confirm) {
//TODO //TODO get chatRoom URI
//LinphoneActivity.instance().displayChat(contactsSelected.get(0).getAddress(), "", "");
} else if (id == R.id.clearSearchField) { } else if (id == R.id.clearSearchField) {
searchField.setText(""); searchField.setText("");
searchAdapter.searchContacts("", contactsList); searchAdapter.searchContacts("", contactsList);

View file

@ -123,15 +123,9 @@ interface ChatUpdatedListener {
public class ChatFragment extends Fragment implements OnClickListener, ChatMessageListener, ContactsUpdatedListener { public class ChatFragment extends Fragment implements OnClickListener, ChatMessageListener, ContactsUpdatedListener {
private static final int ADD_PHOTO = 1337; private static final int ADD_PHOTO = 1337;
private static final int MENU_DELETE_MESSAGE = 0; private static final int MENU_DELETE_MESSAGE = 0;
private static final int MENU_PICTURE_SMALL = 2;
private static final int MENU_PICTURE_MEDIUM = 3;
private static final int MENU_PICTURE_LARGE = 4;
private static final int MENU_PICTURE_REAL = 5;
private static final int MENU_COPY_TEXT = 6; private static final int MENU_COPY_TEXT = 6;
private static final int MENU_RESEND_MESSAGE = 7; private static final int MENU_RESEND_MESSAGE = 7;
private static final int SIZE_SMALL = 500; private static final int SIZE_SMALL = 500;
private static final int SIZE_MEDIUM = 1000;
private static final int SIZE_LARGE = 1500;
private static final int SIZE_MAX = 2048; private static final int SIZE_MAX = 2048;
private ChatRoom chatRoom; private ChatRoom chatRoom;
@ -150,14 +144,13 @@ public class ChatFragment extends Fragment implements OnClickListener, ChatMessa
private boolean isEditMode = false; private boolean isEditMode = false;
private LinphoneContact contact; private LinphoneContact contact;
private Uri imageToUploadUri; private Uri imageToUploadUri;
private String filePathToUpload;
private TextWatcher textWatcher; private TextWatcher textWatcher;
private ViewTreeObserver.OnGlobalLayoutListener keyboardListener; private ViewTreeObserver.OnGlobalLayoutListener keyboardListener;
private ChatMessageAdapter adapter; private ChatMessageAdapter adapter;
private CoreListenerStub mListener; private CoreListenerStub mListener;
private boolean newChatConversation = false; private boolean newChatConversation = false;
private String fileSharedUri, fileAlreadySharedUri; private String fileSharedUri;
private static ArrayList<ChatUpdatedListener> ChatUpdatedListeners; private static ArrayList<ChatUpdatedListener> ChatUpdatedListeners;
@ -473,16 +466,8 @@ public class ChatFragment extends Fragment implements OnClickListener, ChatMessa
@Override @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (v.getId() == R.id.send_picture) {
menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small));
menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium));
menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large));
// Not a good idea, very big pictures cause Out of Memory exceptions, slow display, ...
// menu.add(0, MENU_PICTURE_REAL, 0, getString(R.string.share_picture_size_real));
} else {
menu.add(v.getId(), MENU_DELETE_MESSAGE, 0, getString(R.string.delete)); menu.add(v.getId(), MENU_DELETE_MESSAGE, 0, getString(R.string.delete));
menu.add(v.getId(), MENU_COPY_TEXT, 0, getString(R.string.copy_text)); menu.add(v.getId(), MENU_COPY_TEXT, 0, getString(R.string.copy_text));
}
/* ChatMessage msg = getMessageForId(v.getId()); /* ChatMessage msg = getMessageForId(v.getId());
if (msg != null && msg.getStatus() == ChatMessage.State.NotDelivered) { if (msg != null && msg.getStatus() == ChatMessage.State.NotDelivered) {
@ -517,18 +502,6 @@ public class ChatFragment extends Fragment implements OnClickListener, ChatMessa
resendMessage(item.getGroupId()); resendMessage(item.getGroupId());
break; break;
*/ */
case MENU_PICTURE_SMALL:
sendImageMessage(filePathToUpload, SIZE_SMALL);
break;
case MENU_PICTURE_MEDIUM:
sendImageMessage(filePathToUpload, SIZE_MEDIUM);
break;
case MENU_PICTURE_LARGE:
sendImageMessage(filePathToUpload, SIZE_LARGE);
break;
case MENU_PICTURE_REAL:
sendImageMessage(filePathToUpload, SIZE_MAX);
break;
} }
return true; return true;
} }

View file

@ -437,6 +437,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()) {
holder.displayName.setText(chatRoom.getSubject()); holder.displayName.setText(chatRoom.getSubject());
holder.contactPicture.setImageResource(R.drawable.chat_group_avatar); holder.contactPicture.setImageResource(R.drawable.chat_group_avatar);

View file

@ -33,7 +33,7 @@ public class GroupChatFragment extends Fragment implements View.OnClickListener
@Override @Override
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.create_chat, container, false); View view = inflater.inflate(R.layout.chat, container, false);
return view; return view;
} }