From dc530235726ff09b5108cc611b1d8b0aa16d619b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 25 Nov 2022 10:59:32 +0100 Subject: [PATCH] Update displayed nick when received in offers or answers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nick was displayed when updated through a data channel message, or when a ParticipantDisplayItem was created and the nick was already received. However, when the HPB is not used the nick is not sent after a connection is established, as it was sent already in the offer or answer. The nick from the offer or answer has not been received yet when the ParticipantDisplayItem is initially created, so the nick only appeared because a new ParticipantDisplayItem is created again when the connection is finally established. Due to all that the displayed nick is now updated as soon as it is received in an offer or answer, which ensures that the nick is shown independently of when was the ParticipantDisplayItem created. Note that this only applies to non-HPB scenarios; when the HPB is used the nick is got from the participant list update sent through signaling messages, so it is already known when creating the display item (in some very strange cases it might happen that an offer is received before the participant list was updated, but this should not happen, and in any case it will be handled at a later point). Signed-off-by: Daniel Calviño Sánchez --- .../talk/activities/CallActivity.java | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index bfcf198d0..13d48c75b 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -2018,7 +2018,7 @@ public class CallActivity extends CallBaseActivity { } if (!publisher && !hasExternalSignalingServer && offerAnswerNickProviders.get(sessionId) == null) { - OfferAnswerNickProvider offerAnswerNickProvider = new OfferAnswerNickProvider(); + OfferAnswerNickProvider offerAnswerNickProvider = new OfferAnswerNickProvider(sessionId); offerAnswerNickProviders.put(sessionId, offerAnswerNickProvider); signalingMessageReceiver.addListener(offerAnswerNickProvider.getVideoWebRtcMessageListener(), sessionId, "video"); signalingMessageReceiver.addListener(offerAnswerNickProvider.getScreenWebRtcMessageListener(), sessionId, "screen"); @@ -2570,18 +2570,18 @@ public class CallActivity extends CallBaseActivity { } } - private static class OfferAnswerNickProvider { + private class OfferAnswerNickProvider { private class WebRtcMessageListener implements SignalingMessageReceiver.WebRtcMessageListener { @Override public void onOffer(String sdp, String nick) { - (OfferAnswerNickProvider.this).nick = nick; + onOfferOrAnswer(nick); } @Override public void onAnswer(String sdp, String nick) { - (OfferAnswerNickProvider.this).nick = nick; + onOfferOrAnswer(nick); } @Override @@ -2596,8 +2596,31 @@ public class CallActivity extends CallBaseActivity { private final WebRtcMessageListener videoWebRtcMessageListener = new WebRtcMessageListener(); private final WebRtcMessageListener screenWebRtcMessageListener = new WebRtcMessageListener(); + private final String sessionId; + private String nick; + private OfferAnswerNickProvider(String sessionId) { + this.sessionId = sessionId; + } + + private void onOfferOrAnswer(String nick) { + this.nick = nick; + + boolean notifyDataSetChanged = false; + if (participantDisplayItems.get(sessionId + "-video") != null) { + participantDisplayItems.get(sessionId + "-video").setNick(nick); + notifyDataSetChanged = true; + } + if (participantDisplayItems.get(sessionId + "-screen") != null) { + participantDisplayItems.get(sessionId + "-screen").setNick(nick); + notifyDataSetChanged = true; + } + if (notifyDataSetChanged) { + participantsAdapter.notifyDataSetChanged(); + } + } + public WebRtcMessageListener getVideoWebRtcMessageListener() { return videoWebRtcMessageListener; }