Эх сурвалжийг харах

Show avatar for guests in call view

The avatar of guests is based on their display name/nick.

When the HPB is not used the nick is provided in the offer/answer
signaling messages, and later updated through data channel messages when
it changes. When the HPB is used the nick is periodically sent through
data channel messages. Therefore the avatar is based on the nick set in
the peer connection and reloaded when the nick changes (although it is
currently a bit hacky and brittle, as it is based on whether the nick
shown in the text view changed rather than whether the nick itself
changed, but it works nevertheless).

Note that currently it is required that the guest has a peer connection
to know its nick and, therefore, its avatar; some changes would be
needed in the clients to also send the nick when there is no peer
connection.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Daniel Calviño Sánchez 4 жил өмнө
parent
commit
ed8ac14d94

+ 22 - 6
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -1914,23 +1914,35 @@ public class CallController extends BaseController {
                 SimpleDraweeView avatarImageView = relativeLayout.findViewById(R.id.avatarImageView);
 
                 String userId;
+                String displayName;
 
                 if (hasMCU) {
                     userId = webSocketClient.getUserIdForSession(session);
+                    displayName = getPeerConnectionWrapperForSessionIdAndType(session, "video", false).getNick();
                 } else {
                     userId = participantMap.get(session).getUserId();
+                    displayName = getPeerConnectionWrapperForSessionIdAndType(session, "video", false).getNick();
                 }
 
-                if (!TextUtils.isEmpty(userId)) {
+                if (!TextUtils.isEmpty(userId) || !TextUtils.isEmpty(displayName)) {
 
                     if (getActivity() != null) {
                         avatarImageView.setController(null);
 
+                        String urlForAvatar;
+                        if (!TextUtils.isEmpty(userId)) {
+                            urlForAvatar = ApiUtils.getUrlForAvatarWithName(baseUrl,
+                                    userId,
+                                    R.dimen.avatar_size_big);
+                        } else {
+                            urlForAvatar = ApiUtils.getUrlForAvatarWithNameForGuests(baseUrl,
+                                    displayName,
+                                    R.dimen.avatar_size_big);
+                        }
+
                         DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                                 .setOldController(avatarImageView.getController())
-                                .setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(baseUrl,
-                                        userId,
-                                        R.dimen.avatar_size_big), null))
+                                .setImageRequest(DisplayUtils.getImageRequestForUrl(urlForAvatar, null))
                                 .build();
                         avatarImageView.setController(draweeController);
                     }
@@ -2032,13 +2044,17 @@ public class CallController extends BaseController {
     }
 
     private void gotNick(String sessionId, String nick, String type) {
-        sessionId += "+" + type;
+        String remoteRendererTag = sessionId + "+" + type;
 
         if (relativeLayout != null) {
-            RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
+            RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(remoteRendererTag);
             TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
             if (!textView.getText().equals(nick)) {
                 textView.setText(nick);
+
+                if (getActivity() != null && type.equals("video")) {
+                    getActivity().runOnUiThread(() -> setupAvatarForSession(sessionId));
+                }
             }
         }
     }