Show proper avatar for federated users in calls

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2024-08-28 08:32:37 +02:00 committed by Marcel Hibbe
parent 3b7c5e1d27
commit 0ff783ef0b
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 18 additions and 3 deletions

View File

@ -2517,10 +2517,12 @@ class CallActivity : CallBaseActivity() {
}
val defaultGuestNick = resources.getString(R.string.nc_nick_guest)
val participantDisplayItem = ParticipantDisplayItem(
context,
baseUrl,
defaultGuestNick,
rootEglBase,
videoStreamType,
roomToken,
callParticipantModel
)
val sessionId = callParticipantModel.sessionId

View File

@ -8,6 +8,7 @@
*/
package com.nextcloud.talk.adapters;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
@ -16,6 +17,7 @@ import com.nextcloud.talk.call.CallParticipantModel;
import com.nextcloud.talk.call.RaisedHand;
import com.nextcloud.talk.models.json.participants.Participant;
import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import org.webrtc.EglBase;
import org.webrtc.MediaStream;
@ -30,6 +32,8 @@ public class ParticipantDisplayItem {
private final ParticipantDisplayItemNotifier participantDisplayItemNotifier = new ParticipantDisplayItemNotifier();
private final Context context;
private final String baseUrl;
private final String defaultGuestNick;
private final EglBase rootEglBase;
@ -37,6 +41,8 @@ public class ParticipantDisplayItem {
private final String session;
private final String streamType;
private final String roomToken;
private final CallParticipantModel callParticipantModel;
private Participant.ActorType actorType;
@ -65,8 +71,10 @@ public class ParticipantDisplayItem {
}
};
public ParticipantDisplayItem(String baseUrl, String defaultGuestNick, EglBase rootEglBase, String streamType,
CallParticipantModel callParticipantModel) {
public ParticipantDisplayItem(Context context, String baseUrl, String defaultGuestNick, EglBase rootEglBase,
String streamType, String roomToken, CallParticipantModel callParticipantModel) {
this.context = context;
this.baseUrl = baseUrl;
this.defaultGuestNick = defaultGuestNick;
this.rootEglBase = rootEglBase;
@ -74,6 +82,8 @@ public class ParticipantDisplayItem {
this.session = callParticipantModel.getSessionId();
this.streamType = streamType;
this.roomToken = roomToken;
this.callParticipantModel = callParticipantModel;
this.callParticipantModel.addObserver(callParticipantModelObserver, handler);
@ -112,7 +122,10 @@ public class ParticipantDisplayItem {
}
private void updateUrlForAvatar() {
if (!TextUtils.isEmpty(userId)) {
if (actorType == Participant.ActorType.FEDERATED) {
int darkTheme = DisplayUtils.INSTANCE.isDarkModeOn(context) ? 1 : 0;
urlForAvatar = ApiUtils.getUrlForFederatedAvatar(baseUrl, roomToken, actorId, darkTheme, true);
} else if (!TextUtils.isEmpty(userId)) {
urlForAvatar = ApiUtils.getUrlForAvatar(baseUrl, userId, true);
} else {
urlForAvatar = ApiUtils.getUrlForGuestAvatar(baseUrl, getNick(), true);