Allow multiple images + text, but send as multiple messages for now
This commit is contained in:
parent
9cd759b5cf
commit
3dc3bf509e
2 changed files with 31 additions and 19 deletions
|
@ -86,6 +86,8 @@
|
||||||
<string name="temp_photo_name">linphone-android-photo-temp</string>
|
<string name="temp_photo_name">linphone-android-photo-temp</string>
|
||||||
<string name="temp_photo_name_with_date">linphone-android-photo-%s</string>
|
<string name="temp_photo_name_with_date">linphone-android-photo-%s</string>
|
||||||
<bool name="lower_space_between_chat_bubbles_if_same_person">false</bool>
|
<bool name="lower_space_between_chat_bubbles_if_same_person">false</bool>
|
||||||
|
<bool name="allow_multiple_images_and_text">true</bool>
|
||||||
|
<bool name="send_text_and_images_as_different_messages">true</bool>
|
||||||
|
|
||||||
<!-- Contacts -->
|
<!-- Contacts -->
|
||||||
<bool name="hide_contact_phone_numbers">false</bool>
|
<bool name="hide_contact_phone_numbers">false</bool>
|
||||||
|
|
|
@ -226,7 +226,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
mSendMessageButton.setEnabled(mMessageTextToSend.getText().length() > 0 || mFilesUploadLayout.getChildCount() > 0);
|
mSendMessageButton.setEnabled(mMessageTextToSend.getText().length() > 0 || mFilesUploadLayout.getChildCount() > 0);
|
||||||
if (mChatRoom != null && mMessageTextToSend.getText().length() > 0) {
|
if (mChatRoom != null && mMessageTextToSend.getText().length() > 0) {
|
||||||
|
if (!getResources().getBoolean(R.bool.allow_multiple_images_and_text)) {
|
||||||
mAttachImageButton.setEnabled(false);
|
mAttachImageButton.setEnabled(false);
|
||||||
|
}
|
||||||
mChatRoom.compose();
|
mChatRoom.compose();
|
||||||
} else {
|
} else {
|
||||||
mAttachImageButton.setEnabled(true);
|
mAttachImageButton.setEnabled(true);
|
||||||
|
@ -755,8 +757,10 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
|
|
||||||
mFilesUploadLayout.addView(pendingFile);
|
mFilesUploadLayout.addView(pendingFile);
|
||||||
|
|
||||||
mAttachImageButton.setEnabled(false); // For now limit file per message to 1
|
if (!getResources().getBoolean(R.bool.allow_multiple_images_and_text)) {
|
||||||
mMessageTextToSend.setEnabled(false); // For now forbid to send both text and picture at the same time
|
mAttachImageButton.setEnabled(false);
|
||||||
|
mMessageTextToSend.setEnabled(false);
|
||||||
|
}
|
||||||
mSendMessageButton.setEnabled(true);
|
mSendMessageButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,8 +793,10 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
|
|
||||||
mFilesUploadLayout.addView(pendingImage);
|
mFilesUploadLayout.addView(pendingImage);
|
||||||
|
|
||||||
mAttachImageButton.setEnabled(false); // For now limit file per message to 1
|
if (!getResources().getBoolean(R.bool.allow_multiple_images_and_text)) {
|
||||||
mMessageTextToSend.setEnabled(false); // For now forbid to send both text and picture at the same time
|
mAttachImageButton.setEnabled(false);
|
||||||
|
mMessageTextToSend.setEnabled(false);
|
||||||
|
}
|
||||||
mSendMessageButton.setEnabled(true);
|
mSendMessageButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,12 +805,9 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void sendMessage() {
|
private void sendMessage() {
|
||||||
String text = mMessageTextToSend.getText().toString();
|
ChatMessage msg = mChatRoom.createEmptyMessage();
|
||||||
|
for (int i = 0; i < mFilesUploadLayout.getChildCount(); i++) {
|
||||||
ChatMessage msg;
|
String filePath = (String) mFilesUploadLayout.getChildAt(i).getTag();
|
||||||
//TODO: rework when we'll send multiple files at once
|
|
||||||
if (mFilesUploadLayout.getChildCount() > 0) {
|
|
||||||
String filePath = (String) mFilesUploadLayout.getChildAt(0).getTag();
|
|
||||||
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
||||||
String extension = LinphoneUtils.getExtensionFromFileName(fileName);
|
String extension = LinphoneUtils.getExtensionFromFileName(fileName);
|
||||||
Content content = Factory.instance().createContent();
|
Content content = Factory.instance().createContent();
|
||||||
|
@ -815,18 +818,25 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
}
|
}
|
||||||
content.setSubtype(extension);
|
content.setSubtype(extension);
|
||||||
content.setName(fileName);
|
content.setName(fileName);
|
||||||
msg = mChatRoom.createFileTransferMessage(content);
|
content.setFilePath(filePath); // Let the file body handler take care of the upload
|
||||||
msg.setFileTransferFilepath(filePath); // Let the file body handler take care of the upload
|
|
||||||
msg.setAppdata(filePath);
|
|
||||||
|
|
||||||
|
if (getResources().getBoolean(R.bool.send_text_and_images_as_different_messages)) {
|
||||||
|
ChatMessage fileMessage = mChatRoom.createFileTransferMessage(content);
|
||||||
|
fileMessage.send();
|
||||||
|
} else {
|
||||||
|
msg.addFileContent(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = mMessageTextToSend.getText().toString();
|
||||||
if (text != null && text.length() > 0) {
|
if (text != null && text.length() > 0) {
|
||||||
msg.addTextContent(text);
|
msg.addTextContent(text);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
msg = mChatRoom.createMessage(text);
|
|
||||||
}
|
|
||||||
// Set listener not required here anymore, message will be added to messages list and adapter will set the listener
|
// Set listener not required here anymore, message will be added to messages list and adapter will set the listener
|
||||||
|
if (msg.getContents().length > 0) {
|
||||||
msg.send();
|
msg.send();
|
||||||
|
}
|
||||||
|
|
||||||
mFilesUploadLayout.removeAllViews();
|
mFilesUploadLayout.removeAllViews();
|
||||||
mAttachImageButton.setEnabled(true);
|
mAttachImageButton.setEnabled(true);
|
||||||
|
|
Loading…
Reference in a new issue