VoIP: fix some other issues

This commit is contained in:
ganfra 2020-12-16 18:49:29 +01:00
parent 8734101d87
commit 33047b5f64
4 changed files with 23 additions and 12 deletions

View File

@ -123,7 +123,11 @@ class VectorCallViewModel @AssistedInject constructor(
private val currentCallListener = object : WebRtcCallManager.CurrentCallListener {
override fun onCurrentCallChange(call: WebRtcCall?) {
updateOtherKnownCall(call)
if (call == null) {
_viewEvents.post(VectorCallViewEvents.DismissNoCall)
} else {
updateOtherKnownCall(call)
}
}
override fun onAudioDevicesChange() {
@ -143,8 +147,7 @@ class VectorCallViewModel @AssistedInject constructor(
}
}
private fun updateOtherKnownCall(currentCall: WebRtcCall?) {
if (currentCall == null) return
private fun updateOtherKnownCall(currentCall: WebRtcCall) {
val otherCall = callManager.getCalls().firstOrNull {
it.callId != currentCall.callId && it.mxCall.state is CallState.Connected
}

View File

@ -707,7 +707,6 @@ class WebRtcCall(val mxCall: MxCall,
if (mxCall.state == CallState.Terminated) {
return
}
val wasConnected = mxCall.state is CallState.Connected
mxCall.state = CallState.Terminated
// Close tracks ASAP
localVideoTrack?.setEnabled(false)
@ -721,8 +720,7 @@ class WebRtcCall(val mxCall: MxCall,
}
onCallEnded(this)
if (originatedByMe) {
// send hang up event
if (wasConnected) {
if (mxCall.state is CallState.Connected || mxCall.isOutgoing) {
mxCall.hangUp(reason)
} else {
mxCall.reject()

View File

@ -21,6 +21,7 @@ import android.view.View
import android.widget.ImageView
import android.widget.TextView
import im.vector.app.R
import im.vector.app.core.extensions.setLeftDrawable
import im.vector.app.core.glide.GlideApp
import im.vector.app.features.home.AvatarRenderer
import org.matrix.android.sdk.api.util.MatrixItem
@ -43,18 +44,24 @@ class IncomingCallAlert(uid: String,
: VectorAlert.ViewBinder {
override fun bind(view: View) {
val callKind = if (isVideoCall) {
R.string.action_video_call
val (callKindText, callKindIcon) = if (isVideoCall) {
Pair(R.string.action_video_call, R.drawable.ic_call_video_small)
} else {
R.string.action_voice_call
Pair(R.string.action_voice_call, R.drawable.ic_call_audio_small)
}
view.findViewById<TextView>(R.id.incomingCallKindView).apply {
setText(callKindText)
setLeftDrawable(callKindIcon)
}
view.findViewById<TextView>(R.id.incomingCallKindView).setText(callKind)
view.findViewById<TextView>(R.id.incomingCallNameView).text = matrixItem?.getBestName()
view.findViewById<ImageView>(R.id.incomingCallAvatar)?.let { imageView ->
matrixItem?.let { avatarRenderer.render(it, imageView, GlideApp.with(view.context.applicationContext)) }
}
view.findViewById<ImageView>(R.id.incomingCallAcceptView).setOnClickListener {
onAccept()
view.findViewById<ImageView>(R.id.incomingCallAcceptView).apply {
setOnClickListener {
onAccept()
}
setImageResource(callKindIcon)
}
view.findViewById<ImageView>(R.id.incomingCallRejectView).setOnClickListener {
onReject()

View File

@ -45,6 +45,8 @@
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:textColor="?riotx_text_secondary"
app:drawableTint="?riotx_text_secondary"
android:drawablePadding="4dp"
android:textSize="15sp"
android:maxLines="1"
app:layout_constraintEnd_toStartOf="@+id/incomingCallRejectView"
@ -65,6 +67,7 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:tint="@color/white"
android:src="@drawable/ic_call_answer" />
<ImageView