mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 11:42:15 -05:00
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:
parent
a3991d59c9
commit
77920c7aa6
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user