diff options
author | Andreas Straub <andy@strb.org> | 2015-07-29 02:49:14 +0200 |
---|---|---|
committer | Andreas Straub <andy@strb.org> | 2015-07-29 02:59:41 +0200 |
commit | 77920c7aa608bd92391ade653eb8971b977eb7d5 (patch) | |
tree | 8ff5169332d15d415ecb3e52d670a62c6e4d00c3 /src/main | |
parent | a3991d59c908c151fa2b1f6ea9f865313d7c8cce (diff) |
Color plaintext messages in encrypted sessions red
Plaintext messages that were received while in an encrypted session are
now colored red. We define "in an encrypted session" if a) the last
message sent by our own device before the message under consideration
(or any message received between then and now) was encrypted AND b) the
next message will be sent encrypted or the next message sent after the
one under consideration was sent encrypted
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index f55094af..c44796ba 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -560,6 +560,36 @@ public class MessageAdapter extends ArrayAdapter<Message> { } } + if (type == RECEIVED) { + boolean wasEncrypted = false; + for (Message iterator = message.prev(); iterator != null; iterator = iterator.prev()){ + if (iterator.getEncryption() != Message.ENCRYPTION_NONE) { + wasEncrypted = true; + break; + } + if (iterator.getRemoteMsgId() == null && iterator.getType() == SENT) { + break; + } + } + boolean willBeEncrypted = conversation.getNextEncryption(false) != Message.ENCRYPTION_NONE; + for (Message iterator = message.next(); iterator != null; iterator = iterator.next()){ + if (iterator.getEncryption() != Message.ENCRYPTION_NONE) { + willBeEncrypted = true; + break; + } + if (iterator.getRemoteMsgId() == null && iterator.getType() == SENT) { + break; + } + } + + if ( willBeEncrypted && wasEncrypted + && message.getEncryption() == Message.ENCRYPTION_NONE) { + viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_warning); + } else { + viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received); + } + } + displayStatus(viewHolder, message); return view; |