mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 06:44:09 +01:00
Fix calls
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
919e349ac9
commit
b984eea07a
@ -91,7 +91,6 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -382,9 +381,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(CallOverall callOverall) {
|
public void onNext(CallOverall callOverall) {
|
||||||
inChat = true;
|
inChat = true;
|
||||||
|
currentCall = callOverall.getOcs().getData();
|
||||||
startPing();
|
startPing();
|
||||||
pullChatMessages(0);
|
pullChatMessages(0);
|
||||||
currentCall = callOverall.getOcs().getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -410,8 +409,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
fieldMap.put("actorDisplayName", conversationUser.getDisplayName());
|
fieldMap.put("actorDisplayName", conversationUser.getDisplayName());
|
||||||
|
|
||||||
|
|
||||||
ncApi.sendChatMessage(ApiUtils.getCredentials(conversationUser.getUserId(), conversationUser.getToken()),
|
ncApi.sendChatMessage(credentials, ApiUtils.getUrlForChat(baseUrl, roomToken), fieldMap)
|
||||||
ApiUtils.getUrlForChat(conversationUser.getBaseUrl(), roomToken), fieldMap)
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(3, observable -> inChat)
|
.retry(3, observable -> inChat)
|
||||||
@ -492,8 +490,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lookIntoFuture == 1) {
|
if (lookIntoFuture == 1) {
|
||||||
ncApi.pullChatMessages(ApiUtils.getCredentials(conversationUser.getUserId(), conversationUser.getToken()),
|
ncApi.pullChatMessages(credentials, ApiUtils.getUrlForChat(baseUrl, roomToken), fieldMap)
|
||||||
ApiUtils.getUrlForChat(conversationUser.getBaseUrl(), roomToken), fieldMap)
|
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.takeWhile(observable -> inChat)
|
.takeWhile(observable -> inChat)
|
||||||
@ -521,8 +518,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ncApi.pullChatMessages(ApiUtils.getCredentials(conversationUser.getUserId(), conversationUser.getToken()),
|
ncApi.pullChatMessages(credentials,
|
||||||
ApiUtils.getUrlForChat(conversationUser.getBaseUrl(), roomToken), fieldMap)
|
ApiUtils.getUrlForChat(baseUrl, roomToken), fieldMap)
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(3, observable -> inChat)
|
.retry(3, observable -> inChat)
|
||||||
@ -652,10 +649,16 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.conversation_video_call:
|
case R.id.conversation_video_call:
|
||||||
startActivity(Objects.requireNonNull(getIntentForCall(false)));
|
Intent videoCallIntent = getIntentForCall(false);
|
||||||
|
if (videoCallIntent != null) {
|
||||||
|
startActivity(videoCallIntent);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.conversation_voice_call:
|
case R.id.conversation_voice_call:
|
||||||
startActivity(Objects.requireNonNull(getIntentForCall(true)));
|
Intent voiceCallIntent = getIntentForCall(true);
|
||||||
|
if (voiceCallIntent != null) {
|
||||||
|
startActivity(voiceCallIntent);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -669,6 +672,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
|
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomToken);
|
||||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(conversationUser));
|
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(conversationUser));
|
||||||
bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
|
bundle.putString(BundleKeys.KEY_CALL_SESSION, currentCall.getSessionId());
|
||||||
|
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
||||||
|
|
||||||
if (isVoiceOnlyCall) {
|
if (isVoiceOnlyCall) {
|
||||||
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
|
bundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
|
||||||
|
@ -46,6 +46,7 @@ import com.nextcloud.talk.controllers.base.BaseController;
|
|||||||
import com.nextcloud.talk.events.BottomSheetLockEvent;
|
import com.nextcloud.talk.events.BottomSheetLockEvent;
|
||||||
import com.nextcloud.talk.models.RetrofitBucket;
|
import com.nextcloud.talk.models.RetrofitBucket;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
|
import com.nextcloud.talk.models.json.call.Call;
|
||||||
import com.nextcloud.talk.models.json.call.CallOverall;
|
import com.nextcloud.talk.models.json.call.CallOverall;
|
||||||
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
||||||
import com.nextcloud.talk.models.json.generic.GenericOverall;
|
import com.nextcloud.talk.models.json.generic.GenericOverall;
|
||||||
@ -108,7 +109,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
private String callUrl;
|
private String callUrl;
|
||||||
|
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
private String callSession;
|
private Call call;
|
||||||
private String conversationToken;
|
private String conversationToken;
|
||||||
|
|
||||||
private Disposable disposable;
|
private Disposable disposable;
|
||||||
@ -427,7 +428,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
.getCapabilities().getSpreedCapability()
|
.getCapabilities().getSpreedCapability()
|
||||||
.getFeatures() != null && capabilitiesOverall.getOcs().getData()
|
.getFeatures() != null && capabilitiesOverall.getOcs().getData()
|
||||||
.getCapabilities().getSpreedCapability()
|
.getCapabilities().getSpreedCapability()
|
||||||
.getFeatures().contains("guest-signaling")) {
|
.getFeatures().contains("chat-v2")) {
|
||||||
if (room.isHasPassword() && room.isGuest()) {
|
if (room.isHasPassword() && room.isGuest()) {
|
||||||
eventBus.post(new BottomSheetLockEvent(true, 0,
|
eventBus.post(new BottomSheetLockEvent(true, 0,
|
||||||
true, false));
|
true, false));
|
||||||
@ -439,8 +440,16 @@ public class OperationsMenuController extends BaseController {
|
|||||||
.pushChangeHandler(new HorizontalChangeHandler())
|
.pushChangeHandler(new HorizontalChangeHandler())
|
||||||
.popChangeHandler(new HorizontalChangeHandler()));
|
.popChangeHandler(new HorizontalChangeHandler()));
|
||||||
} else {
|
} else {
|
||||||
initiateCall();
|
initiateConversation(true);
|
||||||
}
|
}
|
||||||
|
} else if (capabilitiesOverall.getOcs().getData()
|
||||||
|
.getCapabilities().getSpreedCapability() != null &&
|
||||||
|
capabilitiesOverall.getOcs().getData()
|
||||||
|
.getCapabilities().getSpreedCapability()
|
||||||
|
.getFeatures() != null && capabilitiesOverall.getOcs().getData()
|
||||||
|
.getCapabilities().getSpreedCapability()
|
||||||
|
.getFeatures().contains("guest-signaling")) {
|
||||||
|
initiateCall();
|
||||||
} else {
|
} else {
|
||||||
showResultImage(false, true);
|
showResultImage(false, true);
|
||||||
}
|
}
|
||||||
@ -494,24 +503,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (localInvitedUsers.size() == 0) {
|
if (localInvitedUsers.size() == 0) {
|
||||||
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
initiateConversation(false);
|
||||||
eventBus.post(new BottomSheetLockEvent(true, 0,
|
|
||||||
true, true, false));
|
|
||||||
|
|
||||||
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
|
|
||||||
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME, room.getDisplayName());
|
|
||||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
|
||||||
conversationIntent.putExtras(bundle);
|
|
||||||
getParentController().getRouter().pushController((RouterTransaction.with(
|
|
||||||
new ChatController(bundle)).pushChangeHandler(
|
|
||||||
new HorizontalChangeHandler())
|
|
||||||
.popChangeHandler(new HorizontalChangeHandler())));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
initiateCall();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
@ -522,6 +514,34 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initiateConversation(boolean dismissView) {
|
||||||
|
if (currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||||
|
eventBus.post(new BottomSheetLockEvent(true, 0,
|
||||||
|
true, true, dismissView));
|
||||||
|
|
||||||
|
Intent conversationIntent = new Intent(getActivity(), CallActivity.class);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, room.getToken());
|
||||||
|
bundle.putString(BundleKeys.KEY_CONVERSATION_NAME, room.getDisplayName());
|
||||||
|
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(currentUser));
|
||||||
|
if (baseUrl != null && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||||
|
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(call));
|
||||||
|
|
||||||
|
conversationIntent.putExtras(bundle);
|
||||||
|
getParentController().getParentController().getRouter().pushController((RouterTransaction.with(
|
||||||
|
new ChatController(bundle)).pushChangeHandler(
|
||||||
|
new HorizontalChangeHandler())
|
||||||
|
.popChangeHandler(new HorizontalChangeHandler())));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
initiateCall();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initiateCall() {
|
private void initiateCall() {
|
||||||
eventBus.post(new BottomSheetLockEvent(true, 0, true, true));
|
eventBus.post(new BottomSheetLockEvent(true, 0, true, true));
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
@ -530,7 +550,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
if (baseUrl != null && !baseUrl.equals(currentUser.getBaseUrl())) {
|
if (baseUrl != null && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||||
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
bundle.putString(BundleKeys.KEY_MODIFIED_BASE_URL, baseUrl);
|
||||||
}
|
}
|
||||||
bundle.putString(BundleKeys.KEY_CALL_SESSION, callSession);
|
bundle.putParcelable(BundleKeys.KEY_ACTIVE_CONVERSATION, Parcels.wrap(call));
|
||||||
|
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
|
|
||||||
@ -561,8 +581,8 @@ public class OperationsMenuController extends BaseController {
|
|||||||
showResultImage(true, false);
|
showResultImage(true, false);
|
||||||
} else {
|
} else {
|
||||||
CallOverall callOverall = (CallOverall) o;
|
CallOverall callOverall = (CallOverall) o;
|
||||||
callSession = callOverall.getOcs().getData().getSessionId();
|
call = callOverall.getOcs().getData();
|
||||||
initiateCall();
|
initiateConversation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user