Skip to content

Commit

Permalink
pass spreedCapabilities instead user to CapabilitiesUtilNew
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
  • Loading branch information
mahibi committed Feb 28, 2024
1 parent c79def1 commit 7859a08
Show file tree
Hide file tree
Showing 86 changed files with 1,467 additions and 1,306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class AccountVerificationActivity : BaseActivity() {
val credentials = ApiUtils.getCredentials(username, token)
cookieManager.cookieStore.removeAll()

ncApi.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl))
ncApi.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl!!))
.subscribeOn(Schedulers.io())
.subscribe(object : Observer<CapabilitiesOverall> {
override fun onSubscribe(d: Disposable) {
Expand All @@ -213,7 +213,7 @@ class AccountVerificationActivity : BaseActivity() {
capabilitiesOverall.ocs!!.data!!.capabilities!!.spreedCapability!!.features != null &&
!capabilitiesOverall.ocs!!.data!!.capabilities!!.spreedCapability!!.features!!.isEmpty()
if (hasTalk) {
fetchProfile(credentials, capabilitiesOverall)
fetchProfile(credentials!!, capabilitiesOverall)
} else {
if (resources != null) {
runOnUiThread {
Expand Down Expand Up @@ -305,7 +305,7 @@ class AccountVerificationActivity : BaseActivity() {
private fun fetchProfile(credentials: String, capabilitiesOverall: CapabilitiesOverall) {
ncApi.getUserProfile(
credentials,
ApiUtils.getUrlForUserProfile(baseUrl)
ApiUtils.getUrlForUserProfile(baseUrl!!)
)
.subscribeOn(Schedulers.io())
.subscribe(object : Observer<UserProfileOverall> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import com.nextcloud.talk.utils.UriUtils
import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ADDITIONAL_ACCOUNT
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_ACCOUNT_IMPORT
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
Expand Down Expand Up @@ -336,7 +336,7 @@ class ServerSelectionActivity : BaseActivity() {

if (hasTalk) {
runOnUiThread {
if (CapabilitiesUtilNew.isServerEOL(capabilities)) {
if (CapabilitiesUtil.isServerEOL(capabilities)) {
if (resources != null) {
runOnUiThread {
setErrorText(resources!!.getString(R.string.nc_settings_server_eol))
Expand Down
39 changes: 21 additions & 18 deletions app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.isCallRecordingAvailable
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.CapabilitiesUtil.isCallRecordingAvailable
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
import com.nextcloud.talk.utils.power.PowerManagerUtils
Expand Down Expand Up @@ -234,7 +234,7 @@ class CallActivity : CallBaseActivity() {
private var iceServers: MutableList<PeerConnection.IceServer>? = null
private var cameraEnumerator: CameraEnumerator? = null
private var roomToken: String? = null
var conversationUser: User? = null
lateinit var conversationUser: User
private var conversationName: String? = null
private var callSession: String? = null
private var localStream: MediaStream? = null
Expand Down Expand Up @@ -530,12 +530,12 @@ class CallActivity : CallBaseActivity() {
)
}

when (CapabilitiesUtilNew.getRecordingConsentType(conversationUser)) {
CapabilitiesUtilNew.RECORDING_CONSENT_NOT_REQUIRED -> initiateCall()
CapabilitiesUtilNew.RECORDING_CONSENT_REQUIRED -> askForRecordingConsent()
CapabilitiesUtilNew.RECORDING_CONSENT_DEPEND_ON_CONVERSATION -> {
when (CapabilitiesUtil.getRecordingConsentType(conversationUser!!.capabilities!!.spreedCapability!!)) {
CapabilitiesUtil.RECORDING_CONSENT_NOT_REQUIRED -> initiateCall()
CapabilitiesUtil.RECORDING_CONSENT_REQUIRED -> askForRecordingConsent()
CapabilitiesUtil.RECORDING_CONSENT_DEPEND_ON_CONVERSATION -> {
val getRoomApiVersion = ApiUtils.getConversationApiVersion(
conversationUser,
conversationUser!!,
intArrayOf(ApiUtils.APIv4, 1)
)
ncApi!!.getRoom(credentials, ApiUtils.getUrlForRoom(getRoomApiVersion, baseUrl, roomToken))
Expand Down Expand Up @@ -571,7 +571,7 @@ class CallActivity : CallBaseActivity() {

override fun onResume() {
super.onResume()
if (hasSpreedFeatureCapability(conversationUser, "recording-v1") &&
if (hasSpreedFeatureCapability(conversationUser!!.capabilities!!.spreedCapability!!, "recording-v1") &&
othersInCall &&
elapsedSeconds.toInt() >= CALL_TIME_ONE_HOUR
) {
Expand Down Expand Up @@ -1564,7 +1564,7 @@ class CallActivity : CallBaseActivity() {
}

private fun checkCapabilities() {
ncApi!!.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl))
ncApi!!.getCapabilities(credentials, ApiUtils.getUrlForCapabilities(baseUrl!!))
.retry(API_RETRIES)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -1718,7 +1718,7 @@ class CallActivity : CallBaseActivity() {
val apiVersion = ApiUtils.getCallApiVersion(conversationUser, intArrayOf(ApiUtils.APIv4, 1))
ncApi!!.joinCall(
credentials,
ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken),
ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken!!),
inCallFlag,
isCallWithoutNotification,
recordingConsentGiven
Expand Down Expand Up @@ -1756,7 +1756,10 @@ class CallActivity : CallBaseActivity() {
}

private fun startCallTimeCounter(callStartTime: Long?) {
if (callStartTime != null && hasSpreedFeatureCapability(conversationUser, "recording-v1")) {
if (callStartTime != null && hasSpreedFeatureCapability(
conversationUser!!.capabilities!!.spreedCapability!!, "recording-v1"
)
) {
binding!!.callDuration.visibility = View.VISIBLE
val currentTimeInSec = System.currentTimeMillis() / SECOND_IN_MILLIES
elapsedSeconds = currentTimeInSec - callStartTime
Expand Down Expand Up @@ -1801,7 +1804,7 @@ class CallActivity : CallBaseActivity() {
ApiUtils.getUrlForSignaling(
signalingApiVersion,
baseUrl,
roomToken
roomToken!!
)
)
.subscribeOn(Schedulers.io())
Expand Down Expand Up @@ -2036,7 +2039,7 @@ class CallActivity : CallBaseActivity() {
callParticipantList!!.removeObserver(callParticipantListObserver)
callParticipantList!!.destroy()
}
ncApi!!.leaveCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken))
ncApi!!.leaveCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken!!))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<GenericOverall> {
Expand Down Expand Up @@ -2922,7 +2925,7 @@ class CallActivity : CallBaseActivity() {
val apiVersion = ApiUtils.getSignalingApiVersion(conversationUser, intArrayOf(ApiUtils.APIv3, 2, 1))
ncApi!!.sendSignalingMessages(
credentials,
ApiUtils.getUrlForSignaling(apiVersion, baseUrl, roomToken),
ApiUtils.getUrlForSignaling(apiVersion, baseUrl, roomToken!!),
strings.toString()
)
.retry(API_RETRIES)
Expand Down Expand Up @@ -3099,11 +3102,11 @@ class CallActivity : CallBaseActivity() {

val isAllowedToStartOrStopRecording: Boolean
get() = (
isCallRecordingAvailable(conversationUser!!) &&
isCallRecordingAvailable(conversationUser!!.capabilities!!.spreedCapability!!) &&
isModerator
)
val isAllowedToRaiseHand: Boolean
get() = hasSpreedFeatureCapability(conversationUser, "raise-hand") ||
get() = hasSpreedFeatureCapability(conversationUser!!.capabilities!!.spreedCapability!!, "raise-hand") ||
isBreakoutRoom

private inner class SelfVideoTouchListener : OnTouchListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
val user = userId.substringBeforeLast("@")
val baseUrl = userId.substringAfterLast("@")

if (userManager.currentUser.blockingGet()?.baseUrl?.endsWith(baseUrl) == true) {
if (userManager.currentUser.blockingGet()?.baseUrl!!.endsWith(baseUrl) == true) {
startConversation(user)
} else {
Snackbar.make(
Expand All @@ -204,7 +204,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
val credentials = ApiUtils.getCredentials(currentUser?.username, currentUser?.token)
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion,
currentUser?.baseUrl,
currentUser?.baseUrl!!,
roomType,
null,
userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import com.nextcloud.talk.ui.StatusDrawable
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
import eu.davidea.flexibleadapter.items.IFilterable
Expand Down Expand Up @@ -312,7 +312,7 @@ class ConversationItem(
if (model.type === ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble)
} else if (model.unreadMention) {
if (hasSpreedFeatureCapability(user, "direct-mention-flag")) {
if (hasSpreedFeatureCapability(user.capabilities?.spreedCapability!!, "direct-mention-flag")) {
if (model.unreadMentionDirect!!) {
viewThemeUtils.material.colorChipBackground(holder.binding.dialogUnreadBubble)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ class CallStartedViewHolder(incomingView: View, payload: Any) :
val user = userManager.currentUser.blockingGet()
val url: String = if (message.actorType == "guests" || message.actorType == "guest") {
ApiUtils.getUrlForGuestAvatar(
user!!.baseUrl,
user!!.baseUrl!!,
message.actorDisplayName,
true
)
} else {
ApiUtils.getUrlForAvatar(user!!.baseUrl, message.actorDisplayName, false)
ApiUtils.getUrlForAvatar(user!!.baseUrl!!, message.actorDisplayName, false)
}

val imageRequest: ImageRequest = ImageRequest.Builder(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class LinkPreview {
binding.referenceThumbImage.setImageDrawable(null)

if (!message.extractedUrlToPreview.isNullOrEmpty()) {
val credentials: String = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)
val openGraphLink = ApiUtils.getUrlForOpenGraph(message.activeUser?.baseUrl)
val credentials: String = ApiUtils.getCredentials(message.activeUser?.username, message.activeUser?.token)!!
val openGraphLink = ApiUtils.getUrlForOpenGraph(message.activeUser?.baseUrl!!)
ncApi.getOpenGraph(
credentials,
openGraphLink,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
binding.messageQuote.quotedMessageImage.load(it) {
addHeader(
"Authorization",
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)
ApiUtils.getCredentials(message.activeUser!!.username, message.activeUser!!.token)!!
)
}
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CALL_VOICE_ONLY
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CONVERSATION_NAME
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import io.reactivex.disposables.Disposable
import okhttp3.Cache
import java.io.IOException
Expand Down Expand Up @@ -148,7 +148,7 @@ class CallNotificationActivity : CallBaseActivity() {

private fun initObservers() {
val apiVersion = ApiUtils.getConversationApiVersion(
userBeingCalled,
userBeingCalled!!,
intArrayOf(
ApiUtils.APIv4,
ApiUtils.APIv3,
Expand Down Expand Up @@ -188,7 +188,7 @@ class CallNotificationActivity : CallBaseActivity() {

if (apiVersion >= ApiUtils.APIv3) {
val hasCallFlags = hasSpreedFeatureCapability(
userBeingCalled,
userBeingCalled?.capabilities?.spreedCapability!!,
"conversation-call-flags"
)
if (hasCallFlags) {
Expand Down Expand Up @@ -243,7 +243,7 @@ class CallNotificationActivity : CallBaseActivity() {
originalBundle!!.putString(KEY_CONVERSATION_NAME, currentConversation!!.displayName)

val participantPermission = ParticipantPermissions(
userBeingCalled!!,
userBeingCalled!!.capabilities!!.spreedCapability!!,
currentConversation!!
)
originalBundle!!.putBoolean(
Expand Down
Loading

0 comments on commit 7859a08

Please sign in to comment.