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
This commit is contained in:
Andreas Straub 2015-07-29 02:49:14 +02:00
parent a3991d59c9
commit 77920c7aa6

View file

@ -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); displayStatus(viewHolder, message);
return view; return view;