From 4ab558715cc279515894d8ad28053716d3d61ad2 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 14 Nov 2014 17:39:03 +0100 Subject: adepted conversationadapter to deal with files --- .../ui/adapter/ConversationAdapter.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index b3df8d72..b1aea209 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -6,6 +6,7 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Downloadable; +import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.XmppActivity; @@ -75,7 +76,7 @@ public class ConversationAdapter extends ArrayAdapter { 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) { Downloadable d = message.getDownloadable(); if (conversation.isRead()) { @@ -89,13 +90,25 @@ public class ConversationAdapter extends ArrayAdapter { if (d.getStatus() == Downloadable.STATUS_CHECKING) { mLastMessage.setText(R.string.checking_image); } 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) { - mLastMessage.setText(R.string.image_offered_for_download); + if (message.getType() == Message.TYPE_FILE) { + mLastMessage.setText(R.string.file_offered_for_download); + } else { + mLastMessage.setText(R.string.image_offered_for_download); + } } else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) { mLastMessage.setText(R.string.image_offered_for_download); } else if (d.getStatus() == Downloadable.STATUS_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 { mLastMessage.setText(""); } @@ -103,6 +116,11 @@ public class ConversationAdapter extends ArrayAdapter { imagePreview.setVisibility(View.GONE); mLastMessage.setVisibility(View.VISIBLE); 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 { mLastMessage.setVisibility(View.GONE); imagePreview.setVisibility(View.VISIBLE); -- cgit v1.2.3 From 47d44448f3c2e4527b23fcabc4ee65269094eda1 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 15 Nov 2014 14:40:43 +0100 Subject: fixed description in notifications and conversation overview --- .../siacs/conversations/ui/adapter/ConversationAdapter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index b1aea209..b81544e6 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -104,7 +104,17 @@ public class ConversationAdapter extends ArrayAdapter { } else if (d.getStatus() == Downloadable.STATUS_OFFER_CHECK_FILESIZE) { mLastMessage.setText(R.string.image_offered_for_download); } else if (d.getStatus() == Downloadable.STATUS_DELETED) { - mLastMessage.setText(R.string.image_file_deleted); + if (message.getType() == Message.TYPE_FILE) { + mLastMessage.setText(R.string.file_deleted); + } else { + mLastMessage.setText(R.string.image_file_deleted); + } + } else if (d.getStatus() == Downloadable.STATUS_FAILED) { + if (message.getType() == Message.TYPE_FILE) { + mLastMessage.setText(R.string.file_transmission_failed); + } else { + mLastMessage.setText(R.string.image_transmission_failed); + } } else if (message.getImageParams().width > 0) { mLastMessage.setVisibility(View.GONE); imagePreview.setVisibility(View.VISIBLE); -- cgit v1.2.3