mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
"chat-v2" capability is available since Nextcloud 13
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
dab9a7c860
commit
172d8da1cf
@ -25,7 +25,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.provider.ContactsContract
|
||||
import android.text.TextUtils
|
||||
import android.view.ViewGroup
|
||||
@ -244,51 +243,38 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
.subscribe(object : Observer<RoomOverall> {
|
||||
override fun onSubscribe(d: Disposable) {}
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
val conversationIntent = Intent(context, MagicCallActivity::class.java)
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable(KEY_USER_ENTITY, currentUser)
|
||||
bundle.putString(KEY_ROOM_TOKEN, roomOverall.ocs.data.token)
|
||||
bundle.putString(KEY_ROOM_ID, roomOverall.ocs.data.roomId)
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
// FIXME once APIv2 or later is used only, the createRoom already returns all the data
|
||||
ncApi.getRoom(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoom(
|
||||
apiVersion,
|
||||
currentUser.baseUrl,
|
||||
roomOverall.ocs.data.token
|
||||
)
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<RoomOverall> {
|
||||
override fun onSubscribe(d: Disposable) {}
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
bundle.putParcelable(
|
||||
KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs.data)
|
||||
)
|
||||
remapChatController(
|
||||
router!!, currentUser.id,
|
||||
roomOverall.ocs.data.token, bundle, true
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {}
|
||||
override fun onComplete() {}
|
||||
})
|
||||
} else {
|
||||
conversationIntent.putExtras(bundle)
|
||||
startActivity(conversationIntent)
|
||||
Handler().postDelayed(
|
||||
{
|
||||
if (!isDestroyed) {
|
||||
router!!.popCurrentController()
|
||||
}
|
||||
},
|
||||
100
|
||||
// FIXME once APIv2 or later is used only, the createRoom already returns all the data
|
||||
ncApi.getRoom(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRoom(
|
||||
apiVersion,
|
||||
currentUser.baseUrl,
|
||||
roomOverall.ocs.data.token
|
||||
)
|
||||
}
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(object : Observer<RoomOverall> {
|
||||
override fun onSubscribe(d: Disposable) {}
|
||||
override fun onNext(roomOverall: RoomOverall) {
|
||||
bundle.putParcelable(
|
||||
KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs.data)
|
||||
)
|
||||
remapChatController(
|
||||
router!!, currentUser.id,
|
||||
roomOverall.ocs.data.token, bundle, true
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {}
|
||||
override fun onComplete() {}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {}
|
||||
|
@ -1777,18 +1777,16 @@ class ChatController(args: Bundle) :
|
||||
bundle.putString(BundleKeys.KEY_ROOM_ID, roomOverall.ocs.data.roomId)
|
||||
|
||||
if (conversationUser != null) {
|
||||
if (conversationUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
bundle.putParcelable(
|
||||
BundleKeys.KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs.data)
|
||||
)
|
||||
conversationIntent.putExtras(bundle)
|
||||
bundle.putParcelable(
|
||||
BundleKeys.KEY_ACTIVE_CONVERSATION,
|
||||
Parcels.wrap(roomOverall.ocs.data)
|
||||
)
|
||||
conversationIntent.putExtras(bundle)
|
||||
|
||||
ConductorRemapping.remapChatController(
|
||||
router, conversationUser.id,
|
||||
roomOverall.ocs.data.token, bundle, false
|
||||
)
|
||||
}
|
||||
ConductorRemapping.remapChatController(
|
||||
router, conversationUser.id,
|
||||
roomOverall.ocs.data.token, bundle, false
|
||||
)
|
||||
} else {
|
||||
conversationIntent.putExtras(bundle)
|
||||
startActivity(conversationIntent)
|
||||
|
@ -308,57 +308,43 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOverall roomOverall) {
|
||||
Intent conversationIntent = new Intent(getActivity(), MagicCallActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY(), currentUser);
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_TOKEN(), roomOverall.getOcs().getData().getToken());
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
|
||||
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
// FIXME once APIv2 or later is used only, the createRoom already returns all the data
|
||||
ncApi.getRoom(credentials,
|
||||
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||
roomOverall.getOcs().getData().getToken()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoomOverall>() {
|
||||
// FIXME once APIv2 or later is used only, the createRoom already returns all the data
|
||||
ncApi.getRoom(credentials,
|
||||
ApiUtils.getUrlForRoom(apiVersion, currentUser.getBaseUrl(),
|
||||
roomOverall.getOcs().getData().getToken()))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoomOverall>() {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOverall roomOverall) {
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
roomOverall.getOcs().getData().getToken(), bundle, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
conversationIntent.putExtras(bundle);
|
||||
startActivity(conversationIntent);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isDestroyed() && !isBeingDestroyed()) {
|
||||
getRouter().popCurrentController();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomOverall roomOverall) {
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
roomOverall.getOcs().getData().getToken(), bundle, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -885,16 +871,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
||||
bundle.putString(BundleKeys.INSTANCE.getKEY_ROOM_ID(), roomOverall.getOcs().getData().getRoomId());
|
||||
conversationIntent.putExtras(bundle);
|
||||
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(),
|
||||
Parcels.wrap(roomOverall.getOcs().getData()));
|
||||
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
roomOverall.getOcs().getData().getToken(), bundle, true);
|
||||
} else {
|
||||
startActivity(conversationIntent);
|
||||
new Handler().postDelayed(() -> getRouter().popCurrentController(), 100);
|
||||
}
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
roomOverall.getOcs().getData().getToken(), bundle, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -736,17 +736,9 @@ public class ConversationsListController extends BaseController implements Searc
|
||||
} else {
|
||||
currentUser = userUtils.getCurrentUser();
|
||||
|
||||
if (currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), Parcels.wrap(conversation));
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
conversation.getToken(), bundle, false);
|
||||
} else {
|
||||
overridePushHandler(new NoOpControllerChangeHandler());
|
||||
overridePopHandler(new NoOpControllerChangeHandler());
|
||||
Intent callIntent = new Intent(getActivity(), MagicCallActivity.class);
|
||||
callIntent.putExtras(bundle);
|
||||
startActivity(callIntent);
|
||||
}
|
||||
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_ACTIVE_CONVERSATION(), Parcels.wrap(conversation));
|
||||
ConductorRemapping.INSTANCE.remapChatController(getRouter(), currentUser.getId(),
|
||||
conversation.getToken(), bundle, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,6 +448,8 @@ public class OperationsMenuController extends BaseController {
|
||||
|
||||
@Override
|
||||
public void onNext(CapabilitiesOverall capabilitiesOverall) {
|
||||
// Guest checking the capabilities so there is no global server EOL warning until here.
|
||||
// FIXME check the serverEOL capabilities instead
|
||||
if (capabilitiesOverall.getOcs().getData()
|
||||
.getCapabilities().getSpreedCapability() != null &&
|
||||
capabilitiesOverall.getOcs().getData()
|
||||
@ -471,14 +473,6 @@ public class OperationsMenuController extends BaseController {
|
||||
initiateConversation(false, capabilitiesOverall.getOcs().getData()
|
||||
.getCapabilities());
|
||||
}
|
||||
} 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 {
|
||||
showResultImage(false, true);
|
||||
}
|
||||
@ -590,11 +584,7 @@ public class OperationsMenuController extends BaseController {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!currentUser.hasSpreedFeatureCapability("chat-v2")) {
|
||||
showResultImage(true, false);
|
||||
} else {
|
||||
initiateConversation(true, null);
|
||||
}
|
||||
initiateConversation(true, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,6 +595,8 @@ public class OperationsMenuController extends BaseController {
|
||||
|
||||
if (baseUrl != null && !baseUrl.equals(currentUser.getBaseUrl())) {
|
||||
isGuestUser = true;
|
||||
// Guest checking the capabilities so there is no global server EOL warning until here.
|
||||
// FIXME check the serverEOL capabilities instead
|
||||
hasChatCapability = capabilities != null && capabilities.getSpreedCapability() != null && capabilities.getSpreedCapability().getFeatures() != null && capabilities.getSpreedCapability().getFeatures().contains("chat-v2");
|
||||
} else {
|
||||
hasChatCapability = currentUser.hasSpreedFeatureCapability("chat-v2");
|
||||
|
@ -598,9 +598,6 @@ public class NotificationWorker extends Worker {
|
||||
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
||||
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
||||
|
||||
boolean hasChatSupport = signatureVerification.getUserEntity().
|
||||
hasSpreedFeatureCapability("chat-v2");
|
||||
|
||||
boolean shouldShowNotification = decryptedPushMessage.getApp().equals("spreed");
|
||||
|
||||
if (shouldShowNotification) {
|
||||
@ -608,7 +605,7 @@ public class NotificationWorker extends Worker {
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
|
||||
boolean startACall = decryptedPushMessage.getType().equals("call") || !hasChatSupport;
|
||||
boolean startACall = decryptedPushMessage.getType().equals("call");
|
||||
if (startACall) {
|
||||
intent = new Intent(context, MagicCallActivity.class);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user