get recording status by signaling

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-01-19 08:50:42 +01:00
parent 4834afaf7e
commit 1aafc9989d
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
3 changed files with 40 additions and 20 deletions

View File

@ -98,6 +98,7 @@ import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import com.nextcloud.talk.utils.NotificationUtils;
import com.nextcloud.talk.utils.animations.PulseAnimation;
import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew;
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil;
import com.nextcloud.talk.utils.power.PowerManagerUtils;
@ -1674,6 +1675,7 @@ public class CallActivity extends CallBaseActivity {
return;
}
if (webSocketCommunicationEvent.getHashMap() != null) {
switch (webSocketCommunicationEvent.getType()) {
case "hello":
Log.d(TAG, "onMessageEvent 'hello'");
@ -1694,6 +1696,21 @@ public class CallActivity extends CallBaseActivity {
performCall();
}
break;
case "recordingStatus":
Log.d(TAG, "onMessageEvent 'recordingStatus'");
if (webSocketCommunicationEvent.getHashMap().containsKey(BundleKeys.KEY_RECORDING_STATE)) {
String recordingStateString =
webSocketCommunicationEvent.getHashMap().get(BundleKeys.KEY_RECORDING_STATE);
if (recordingStateString != null) {
runOnUiThread(() -> {
callRecordingViewModel.setRecordingState(Integer.parseInt(recordingStateString));
});
}
}
break;
}
}
}

View File

@ -108,6 +108,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
when (state) {
0 -> _viewState.value = RecordingStoppedState
1 -> _viewState.value = RecordingStartedState
2 -> _viewState.value = RecordingStartedState
else -> {}
}
}

View File

@ -266,13 +266,15 @@ public class MagicWebSocketInstance extends WebSocketListener {
refreshChatHashMap.put(BundleKeys.KEY_INTERNAL_USER_ID, Long.toString(conversationUser.getId()));
eventBus.post(new WebSocketCommunicationEvent("refreshChat", refreshChatHashMap));
}
} else if (dataHashMap.containsKey("recording")) {
} else if (dataHashMap != null && dataHashMap.containsKey("recording")) {
Map<String, Object> recordingMap = (Map<String, Object>) dataHashMap.get("recording");
if (recordingMap != null && recordingMap.containsKey("status")) {
int status = ((Long) recordingMap.get("status")).intValue();
Log.d(TAG, "status is " + status);
// TODO: inform ChatController about state (after Daniels PRs are merged..)
HashMap<String, String> recordingHashMap = new HashMap<>();
recordingHashMap.put(BundleKeys.KEY_RECORDING_STATE, Integer.toString(status));
eventBus.post(new WebSocketCommunicationEvent("recordingStatus", recordingHashMap));
}
}
}