diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-02-08 21:24:46 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-02-08 21:24:46 +0100 |
commit | 692e0b3455635b9a97a98890b9a2484c019c7c26 (patch) | |
tree | ae7aa9e48812175573d8af70760460a9ed7331dc /src/main/java/de | |
parent | a8d81dc839f6410ebafca463a785d44e1d3ea8bb (diff) |
show number of failed uploads in chat list in red bubbles
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Conversation.java | 15 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 526c60f6c..4a7b45088 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -994,6 +994,21 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } + public int failedCount() { + synchronized (this.messages) { + int count = 0; + for (int i = this.messages.size() - 1; i >= 0; --i) { + Message message = this.messages.get(i); + if ((message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) && message.getEncryption() != Message.ENCRYPTION_PGP) { + if (message.getStatus() == Message.STATUS_SEND_FAILED){ + ++count; + } + } + } + return count; + } + } + public class Smp { public static final int STATUS_NONE = 0; public static final int STATUS_CONTACT_REQUESTED = 1; diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java index 600ac47eb..3fe3cceae 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java @@ -86,8 +86,10 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { ImageView imagePreview = (ImageView) view.findViewById(R.id.conversation_lastimage); ImageView notificationStatus = (ImageView) view.findViewById(R.id.notification_status); TextView mUnread = (TextView) view.findViewById(R.id.conversation_unread); + TextView mFailed = (TextView) view.findViewById(R.id.conversation_failed); Message message = conversation.getLatestMessage(); int unreadcount = conversation.unreadCount(); + int failedcount = conversation.failedCount(); String mimeType = message.getMimeType(); if (!conversation.isRead()) { @@ -137,6 +139,12 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { } else { mUnread.setVisibility(View.GONE); } + if (failedcount > 0) { + mFailed.setVisibility(View.VISIBLE); + mFailed.setText(String.valueOf(failedcount)); + } else { + mFailed.setVisibility(View.GONE); + } if (preview.second) { if (conversation.isRead()) { mLastMessage.setTypeface(null, Typeface.ITALIC); |