Skip to content

Commit

Permalink
Show proper avatar for federated users in calls
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Aug 28, 2024
1 parent 69530aa commit 986f459
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +17,7 @@
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;
Expand All @@ -30,13 +32,17 @@ 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;

private final String session;
private final String streamType;

private final String roomToken;

private final CallParticipantModel callParticipantModel;

private Participant.ActorType actorType;
Expand Down Expand Up @@ -65,15 +71,19 @@ public void onReaction(String reaction) {
}
};

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;

this.session = callParticipantModel.getSessionId();
this.streamType = streamType;

this.roomToken = roomToken;

this.callParticipantModel = callParticipantModel;
this.callParticipantModel.addObserver(callParticipantModelObserver, handler);

Expand Down Expand Up @@ -112,7 +122,10 @@ private void updateFromModel() {
}

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);
Expand Down

0 comments on commit 986f459

Please sign in to comment.