VoIP: clean code

This commit is contained in:
ganfra 2020-12-22 12:34:20 +01:00
parent 33047b5f64
commit 69cc4f83bb
14 changed files with 26 additions and 23 deletions

View File

@ -309,7 +309,6 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
ContextCompat.startForegroundService(context, intent)
}
fun onOutgoingCallRinging(context: Context,
callId: String) {
val intent = Intent(context, CallService::class.java)

View File

@ -18,10 +18,8 @@ package im.vector.app.core.ui.views
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import im.vector.app.R
import im.vector.app.databinding.ViewCallControlsBinding
import im.vector.app.databinding.ViewCurrentCallsBinding
import im.vector.app.features.call.webrtc.WebRtcCall
import im.vector.app.features.themes.ThemeUtils

View File

@ -16,9 +16,7 @@
package im.vector.app.core.utils
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
@ -56,5 +54,4 @@ class CountUpTimer(private val intervalInMs: Long) {
interface TickListener {
fun onTick(milliseconds: Long)
}
}

View File

@ -251,7 +251,13 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
} else {
val otherCall = callManager.getCallById(state.otherKnownCallInfo.callId)
val colorFilter = ContextCompat.getColor(this, R.color.bg_call_screen)
avatarRenderer.renderBlur(state.otherKnownCallInfo.otherUserItem, views.otherKnownCallAvatarView, sampling = 20, rounded = false, colorFilter = colorFilter)
avatarRenderer.renderBlur(
matrixItem = state.otherKnownCallInfo.otherUserItem,
imageView = views.otherKnownCallAvatarView,
sampling = 20,
rounded = false,
colorFilter = colorFilter
)
views.otherKnownCallLayout.isVisible = true
views.otherSmallIsHeldIcon.isVisible = otherCall?.let { it.isLocalOnHold || it.remoteOnHold }.orFalse()
}

View File

@ -558,11 +558,15 @@ class WebRtcCall(val mxCall: MxCall,
remoteOnHold = true
isLocalOnHold = true
direction = RtpTransceiver.RtpTransceiverDirection.INACTIVE
timer.pause()
} else {
remoteOnHold = false
isLocalOnHold = wasLocalOnHold
onCallBecomeActive(this@WebRtcCall)
direction = RtpTransceiver.RtpTransceiverDirection.SEND_RECV
if (!isLocalOnHold) {
timer.resume()
}
}
for (transceiver in peerConnection?.transceivers ?: emptyList()) {
transceiver.direction = direction

View File

@ -206,6 +206,10 @@ class WebRtcCallManager @Inject constructor(
fun startOutgoingCall(signalingRoomId: String, otherUserId: String, isVideoCall: Boolean) {
Timber.v("## VOIP startOutgoingCall in room $signalingRoomId to $otherUserId isVideo $isVideoCall")
if (getCallsByRoomId(signalingRoomId).isNotEmpty()) {
Timber.w("## VOIP you already have a call in this room")
return
}
if (currentCall.get() != null && currentCall.get()?.mxCall?.state !is CallState.Connected || getCalls().size >= 2) {
Timber.w("## VOIP cannot start outgoing call")
// Just ignore, maybe we could answer from other session?
@ -276,7 +280,11 @@ class WebRtcCallManager @Inject constructor(
override fun onCallInviteReceived(mxCall: MxCall, callInviteContent: CallInviteContent) {
Timber.v("## VOIP onCallInviteReceived callId ${mxCall.callId}")
if (currentCall.get() != null && currentCall.get()?.mxCall?.state !is CallState.Connected || getCalls().size >= 2) {
if (getCallsByRoomId(mxCall.roomId).isNotEmpty()) {
Timber.w("## VOIP you already have a call in this room")
return
}
if ((currentCall.get() != null && currentCall.get()?.mxCall?.state !is CallState.Connected) || getCalls().size >= 2) {
Timber.w("## VOIP receiving incoming call but cannot handle it")
// Just ignore, maybe we could answer from other session?
return

View File

@ -16,8 +16,6 @@
package im.vector.app.features.home.room.detail.timeline.factory
import android.content.Intent
import android.os.Parcelable
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
@ -40,7 +38,6 @@ import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadSt
import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder
import im.vector.app.features.home.room.detail.timeline.helper.MessageInformationDataFactory
import im.vector.app.features.home.room.detail.timeline.helper.MessageItemAttributesFactory
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummaryHolder
import im.vector.app.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
import im.vector.app.features.home.room.detail.timeline.item.AbsMessageItem
import im.vector.app.features.home.room.detail.timeline.item.MessageBlockCodeItem

View File

@ -21,7 +21,6 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.resources.UserPreferencesProvider
import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummaryHolder
import im.vector.app.features.home.room.detail.timeline.item.RoomCreateItem_
import me.gujun.android.span.span
import org.matrix.android.sdk.api.session.Session

View File

@ -24,7 +24,6 @@ import im.vector.app.features.home.room.detail.timeline.TimelineEventController
import im.vector.app.features.home.room.detail.timeline.helper.AvatarSizeProvider
import im.vector.app.features.home.room.detail.timeline.helper.MessageInformationDataFactory
import im.vector.app.features.home.room.detail.timeline.helper.MessageItemAttributesFactory
import im.vector.app.features.home.room.detail.timeline.helper.RoomSummaryHolder
import im.vector.app.features.home.room.detail.timeline.item.StatusTileTimelineItem
import im.vector.app.features.home.room.detail.timeline.item.StatusTileTimelineItem_
import org.matrix.android.sdk.api.session.Session

View File

@ -16,7 +16,6 @@
package im.vector.app.features.home.room.detail.timeline.helper
import im.vector.app.core.di.ScreenScope
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import javax.inject.Inject
import javax.inject.Singleton

View File

@ -113,5 +113,4 @@ interface Navigator {
options: ((MutableList<Pair<View, String>>) -> Unit)?)
fun openSearch(context: Context, roomId: String)
}

View File

@ -297,7 +297,6 @@ class NotificationUtils @Inject constructor(private val context: Context,
.setLights(accentColor, 500, 500)
.setOngoing(true)
val contentIntent = VectorCallActivity.newIntent(
context = context,
mxCall = mxCall,
@ -391,7 +390,6 @@ class NotificationUtils @Inject constructor(private val context: Context,
@SuppressLint("NewApi")
fun buildPendingCallNotification(mxCall: MxCall,
title: String): Notification {
val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID)
.setContentTitle(ensureTitleNotEmpty(title))
.apply {