show verified shield in rtp session activity

This commit is contained in:
Daniel Gultsch 2021-03-03 09:41:05 +01:00
parent e4b2bb4a42
commit 3ee70b1d48
3 changed files with 38 additions and 12 deletions

View file

@ -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> 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);

View file

@ -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:

View file

@ -86,17 +86,14 @@
</RelativeLayout>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video"
android:layout_width="@dimen/local_video_preview_width"
android:layout_height="@dimen/local_video_preview_height"
android:layout_below="@+id/app_bar_layout"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="24dp"
android:layout_marginEnd="24dp"
android:layout_marginRight="24dp"
android:visibility="gone"
app:elevation="4dp" />
@ -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" />
<ImageView
android:id="@+id/verified"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/app_bar_layout"
android:layout_alignParentStart="true"
android:layout_marginTop="24dp"
android:layout_marginStart="16dp"
android:alpha="0.7"
android:src="@drawable/ic_verified_fingerprint" />
<ImageView
android:id="@+id/pip_local_mic_off_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
android:alpha="0.7"
android:src="@drawable/ic_mic_off_black_24dp"
android:tint="@color/white"
android:visibility="gone" />
android:visibility="gone"
app:tint="@color/white" />
<RelativeLayout
android:id="@+id/button_row"
@ -141,7 +147,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_margin="16dp"
android:src="@drawable/ic_call_end_white_48dp"
android:visibility="gone"
@ -156,7 +161,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="16dp"
android:src="@drawable/ic_call_white_48dp"
@ -176,7 +180,6 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toStartOf="@+id/end_call"
android:layout_toLeftOf="@+id/end_call"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"
@ -203,7 +206,6 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toEndOf="@+id/end_call"
android:layout_toRightOf="@+id/end_call"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"
@ -217,7 +219,6 @@
android:layout_centerVertical="true"
android:layout_margin="@dimen/in_call_fab_margin"
android:layout_toEndOf="@+id/in_call_action_right"
android:layout_toRightOf="@+id/in_call_action_right"
android:visibility="gone"
app:backgroundTint="?color_background_primary"
app:elevation="4dp"