adepted conversationadapter to deal with files
This commit is contained in:
parent
af2922adea
commit
4ab558715c
|
@ -6,6 +6,7 @@ import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Downloadable;
|
import eu.siacs.conversations.entities.Downloadable;
|
||||||
|
import eu.siacs.conversations.entities.DownloadableFile;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.ui.ConversationActivity;
|
import eu.siacs.conversations.ui.ConversationActivity;
|
||||||
import eu.siacs.conversations.ui.XmppActivity;
|
import eu.siacs.conversations.ui.XmppActivity;
|
||||||
|
@ -75,7 +76,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
convName.setTypeface(null, Typeface.NORMAL);
|
convName.setTypeface(null, Typeface.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.getType() == Message.TYPE_IMAGE
|
if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE
|
||||||
|| message.getDownloadable() != null) {
|
|| message.getDownloadable() != null) {
|
||||||
Downloadable d = message.getDownloadable();
|
Downloadable d = message.getDownloadable();
|
||||||
if (conversation.isRead()) {
|
if (conversation.isRead()) {
|
||||||
|
@ -89,13 +90,25 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
if (d.getStatus() == Downloadable.STATUS_CHECKING) {
|
if (d.getStatus() == Downloadable.STATUS_CHECKING) {
|
||||||
mLastMessage.setText(R.string.checking_image);
|
mLastMessage.setText(R.string.checking_image);
|
||||||
} else if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
|
} else if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
|
||||||
mLastMessage.setText(R.string.receiving_image);
|
if (message.getType() == Message.TYPE_FILE) {
|
||||||
|
mLastMessage.setText(getContext().getString(R.string.receiving_file,d.getMimeType(), d.getProgress()));
|
||||||
|
} else {
|
||||||
|
mLastMessage.setText(getContext().getString(R.string.receiving_image, d.getProgress()));
|
||||||
|
}
|
||||||
} else if (d.getStatus() == Downloadable.STATUS_OFFER) {
|
} else if (d.getStatus() == Downloadable.STATUS_OFFER) {
|
||||||
|
if (message.getType() == Message.TYPE_FILE) {
|
||||||
|
mLastMessage.setText(R.string.file_offered_for_download);
|
||||||
|
} else {
|
||||||
mLastMessage.setText(R.string.image_offered_for_download);
|
mLastMessage.setText(R.string.image_offered_for_download);
|
||||||
|
}
|
||||||
} else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
|
} else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) {
|
||||||
mLastMessage.setText(R.string.image_offered_for_download);
|
mLastMessage.setText(R.string.image_offered_for_download);
|
||||||
} else if (d.getStatus() == Downloadable.STATUS_DELETED) {
|
} else if (d.getStatus() == Downloadable.STATUS_DELETED) {
|
||||||
mLastMessage.setText(R.string.image_file_deleted);
|
mLastMessage.setText(R.string.image_file_deleted);
|
||||||
|
} else if (message.getImageParams().width > 0) {
|
||||||
|
mLastMessage.setVisibility(View.GONE);
|
||||||
|
imagePreview.setVisibility(View.VISIBLE);
|
||||||
|
activity.loadBitmap(message, imagePreview);
|
||||||
} else {
|
} else {
|
||||||
mLastMessage.setText("");
|
mLastMessage.setText("");
|
||||||
}
|
}
|
||||||
|
@ -103,6 +116,11 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|
||||||
imagePreview.setVisibility(View.GONE);
|
imagePreview.setVisibility(View.GONE);
|
||||||
mLastMessage.setVisibility(View.VISIBLE);
|
mLastMessage.setVisibility(View.VISIBLE);
|
||||||
mLastMessage.setText(R.string.encrypted_message_received);
|
mLastMessage.setText(R.string.encrypted_message_received);
|
||||||
|
} else if (message.getType() == Message.TYPE_FILE && message.getImageParams().width <= 0) {
|
||||||
|
DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
|
||||||
|
mLastMessage.setVisibility(View.VISIBLE);
|
||||||
|
imagePreview.setVisibility(View.GONE);
|
||||||
|
mLastMessage.setText(getContext().getString(R.string.file,file.getMimeType()));
|
||||||
} else {
|
} else {
|
||||||
mLastMessage.setVisibility(View.GONE);
|
mLastMessage.setVisibility(View.GONE);
|
||||||
imagePreview.setVisibility(View.VISIBLE);
|
imagePreview.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -317,4 +317,6 @@
|
||||||
<string name="open_file">Open %s file</string>
|
<string name="open_file">Open %s file</string>
|
||||||
<string name="sending_file">sending (%1$d%% completed)</string>
|
<string name="sending_file">sending (%1$d%% completed)</string>
|
||||||
<string name="preparing_file">Preparing file for transmission</string>
|
<string name="preparing_file">Preparing file for transmission</string>
|
||||||
|
<string name="file_offered_for_download">File offered for download</string>
|
||||||
|
<string name="file">%s file</string>;
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue