mirror of
https://github.com/nextcloud/talk-android
synced 2025-01-31 11:32:00 +00:00
Merge commit 'e52b2d8b7ffbad4e4343bb6b97d40663ddc58149'
This commit is contained in:
commit
be1b075234
@ -93,9 +93,9 @@ import com.nextcloud.talk.utils.power.PowerManagerUtils;
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||
import com.nextcloud.talk.webrtc.MagicAudioManager;
|
||||
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
|
||||
import com.nextcloud.talk.webrtc.MagicWebRTCUtils;
|
||||
import com.nextcloud.talk.webrtc.MagicWebSocketInstance;
|
||||
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
|
||||
import com.nextcloud.talk.webrtc.WebSocketConnectionHelper;
|
||||
import com.wooplr.spotlight.SpotlightView;
|
||||
|
||||
@ -157,6 +157,12 @@ import me.zhanghai.android.effortlesspermissions.OpenAppDetailsDialogFragment;
|
||||
import okhttp3.Cache;
|
||||
import pub.devrel.easypermissions.AfterPermissionGranted;
|
||||
|
||||
import static com.nextcloud.talk.webrtc.Globals.JOB_ID;
|
||||
import static com.nextcloud.talk.webrtc.Globals.PARTICIPANTS_UPDATE;
|
||||
import static com.nextcloud.talk.webrtc.Globals.ROOM_TOKEN;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_ALL;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_IN_CALL;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class CallActivity extends CallBaseActivity {
|
||||
|
||||
@ -1479,13 +1485,35 @@ public class CallActivity extends CallBaseActivity {
|
||||
performCall();
|
||||
}
|
||||
break;
|
||||
case "participantsUpdate":
|
||||
case PARTICIPANTS_UPDATE:
|
||||
Log.d(TAG, "onMessageEvent 'participantsUpdate'");
|
||||
if (webSocketCommunicationEvent.getHashMap().get("roomToken").equals(roomToken)) {
|
||||
processUsersInRoom(
|
||||
(List<HashMap<String, Object>>) webSocketClient
|
||||
.getJobWithId(
|
||||
Integer.valueOf(webSocketCommunicationEvent.getHashMap().get("jobId"))));
|
||||
|
||||
// See MagicWebSocketInstance#onMessage in case "participants" how the 'updateParameters' are created
|
||||
Map<String, String> updateParameters = webSocketCommunicationEvent.getHashMap();
|
||||
|
||||
if (updateParameters == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
String updateRoomToken = updateParameters.get(ROOM_TOKEN);
|
||||
String updateAll = updateParameters.get(UPDATE_ALL);
|
||||
String updateInCall = updateParameters.get(UPDATE_IN_CALL);
|
||||
String jobId = updateParameters.get(JOB_ID);
|
||||
|
||||
if (roomToken.equals(updateRoomToken)) {
|
||||
if (updateAll != null && Boolean.parseBoolean(updateAll)) {
|
||||
if ("0".equals(updateInCall)) {
|
||||
Log.d(TAG, "Most probably a moderator ended the call for all.");
|
||||
hangup(true);
|
||||
}
|
||||
} else if (jobId != null) {
|
||||
// In that case a list of users for the room is passed.
|
||||
processUsersInRoom(
|
||||
(List<HashMap<String, Object>>) webSocketClient
|
||||
.getJobWithId(
|
||||
Integer.valueOf(jobId)));
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "signalingMessage":
|
||||
|
18
app/src/main/java/com/nextcloud/talk/webrtc/Globals.java
Normal file
18
app/src/main/java/com/nextcloud/talk/webrtc/Globals.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.nextcloud.talk.webrtc;
|
||||
|
||||
public class Globals {
|
||||
public static final String ROOM_TOKEN = "roomToken";
|
||||
public static final String JOB_ID = "jobId";
|
||||
|
||||
public static final String PARTICIPANTS_UPDATE = "participantsUpdate";
|
||||
|
||||
public static final String TARGET_PARTICIPANTS = "participants";
|
||||
|
||||
public static final String EVENT_TYPE = "type";
|
||||
public static final String EVENT_TYPE_UPDATE = "update";
|
||||
|
||||
public static final String UPDATE_ALL = "all";
|
||||
public static final String UPDATE_IN_CALL = "incall";
|
||||
public static final String UPDATE_ROOM_ID = "roomid";
|
||||
public static final String UPDATE_USERS = "users";
|
||||
}
|
@ -65,11 +65,22 @@ import okio.ByteString;
|
||||
|
||||
import static com.nextcloud.talk.models.json.participants.Participant.ActorType.GUESTS;
|
||||
import static com.nextcloud.talk.models.json.participants.Participant.ActorType.USERS;
|
||||
import static com.nextcloud.talk.webrtc.Globals.EVENT_TYPE;
|
||||
import static com.nextcloud.talk.webrtc.Globals.EVENT_TYPE_UPDATE;
|
||||
import static com.nextcloud.talk.webrtc.Globals.JOB_ID;
|
||||
import static com.nextcloud.talk.webrtc.Globals.PARTICIPANTS_UPDATE;
|
||||
import static com.nextcloud.talk.webrtc.Globals.ROOM_TOKEN;
|
||||
import static com.nextcloud.talk.webrtc.Globals.TARGET_PARTICIPANTS;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_ALL;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_IN_CALL;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_ROOM_ID;
|
||||
import static com.nextcloud.talk.webrtc.Globals.UPDATE_USERS;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class MagicWebSocketInstance extends WebSocketListener {
|
||||
private static final String TAG = "MagicWebSocketInstance";
|
||||
|
||||
|
||||
@Inject
|
||||
OkHttpClient okHttpClient;
|
||||
|
||||
@ -190,7 +201,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(currentRoomToken)) {
|
||||
helloHasHap.put("roomToken", currentRoomToken);
|
||||
helloHasHap.put(ROOM_TOKEN, currentRoomToken);
|
||||
}
|
||||
eventBus.post(new WebSocketCommunicationEvent("hello", helloHasHap));
|
||||
break;
|
||||
@ -221,23 +232,23 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
switch (target) {
|
||||
case "room":
|
||||
if (eventOverallWebSocketMessage.getEventMap().get("type").equals("message")) {
|
||||
Map<String, Object> messageHashMap =
|
||||
(Map<String, Object>) eventOverallWebSocketMessage.getEventMap().get("message");
|
||||
if (messageHashMap.containsKey("data")) {
|
||||
Map<String, Object> dataHashMap = (Map<String, Object>) messageHashMap.get(
|
||||
"data");
|
||||
if (dataHashMap.containsKey("chat")) {
|
||||
boolean shouldRefreshChat;
|
||||
Map<String, Object> chatMap = (Map<String, Object>) dataHashMap.get("chat");
|
||||
if (chatMap.containsKey("refresh")) {
|
||||
shouldRefreshChat = (boolean) chatMap.get("refresh");
|
||||
if (shouldRefreshChat) {
|
||||
HashMap<String, String> refreshChatHashMap = new HashMap<>();
|
||||
refreshChatHashMap.put(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), (String) messageHashMap.get("roomid"));
|
||||
refreshChatHashMap.put(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), Long.toString(conversationUser.getId()));
|
||||
eventBus.post(new WebSocketCommunicationEvent("refreshChat", refreshChatHashMap));
|
||||
}
|
||||
Map<String, Object> messageHashMap =
|
||||
(Map<String, Object>) eventOverallWebSocketMessage.getEventMap().get("message");
|
||||
if (messageHashMap.containsKey("data")) {
|
||||
Map<String, Object> dataHashMap = (Map<String, Object>) messageHashMap.get(
|
||||
"data");
|
||||
if (dataHashMap.containsKey("chat")) {
|
||||
boolean shouldRefreshChat;
|
||||
Map<String, Object> chatMap = (Map<String, Object>) dataHashMap.get("chat");
|
||||
if (chatMap.containsKey("refresh")) {
|
||||
shouldRefreshChat = (boolean) chatMap.get("refresh");
|
||||
if (shouldRefreshChat) {
|
||||
HashMap<String, String> refreshChatHashMap = new HashMap<>();
|
||||
refreshChatHashMap.put(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), (String) messageHashMap.get("roomid"));
|
||||
refreshChatHashMap.put(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), Long.toString(conversationUser.getId()));
|
||||
eventBus.post(new WebSocketCommunicationEvent("refreshChat", refreshChatHashMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (eventOverallWebSocketMessage.getEventMap().get("type").equals("join")) {
|
||||
@ -264,13 +275,45 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "participants":
|
||||
if (eventOverallWebSocketMessage.getEventMap().get("type").equals("update")) {
|
||||
case TARGET_PARTICIPANTS:
|
||||
if (EVENT_TYPE_UPDATE.equals(eventOverallWebSocketMessage.getEventMap().get(EVENT_TYPE))) {
|
||||
HashMap<String, String> refreshChatHashMap = new HashMap<>();
|
||||
HashMap<String, Object> updateEventMap = (HashMap<String, Object>) eventOverallWebSocketMessage.getEventMap().get("update");
|
||||
refreshChatHashMap.put("roomToken", (String) updateEventMap.get("roomid"));
|
||||
refreshChatHashMap.put("jobId", Integer.toString(magicMap.add(updateEventMap.get("users"))));
|
||||
eventBus.post(new WebSocketCommunicationEvent("participantsUpdate", refreshChatHashMap));
|
||||
HashMap<String, Object> updateEventMap = (HashMap<String, Object>) eventOverallWebSocketMessage.getEventMap().get(EVENT_TYPE_UPDATE);
|
||||
|
||||
if (updateEventMap == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (updateEventMap.containsKey(UPDATE_ROOM_ID)) {
|
||||
Object updateRoomId = updateEventMap.get(UPDATE_ROOM_ID);
|
||||
if (updateRoomId != null) {
|
||||
refreshChatHashMap.put(ROOM_TOKEN,
|
||||
(String) updateEventMap.get(UPDATE_ROOM_ID));
|
||||
}
|
||||
}
|
||||
|
||||
if (updateEventMap.containsKey(UPDATE_USERS)) {
|
||||
Object updateUsers = updateEventMap.get(UPDATE_USERS);
|
||||
if (updateUsers != null) {
|
||||
refreshChatHashMap.put(JOB_ID, Integer.toString(magicMap.add(updateUsers)));
|
||||
}
|
||||
}
|
||||
|
||||
if (updateEventMap.containsKey(UPDATE_IN_CALL)) {
|
||||
Object inCall = updateEventMap.get(UPDATE_IN_CALL);
|
||||
if (inCall != null) {
|
||||
refreshChatHashMap.put(UPDATE_IN_CALL, Long.toString((Long) inCall));
|
||||
}
|
||||
}
|
||||
|
||||
if (updateEventMap.containsKey(UPDATE_ALL)) {
|
||||
Object updateAll = updateEventMap.get(UPDATE_ALL);
|
||||
if (updateAll != null) {
|
||||
refreshChatHashMap.put(UPDATE_ALL, Boolean.toString((Boolean) updateAll));
|
||||
}
|
||||
}
|
||||
|
||||
eventBus.post(new WebSocketCommunicationEvent(PARTICIPANTS_UPDATE, refreshChatHashMap));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -285,7 +328,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
|
||||
if (!TextUtils.isEmpty(ncSignalingMessage.getFrom())) {
|
||||
HashMap<String, String> messageHashMap = new HashMap<>();
|
||||
messageHashMap.put("jobId", Integer.toString(magicMap.add(ncSignalingMessage)));
|
||||
messageHashMap.put(JOB_ID, Integer.toString(magicMap.add(ncSignalingMessage)));
|
||||
eventBus.post(new WebSocketCommunicationEvent("signalingMessage", messageHashMap));
|
||||
}
|
||||
break;
|
||||
@ -303,7 +346,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
|
||||
private void sendRoomJoinedEvent() {
|
||||
HashMap<String, String> joinRoomHashMap = new HashMap<>();
|
||||
joinRoomHashMap.put("roomToken", currentRoomToken);
|
||||
joinRoomHashMap.put(ROOM_TOKEN, currentRoomToken);
|
||||
eventBus.post(new WebSocketCommunicationEvent("roomJoined", joinRoomHashMap));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user