From a7fd629c051a3ba0031fba4e358ba4f3b843283d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 28 Oct 2015 22:40:09 +0100 Subject: [PATCH] show encryption type in warned/red messages --- .../conversations/ui/adapter/MessageAdapter.java | 6 ++++++ .../siacs/conversations/utils/CryptoHelper.java | 15 +++++++++++++++ src/main/res/layout/message_received.xml | 11 +++++++++++ 3 files changed, 32 insertions(+) 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 d9fea8170..42c68eb8b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -36,6 +36,7 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message.FileParams; import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.ui.ConversationActivity; +import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.GeoHelper; import eu.siacs.conversations.utils.UIHelper; @@ -462,6 +463,7 @@ public class MessageAdapter extends ArrayAdapter { .findViewById(R.id.message_time); viewHolder.indicatorReceived = (ImageView) view .findViewById(R.id.indicator_received); + viewHolder.encryption = (TextView) view.findViewById(R.id.message_encryption); break; case STATUS: view = activity.getLayoutInflater().inflate(R.layout.message_status, parent, false); @@ -585,8 +587,11 @@ public class MessageAdapter extends ArrayAdapter { } else { viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received); } + viewHolder.encryption.setVisibility(View.GONE); } else { viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_warning); + viewHolder.encryption.setVisibility(View.VISIBLE); + viewHolder.encryption.setText(CryptoHelper.encryptionTypeToText(message.getEncryption())); } } @@ -667,5 +672,6 @@ public class MessageAdapter extends ArrayAdapter { protected TextView messageBody; protected ImageView contact_picture; protected TextView status_message; + protected TextView encryption; } } diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java index 8091a9966..ab407249c 100644 --- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java @@ -23,6 +23,8 @@ import java.util.LinkedHashSet; import java.util.List; import eu.siacs.conversations.Config; +import eu.siacs.conversations.R; +import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; @@ -164,4 +166,17 @@ public final class CryptoHelper { return null; } } + + public static int encryptionTypeToText(int encryption) { + switch (encryption) { + case Message.ENCRYPTION_OTR: + return R.string.encryption_choice_otr; + case Message.ENCRYPTION_AXOLOTL: + return R.string.encryption_choice_omemo; + case Message.ENCRYPTION_NONE: + return R.string.encryption_choice_unencrypted; + default: + return R.string.encryption_choice_pgp; + } + } } diff --git a/src/main/res/layout/message_received.xml b/src/main/res/layout/message_received.xml index 76df710bf..b6a29e869 100644 --- a/src/main/res/layout/message_received.xml +++ b/src/main/res/layout/message_received.xml @@ -72,6 +72,17 @@ android:orientation="horizontal" android:paddingBottom="2dp"> + +