mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
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>
This commit is contained in:
parent
783f09316f
commit
ed8ac14d94
@ -1914,23 +1914,35 @@ public class CallController extends BaseController {
|
|||||||
SimpleDraweeView avatarImageView = relativeLayout.findViewById(R.id.avatarImageView);
|
SimpleDraweeView avatarImageView = relativeLayout.findViewById(R.id.avatarImageView);
|
||||||
|
|
||||||
String userId;
|
String userId;
|
||||||
|
String displayName;
|
||||||
|
|
||||||
if (hasMCU) {
|
if (hasMCU) {
|
||||||
userId = webSocketClient.getUserIdForSession(session);
|
userId = webSocketClient.getUserIdForSession(session);
|
||||||
|
displayName = getPeerConnectionWrapperForSessionIdAndType(session, "video", false).getNick();
|
||||||
} else {
|
} else {
|
||||||
userId = participantMap.get(session).getUserId();
|
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) {
|
if (getActivity() != null) {
|
||||||
avatarImageView.setController(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()
|
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
||||||
.setOldController(avatarImageView.getController())
|
.setOldController(avatarImageView.getController())
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(baseUrl,
|
.setImageRequest(DisplayUtils.getImageRequestForUrl(urlForAvatar, null))
|
||||||
userId,
|
|
||||||
R.dimen.avatar_size_big), null))
|
|
||||||
.build();
|
.build();
|
||||||
avatarImageView.setController(draweeController);
|
avatarImageView.setController(draweeController);
|
||||||
}
|
}
|
||||||
@ -2032,13 +2044,17 @@ public class CallController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void gotNick(String sessionId, String nick, String type) {
|
private void gotNick(String sessionId, String nick, String type) {
|
||||||
sessionId += "+" + type;
|
String remoteRendererTag = sessionId + "+" + type;
|
||||||
|
|
||||||
if (relativeLayout != null) {
|
if (relativeLayout != null) {
|
||||||
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(remoteRendererTag);
|
||||||
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
|
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
|
||||||
if (!textView.getText().equals(nick)) {
|
if (!textView.getText().equals(nick)) {
|
||||||
textView.setText(nick);
|
textView.setText(nick);
|
||||||
|
|
||||||
|
if (getActivity() != null && type.equals("video")) {
|
||||||
|
getActivity().runOnUiThread(() -> setupAvatarForSession(sessionId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user