mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 17:08:34 +03:00
Fix nickname & fonts
This commit is contained in:
parent
a007af3db6
commit
98cabbfc11
20 changed files with 84 additions and 15 deletions
|
@ -132,6 +132,7 @@ import butterknife.OnClick;
|
|||
import butterknife.OnLongClick;
|
||||
import eu.davidea.flipview.FlipView;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.Scheduler;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
@ -247,6 +248,7 @@ public class CallController extends BaseController {
|
|||
private MagicWebSocketInstance webSocketClient;
|
||||
private WebSocketConnectionHelper webSocketConnectionHelper;
|
||||
private boolean hasMCU;
|
||||
private boolean hasExternalSignalingServer;
|
||||
|
||||
public CallController(Bundle args) {
|
||||
super(args);
|
||||
|
@ -921,11 +923,27 @@ public class CallController extends BaseController {
|
|||
if (signalingSettingsOverall != null && signalingSettingsOverall.getOcs() != null &&
|
||||
signalingSettingsOverall.getOcs().getSettings() != null) {
|
||||
|
||||
externalSignalingServer = new ExternalSignalingServer();
|
||||
|
||||
if (!TextUtils.isEmpty(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer()) &&
|
||||
!TextUtils.isEmpty(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket())) {
|
||||
externalSignalingServer = new ExternalSignalingServer();
|
||||
externalSignalingServer.setExternalSignalingServer(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingServer());
|
||||
externalSignalingServer.setExternalSignalingTicket(signalingSettingsOverall.getOcs().getSettings().getExternalSignalingTicket());
|
||||
hasExternalSignalingServer = true;
|
||||
} else {
|
||||
hasExternalSignalingServer = false;
|
||||
}
|
||||
|
||||
if (!conversationUser.getUserId().equals("?")) {
|
||||
try {
|
||||
userUtils.createOrUpdateUser(null, null, null, null, null, null, null,
|
||||
conversationUser.getId(), null, null, LoganSquare.serialize(externalSignalingServer))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribe();
|
||||
} catch (IOException exception) {
|
||||
Log.e(TAG, "Failed to serialize external signaling server");
|
||||
}
|
||||
}
|
||||
|
||||
if (signalingSettingsOverall.getOcs().getSettings().getStunServers() != null) {
|
||||
|
@ -1004,7 +1022,7 @@ public class CallController extends BaseController {
|
|||
.getCapabilities().getSpreedCapability()
|
||||
.getFeatures().contains("no-ping"));
|
||||
|
||||
if (externalSignalingServer == null) {
|
||||
if (!hasExternalSignalingServer) {
|
||||
joinRoomAndCall();
|
||||
} else {
|
||||
setupAndInitiateWebSocketsConnection();
|
||||
|
@ -1057,7 +1075,7 @@ public class CallController extends BaseController {
|
|||
}
|
||||
|
||||
private void callOrJoinRoomViaWebSocket() {
|
||||
if (externalSignalingServer == null) {
|
||||
if (!hasExternalSignalingServer) {
|
||||
performCall();
|
||||
} else {
|
||||
webSocketClient.joinRoomWithRoomTokenAndSession(roomToken, callSession);
|
||||
|
@ -1132,7 +1150,7 @@ public class CallController extends BaseController {
|
|||
|
||||
NotificationUtils.cancelExistingNotifications(getApplicationContext(), conversationUser);
|
||||
|
||||
if (externalSignalingServer == null) {
|
||||
if (!hasExternalSignalingServer) {
|
||||
ncApi.pullSignalingMessages(credentials, ApiUtils.getUrlForSignaling(baseUrl, urlToken))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -1379,7 +1397,7 @@ public class CallController extends BaseController {
|
|||
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
if (externalSignalingServer != null) {
|
||||
if (hasExternalSignalingServer) {
|
||||
webSocketClient.joinRoomWithRoomTokenAndSession("", "");
|
||||
}
|
||||
|
||||
|
@ -1480,7 +1498,7 @@ public class CallController extends BaseController {
|
|||
}
|
||||
|
||||
for (String sessionId : newSessions) {
|
||||
if (externalSignalingServer != null && webSocketClient.hasMCU()) {
|
||||
if (hasExternalSignalingServer && webSocketClient.hasMCU()) {
|
||||
if (!sessionId.equals(webSocketClient.getSessionId())) {
|
||||
alwaysGetPeerConnectionWrapperForSessionId(sessionId, false);
|
||||
|
||||
|
@ -1619,7 +1637,7 @@ public class CallController extends BaseController {
|
|||
}
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.NICK_CHANGE)) {
|
||||
gotNick(peerConnectionEvent.getSessionId(), peerConnectionEvent.getNick());
|
||||
gotNick(peerConnectionEvent.getSessionId(), peerConnectionEvent.getNick(), true);
|
||||
} else if (peerConnectionEvent.getPeerConnectionEventType().equals(PeerConnectionEvent
|
||||
.PeerConnectionEventType.VIDEO_CHANGE) && !isVoiceOnlyCall) {
|
||||
gotAudioOrVideoChange(true, peerConnectionEvent.getSessionId(),
|
||||
|
@ -1667,7 +1685,7 @@ public class CallController extends BaseController {
|
|||
ncMessageWrapper.setSignalingMessage(ncSignalingMessage);
|
||||
|
||||
|
||||
if (externalSignalingServer == null) {
|
||||
if (!hasExternalSignalingServer) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("{")
|
||||
.append("\"fn\":\"")
|
||||
|
@ -1836,7 +1854,12 @@ public class CallController extends BaseController {
|
|||
surfaceViewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT);
|
||||
surfaceViewRenderer.setOnClickListener(videoOnClickListener);
|
||||
remoteRenderersLayout.addView(relativeLayout);
|
||||
gotNick(session, getPeerConnectionWrapperForSessionId(session).getNick());
|
||||
if (hasExternalSignalingServer) {
|
||||
gotNick(session, webSocketClient.getDisplayNameForSession(session), false);
|
||||
} else {
|
||||
gotNick(session, getPeerConnectionWrapperForSessionId(session).getNick(), false);
|
||||
}
|
||||
|
||||
setupAvatarForSession(session);
|
||||
|
||||
callControls.setZ(100.0f);
|
||||
|
@ -1844,11 +1867,18 @@ public class CallController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
private void gotNick(String sessionId, String nick) {
|
||||
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
||||
private void gotNick(String sessionOrUserId, String nick, boolean isFromAnEvent) {
|
||||
if (isFromAnEvent && hasExternalSignalingServer) {
|
||||
// get session based on userId
|
||||
sessionOrUserId = webSocketClient.getSessionForUserId(sessionOrUserId);
|
||||
}
|
||||
|
||||
if (relativeLayout != null) {
|
||||
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionOrUserId);
|
||||
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
|
||||
textView.setText(nick);
|
||||
if (!textView.getText().equals(nick)) {
|
||||
textView.setText(nick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class DataChannelMessage {
|
|||
String type;
|
||||
|
||||
@JsonField(name = "payload")
|
||||
String payload;
|
||||
Object payload;
|
||||
|
||||
public DataChannelMessage(String type) {
|
||||
this.type = type;
|
||||
|
|
|
@ -233,10 +233,21 @@ public class MagicPeerConnectionWrapper {
|
|||
try {
|
||||
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
||||
|
||||
String internalNick;
|
||||
if ("nickChanged".equals(dataChannelMessage.getType())) {
|
||||
nick = dataChannelMessage.getPayload();
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.NICK_CHANGE, sessionId, nick, null));
|
||||
if (dataChannelMessage.getPayload() instanceof String) {
|
||||
internalNick = (String) dataChannelMessage.getPayload();
|
||||
if (!internalNick.equals(nick)) {
|
||||
setNick(nick);
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.NICK_CHANGE, sessionId, getNick(), null));
|
||||
}
|
||||
} else {
|
||||
HashMap<String, String> payloadHashMap = (HashMap<String, String>) dataChannelMessage.getPayload();
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.NICK_CHANGE, payloadHashMap.get("userid"), payloadHashMap.get("name"), null));
|
||||
}
|
||||
|
||||
} else if ("audioOn".equals(dataChannelMessage.getType())) {
|
||||
remoteAudioOn = true;
|
||||
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
|
|
|
@ -37,10 +37,13 @@ import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMes
|
|||
import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.utils.MagicMap;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -78,6 +81,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||
private boolean isPermanentlyClosed = false;
|
||||
private int restartCount = 0;
|
||||
|
||||
private HashMap<String, String> displayNameHashMap;
|
||||
private HashMap<String, String> userIdSesssionHashMap;
|
||||
|
||||
MagicWebSocketInstance(UserEntity conversationUser, String connectionUrl, String webSocketTicket) {
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
|
@ -85,6 +91,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||
this.conversationUser = conversationUser;
|
||||
this.webSocketTicket = webSocketTicket;
|
||||
this.webSocketConnectionHelper = new WebSocketConnectionHelper();
|
||||
this.displayNameHashMap = new HashMap<>();
|
||||
magicMap = new MagicMap();
|
||||
|
||||
restartWebSocket();
|
||||
|
@ -166,6 +173,15 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (eventOverallWebSocketMessage.getEventMap().get("type").equals("join")) {
|
||||
List<HashMap<String, Object>> joinEventMap = (List<HashMap<String, Object>>) eventOverallWebSocketMessage.getEventMap().get("join");
|
||||
HashMap<String, Object> internalHashMap;
|
||||
for (int i = 0; i < joinEventMap.size(); i++) {
|
||||
internalHashMap = joinEventMap.get(i);
|
||||
HashMap<String, Object> userMap = (HashMap<String, Object>) internalHashMap.get("user");
|
||||
displayNameHashMap.put((String) internalHashMap.get("sessionid"), (String) userMap.get("displayname"));
|
||||
userIdSesssionHashMap.put((String) internalHashMap.get("userid"), (String) internalHashMap.get("sessionid"));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "participants":
|
||||
|
@ -291,4 +307,16 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
|||
boolean isPermanentlyClosed() {
|
||||
return isPermanentlyClosed;
|
||||
}
|
||||
|
||||
public String getDisplayNameForSession(String session) {
|
||||
if (displayNameHashMap.containsKey(session)) {
|
||||
return displayNameHashMap.get(session);
|
||||
}
|
||||
|
||||
return NextcloudTalkApplication.getSharedApplication().getString(R.string.nc_nick_guest);
|
||||
}
|
||||
|
||||
public String getSessionForUserId(String userId) {
|
||||
return userIdSesssionHashMap.get(userId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue