mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 18:05:59 +03:00
VoIP: clean code
This commit is contained in:
parent
33047b5f64
commit
69cc4f83bb
14 changed files with 26 additions and 23 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -62,7 +60,7 @@ class CurrentCallsView @JvmOverloads constructor(
|
|||
}
|
||||
} else {
|
||||
if (heldCalls.size > 1) {
|
||||
views.currentCallsInfo.text = resources.getString(R.string.call_only_multiple_paused , heldCalls.size)
|
||||
views.currentCallsInfo.text = resources.getString(R.string.call_only_multiple_paused, heldCalls.size)
|
||||
} else if (heldCalls.size == 1) {
|
||||
views.currentCallsInfo.text = resources.getString(R.string.call_active_and_single_paused, formattedDuration)
|
||||
} else {
|
||||
|
|
|
@ -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
|
||||
|
@ -37,7 +35,7 @@ class CountUpTimer(private val intervalInMs: Long) {
|
|||
|
||||
var tickListener: TickListener? = null
|
||||
|
||||
fun elapsedTime(): Long{
|
||||
fun elapsedTime(): Long {
|
||||
return elapsedTime.get()
|
||||
}
|
||||
|
||||
|
@ -56,5 +54,4 @@ class CountUpTimer(private val intervalInMs: Long) {
|
|||
interface TickListener {
|
||||
fun onTick(milliseconds: Long)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ class SharedKnownCallsViewModel @Inject constructor(
|
|||
val callListener = object : WebRtcCall.Listener {
|
||||
|
||||
override fun onStateUpdate(call: MxCall) {
|
||||
//post it-self
|
||||
// post it-self
|
||||
liveKnownCalls.postValue(liveKnownCalls.value)
|
||||
}
|
||||
|
||||
override fun onHoldUnhold() {
|
||||
super.onHoldUnhold()
|
||||
//post it-self
|
||||
// post it-self
|
||||
liveKnownCalls.postValue(liveKnownCalls.value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -806,7 +806,7 @@ class RoomDetailFragment @Inject constructor(
|
|||
// resume existing if same room, if not prompt to kill and then restart new call?
|
||||
if (currentCall.mxCall.roomId == roomDetailArgs.roomId) {
|
||||
onTapToReturnToCall()
|
||||
}else {
|
||||
} else {
|
||||
safeStartCall(isVideoCall)
|
||||
}
|
||||
} else if (!state.isAllowedToStartWebRTCCall) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -36,7 +35,7 @@ class RoomSummaryHolder @Inject constructor() {
|
|||
|
||||
fun get(roomId: String) = roomSummaries[roomId]
|
||||
|
||||
fun remove(roomId: String)= roomSummaries.remove(roomId)
|
||||
fun remove(roomId: String) = roomSummaries.remove(roomId)
|
||||
|
||||
fun clear() {
|
||||
roomSummaries.clear()
|
||||
|
|
|
@ -113,5 +113,4 @@ interface Navigator {
|
|||
options: ((MutableList<Pair<View, String>>) -> Unit)?)
|
||||
|
||||
fun openSearch(context: Context, roomId: String)
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue