diff --git a/app/src/main/java/im/conversations/android/database/model/MessageWithContentReactions.java b/app/src/main/java/im/conversations/android/database/model/MessageWithContentReactions.java
index 3b15f0d37..72396c23e 100644
--- a/app/src/main/java/im/conversations/android/database/model/MessageWithContentReactions.java
+++ b/app/src/main/java/im/conversations/android/database/model/MessageWithContentReactions.java
@@ -149,4 +149,26 @@ public class MessageWithContentReactions implements IndividualName {
public BareJid individualAddress() {
return sender;
}
+
+ public String getSender() {
+ return this.fromResource == null ? null : fromResource.toString();
+ }
+
+ public boolean isGroupChat() {
+ return Arrays.asList(ChatType.MUC, ChatType.MULTICAST).contains(this.chatType);
+ }
+
+ public EncryptionTuple getEncryption() {
+ return new EncryptionTuple(this.encryption, this.trust);
+ }
+
+ public static class EncryptionTuple {
+ public final Encryption encryption;
+ public final Trust trust;
+
+ public EncryptionTuple(Encryption encryption, Trust trust) {
+ this.encryption = encryption;
+ this.trust = trust;
+ }
+ }
}
diff --git a/app/src/main/java/im/conversations/android/ui/BindingAdapters.java b/app/src/main/java/im/conversations/android/ui/BindingAdapters.java
index de780cc3a..20e75bd74 100644
--- a/app/src/main/java/im/conversations/android/ui/BindingAdapters.java
+++ b/app/src/main/java/im/conversations/android/ui/BindingAdapters.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.format.DateUtils;
import android.view.KeyEvent;
import android.view.View;
+import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.databinding.BindingAdapter;
@@ -13,6 +14,9 @@ import com.google.android.material.textfield.TextInputLayout;
import com.google.common.base.Supplier;
import im.conversations.android.R;
import im.conversations.android.database.model.ChatOverviewItem;
+import im.conversations.android.database.model.Encryption;
+import im.conversations.android.database.model.MessageWithContentReactions;
+import im.conversations.android.database.model.Trust;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
@@ -113,4 +117,31 @@ public class BindingAdapters {
textView.setVisibility(View.VISIBLE);
}
}
+
+ @BindingAdapter("encryption")
+ public static void setEncryption(
+ final ImageView imageView,
+ final MessageWithContentReactions.EncryptionTuple encryptionTuple) {
+ if (encryptionTuple == null) {
+ imageView.setVisibility(View.GONE);
+ return;
+ }
+ final var encryption = encryptionTuple.encryption;
+ final var trust = encryptionTuple.trust;
+ if (encryption == null || encryption == Encryption.CLEARTEXT) {
+ imageView.setVisibility(View.GONE);
+ } else if (encryption == Encryption.OMEMO || encryption == Encryption.PGP) {
+ if (trust == Trust.VERIFIED || trust == Trust.VERIFIED_X509) {
+ imageView.setImageResource(R.drawable.ic_verified_user_24dp);
+ } else {
+ imageView.setImageResource(R.drawable.ic_lock_outline_24dp);
+ }
+ imageView.setVisibility(View.VISIBLE);
+ } else if (encryption == Encryption.FAILURE) {
+ imageView.setImageResource(R.drawable.ic_encryption_errorred_24dp);
+ imageView.setVisibility(View.VISIBLE);
+ } else {
+ throw new IllegalArgumentException(String.format("Unknown encryption %s", encryption));
+ }
+ }
}
diff --git a/app/src/main/res/drawable/ic_encryption_errorred_24dp.xml b/app/src/main/res/drawable/ic_encryption_errorred_24dp.xml
new file mode 100644
index 000000000..172c06a8d
--- /dev/null
+++ b/app/src/main/res/drawable/ic_encryption_errorred_24dp.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_middle_dot_24dp.xml b/app/src/main/res/drawable/ic_middle_dot_24dp.xml
new file mode 100644
index 000000000..f31a7057b
--- /dev/null
+++ b/app/src/main/res/drawable/ic_middle_dot_24dp.xml
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/app/src/main/res/layout/item_message_received.xml b/app/src/main/res/layout/item_message_received.xml
index 47b3d5a4d..502d07909 100644
--- a/app/src/main/res/layout/item_message_received.xml
+++ b/app/src/main/res/layout/item_message_received.xml
@@ -66,10 +66,38 @@
android:layout_marginStart="4sp"
android:src="@drawable/ic_lock_outline_24dp"
android:visibility="visible"
+ app:encryption="@{message.getEncryption()}"
+ app:layout_constraintBottom_toBottomOf="@+id/time"
+ app:layout_constraintStart_toEndOf="@+id/sender"
+ app:layout_constraintTop_toTopOf="@+id/time"
+ app:tint="?colorOnSurface" />
+
+
+ app:tint="?colorOnSurface"
+ tools:ignore="SmallSp" />
+
+