From 3ee70b1d4834a7e805bd48fee0307bf8721ae29d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 3 Mar 2021 09:41:05 +0100 Subject: [PATCH] show verified shield in rtp session activity --- .../conversations/ui/RtpSessionActivity.java | 15 +++++++++++ .../xmpp/jingle/JingleRtpConnection.java | 10 ++++++++ src/main/res/layout/activity_rtp_session.xml | 25 ++++++++++--------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index fdd73f727..56839d501 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -389,6 +389,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe if (state != null) { Log.d(Config.LOGTAG, "restored last state from intent extra"); updateButtonConfiguration(state); + updateVerifiedShield(false); updateStateDisplay(state); updateProfilePicture(state); invalidateOptionsMenu(); @@ -558,6 +559,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } this.rtpConnectionReference = reference; final RtpEndUserState currentState = requireRtpConnection().getEndUserState(); + final boolean verified = requireRtpConnection().isVerified(); if (currentState == RtpEndUserState.ENDED) { reference.get().throwStateTransitionException(); finish(); @@ -573,6 +575,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe binding.with.setText(getWith().getDisplayName()); updateVideoViews(currentState); updateStateDisplay(currentState, media); + updateVerifiedShield(verified && STATES_SHOWING_SWITCH_TO_CHAT.contains(currentState)); updateButtonConfiguration(currentState, media); updateProfilePicture(currentState); invalidateOptionsMenu(); @@ -591,6 +594,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateStateDisplay(state); updateProfilePicture(state); updateCallDuration(); + updateVerifiedShield(false); invalidateOptionsMenu(); binding.with.setText(account.getRoster().getContact(with).getDisplayName()); } @@ -672,6 +676,14 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } } + private void updateVerifiedShield(final boolean verified) { + if (isPictureInPicture()) { + this.binding.verified.setVisibility(View.GONE); + return; + } + this.binding.verified.setVisibility(verified ? View.VISIBLE : View.GONE); + } + private void updateProfilePicture(final RtpEndUserState state) { updateProfilePicture(state, null); } @@ -1075,6 +1087,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe return; } final AbstractJingleConnection.Id id = requireRtpConnection().getId(); + final boolean verified = requireRtpConnection().isVerified(); final Set media = getMedia(); final Contact contact = getWith(); if (account == id.account && id.with.equals(with) && id.sessionId.equals(sessionId)) { @@ -1084,6 +1097,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } runOnUiThread(() -> { updateStateDisplay(state, media); + updateVerifiedShield(verified && STATES_SHOWING_SWITCH_TO_CHAT.contains(state)); updateButtonConfiguration(state, media); updateVideoViews(state); updateProfilePicture(state, contact); @@ -1133,6 +1147,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe } if (Jid.ofEscaped(withExtra).asBareJid().equals(with)) { runOnUiThread(() -> { + updateVerifiedShield(false); updateStateDisplay(state); updateButtonConfiguration(state); updateProfilePicture(state); diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java index 68e03f403..aff365247 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleRtpConnection.java @@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit; import eu.siacs.conversations.Config; import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.CryptoFailedException; +import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversational; @@ -967,6 +968,15 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web } + public boolean isVerified() { + final String fingerprint = this.omemoVerification.getFingerprint(); + if (fingerprint == null) { + return false; + } + final FingerprintStatus status = id.account.getAxolotlService().getFingerprintTrust(fingerprint); + return status != null && status.getTrust() == FingerprintStatus.Trust.VERIFIED; + } + public synchronized void acceptCall() { switch (this.state) { case PROPOSED: diff --git a/src/main/res/layout/activity_rtp_session.xml b/src/main/res/layout/activity_rtp_session.xml index ccc02259a..f54295866 100644 --- a/src/main/res/layout/activity_rtp_session.xml +++ b/src/main/res/layout/activity_rtp_session.xml @@ -86,17 +86,14 @@ - @@ -106,22 +103,31 @@ android:layout_height="match_parent" android:layout_below="@+id/app_bar_layout" android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" android:visibility="gone" /> + + + android:visibility="gone" + app:tint="@color/white" />