From cb4069f0f213ed1a38ce074d981b0c367dc2cdfd Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 15 Oct 2014 19:32:12 +0200 Subject: refactored file download status. make image http download available for carbon copied (sent) messages as well --- .../ui/adapter/ConversationAdapter.java | 100 ++++++++++++--------- 1 file changed, 56 insertions(+), 44 deletions(-) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index f74856b0..6943a85c 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -5,6 +5,7 @@ import java.util.List; 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.Message; import eu.siacs.conversations.ui.ConversationActivity; import eu.siacs.conversations.ui.XmppActivity; @@ -37,11 +38,11 @@ public class ConversationAdapter extends ArrayAdapter { view = (View) inflater.inflate(R.layout.conversation_list_row, parent, false); } - Conversation conv = getItem(position); + Conversation conversation = getItem(position); if (this.activity instanceof ConversationActivity) { ConversationActivity activity = (ConversationActivity) this.activity; if (!activity.isConversationsOverviewHideable()) { - if (conv == activity.getSelectedConversation()) { + if (conversation == activity.getSelectedConversation()) { view.setBackgroundColor(activity .getSecondaryBackgroundColor()); } else { @@ -53,65 +54,76 @@ public class ConversationAdapter extends ArrayAdapter { } TextView convName = (TextView) view .findViewById(R.id.conversation_name); - if (conv.getMode() == Conversation.MODE_SINGLE + if (conversation.getMode() == Conversation.MODE_SINGLE || activity.useSubjectToIdentifyConference()) { - convName.setText(conv.getName()); + convName.setText(conversation.getName()); } else { - convName.setText(conv.getContactJid().split("/")[0]); + convName.setText(conversation.getContactJid().split("/")[0]); } - TextView convLastMsg = (TextView) view + TextView mLastMessage = (TextView) view .findViewById(R.id.conversation_lastmsg); + TextView mTimestamp = (TextView) view + .findViewById(R.id.conversation_lastupdate); ImageView imagePreview = (ImageView) view .findViewById(R.id.conversation_lastimage); - Message latestMessage = conv.getLatestMessage(); + Message message = conversation.getLatestMessage(); - if (latestMessage.getType() == Message.TYPE_TEXT - || latestMessage.getType() == Message.TYPE_PRIVATE) { - if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP) - && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) { - String body = Config.PARSE_EMOTICONS ? UIHelper - .transformAsciiEmoticons(latestMessage.getBody()) - : latestMessage.getBody(); - convLastMsg.setText(body); - } else { - convLastMsg.setText(R.string.encrypted_message_received); - } - convLastMsg.setVisibility(View.VISIBLE); - imagePreview.setVisibility(View.GONE); - } else if (latestMessage.getType() == Message.TYPE_IMAGE) { - if (latestMessage.getStatus() >= Message.STATUS_RECEIVED) { - convLastMsg.setVisibility(View.GONE); - imagePreview.setVisibility(View.VISIBLE); - activity.loadBitmap(latestMessage, imagePreview); - } else { - convLastMsg.setVisibility(View.VISIBLE); + if (!conversation.isRead()) { + convName.setTypeface(null, Typeface.BOLD); + } else { + convName.setTypeface(null, Typeface.NORMAL); + } + + if (message.getType() == Message.TYPE_IMAGE + || message.getDownloadable() != null) { + Downloadable d = message.getDownloadable(); + if (d != null) { + mLastMessage.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.GONE); - if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) { - convLastMsg.setText(R.string.image_offered_for_download); - } else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) { - convLastMsg.setText(R.string.receiving_image); + if (conversation.isRead()) { + mLastMessage.setTypeface(null, Typeface.ITALIC); + } else { + mLastMessage.setTypeface(null, Typeface.BOLD_ITALIC); + } + 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); + } else if (d.getStatus() == Downloadable.STATUS_OFFER) { + mLastMessage.setText(R.string.image_offered_for_download); } else { - convLastMsg.setText(""); + mLastMessage.setText(""); } + } else { + mLastMessage.setVisibility(View.GONE); + imagePreview.setVisibility(View.VISIBLE); + activity.loadBitmap(message, imagePreview); } - } - - if (!conv.isRead()) { - convName.setTypeface(null, Typeface.BOLD); - convLastMsg.setTypeface(null, Typeface.BOLD); } else { - convName.setTypeface(null, Typeface.NORMAL); - convLastMsg.setTypeface(null, Typeface.NORMAL); + if ((message.getEncryption() != Message.ENCRYPTION_PGP) + && (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) { + String body = Config.PARSE_EMOTICONS ? UIHelper + .transformAsciiEmoticons(message.getBody()) : message + .getBody(); + mLastMessage.setText(body); + } else { + mLastMessage.setText(R.string.encrypted_message_received); + } + if (!conversation.isRead()) { + mLastMessage.setTypeface(null, Typeface.BOLD); + } else { + mLastMessage.setTypeface(null, Typeface.NORMAL); + } + mLastMessage.setVisibility(View.VISIBLE); + imagePreview.setVisibility(View.GONE); } - - ((TextView) view.findViewById(R.id.conversation_lastupdate)) - .setText(UIHelper.readableTimeDifference(getContext(), conv - .getLatestMessage().getTimeSent())); + mTimestamp.setText(UIHelper.readableTimeDifference(getContext(), + conversation.getLatestMessage().getTimeSent())); ImageView profilePicture = (ImageView) view .findViewById(R.id.conversation_image); - profilePicture.setImageBitmap(conv.getImage(activity, 56)); + profilePicture.setImageBitmap(conversation.getImage(activity, 56)); return view; } -- cgit v1.2.3 From f5019ba96647bd1c33153e6e9099d21dcf47bfa7 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Wed, 15 Oct 2014 22:08:13 +0200 Subject: detect deleted files on start up. got rid of lagecy image provider for performance reasons. NOTE: this will prevent you to access images older than version 0.6 --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 6943a85c..bd37f7fc 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -92,6 +92,8 @@ public class ConversationAdapter extends ArrayAdapter { mLastMessage.setText(R.string.receiving_image); } else if (d.getStatus() == Downloadable.STATUS_OFFER) { mLastMessage.setText(R.string.image_offered_for_download); + } else if (d.getStatus() == Downloadable.STATUS_DELETED) { + mLastMessage.setText(R.string.image_file_deleted); } else { mLastMessage.setText(""); } -- cgit v1.2.3 From 8263e073362aed2ebfda910df8ddad1e84302db1 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sun, 19 Oct 2014 23:42:53 +0200 Subject: mtm support for image downloader --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index bd37f7fc..20c7bee2 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -92,6 +92,8 @@ public class ConversationAdapter extends ArrayAdapter { mLastMessage.setText(R.string.receiving_image); } else if (d.getStatus() == Downloadable.STATUS_OFFER) { 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 { -- cgit v1.2.3 From 21961673cbcb3132d2405c3d276058b94cbdbbfc Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Mon, 20 Oct 2014 21:08:33 +0200 Subject: refactored avatar generation. first step --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 20c7bee2..1fea8dcf 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -127,7 +127,9 @@ public class ConversationAdapter extends ArrayAdapter { ImageView profilePicture = (ImageView) view .findViewById(R.id.conversation_image); - profilePicture.setImageBitmap(conversation.getImage(activity, 56)); + profilePicture.setImageBitmap(activity.xmppConnectionService + .getAvatarService().getAvatar(conversation, + activity.getPixel(56))); return view; } -- cgit v1.2.3 From 0d767c39711f171d94d4682f355370d4bdd225ae Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Tue, 21 Oct 2014 14:57:16 +0200 Subject: proper avatar caching --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 1fea8dcf..183c89fa 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -127,9 +127,8 @@ public class ConversationAdapter extends ArrayAdapter { ImageView profilePicture = (ImageView) view .findViewById(R.id.conversation_image); - profilePicture.setImageBitmap(activity.xmppConnectionService - .getAvatarService().getAvatar(conversation, - activity.getPixel(56))); + profilePicture.setImageBitmap(activity.avatarService().get( + conversation, activity.getPixel(56))); return view; } -- cgit v1.2.3 From cbc3d9bd6f275984b390eb4dae48f8eed669fe7a Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 24 Oct 2014 13:29:18 +0200 Subject: notify only after image has been received over http. introduced mini grace for catching up with SM or offline messages --- .../siacs/conversations/ui/adapter/ConversationAdapter.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 183c89fa..0c294e7e 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -78,14 +78,14 @@ public class ConversationAdapter extends ArrayAdapter { if (message.getType() == Message.TYPE_IMAGE || message.getDownloadable() != null) { Downloadable d = message.getDownloadable(); + if (conversation.isRead()) { + mLastMessage.setTypeface(null, Typeface.ITALIC); + } else { + mLastMessage.setTypeface(null, Typeface.BOLD_ITALIC); + } if (d != null) { mLastMessage.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.GONE); - if (conversation.isRead()) { - mLastMessage.setTypeface(null, Typeface.ITALIC); - } else { - mLastMessage.setTypeface(null, Typeface.BOLD_ITALIC); - } if (d.getStatus() == Downloadable.STATUS_CHECKING) { mLastMessage.setText(R.string.checking_image); } else if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) { @@ -99,6 +99,8 @@ public class ConversationAdapter extends ArrayAdapter { } else { mLastMessage.setText(""); } + } else if (message.getEncryption() == Message.ENCRYPTION_PGP) { + mLastMessage.setText(R.string.encrypted_message_received); } else { mLastMessage.setVisibility(View.GONE); imagePreview.setVisibility(View.VISIBLE); -- cgit v1.2.3 From 864f3610b30d684a19fe86eff22835a5ba2e92c4 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Fri, 24 Oct 2014 14:34:46 +0200 Subject: picture notification and some drive by bug fixes --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index 0c294e7e..b2e5dd07 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -100,6 +100,8 @@ public class ConversationAdapter extends ArrayAdapter { mLastMessage.setText(""); } } else if (message.getEncryption() == Message.ENCRYPTION_PGP) { + imagePreview.setVisibility(View.GONE); + mLastMessage.setVisibility(View.VISIBLE); mLastMessage.setText(R.string.encrypted_message_received); } else { mLastMessage.setVisibility(View.GONE); -- cgit v1.2.3 From 020dc863b17a1c9f9c6cb9ff5798d8fcc79a406e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 26 Oct 2014 18:54:10 +0100 Subject: remove some unused cast --- src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java') diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java index b2e5dd07..b5c20dc5 100644 --- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java +++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java @@ -35,7 +35,7 @@ public class ConversationAdapter extends ArrayAdapter { if (view == null) { LayoutInflater inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = (View) inflater.inflate(R.layout.conversation_list_row, + view = inflater.inflate(R.layout.conversation_list_row, parent, false); } Conversation conversation = getItem(position); -- cgit v1.2.3