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