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,8 +123,12 @@ class VectorCallViewModel @AssistedInject constructor(
private val currentCallListener = object : WebRtcCallManager.CurrentCallListener { private val currentCallListener = object : WebRtcCallManager.CurrentCallListener {
override fun onCurrentCallChange(call: WebRtcCall?) { override fun onCurrentCallChange(call: WebRtcCall?) {
if (call == null) {
_viewEvents.post(VectorCallViewEvents.DismissNoCall)
} else {
updateOtherKnownCall(call) updateOtherKnownCall(call)
} }
}
override fun onAudioDevicesChange() { override fun onAudioDevicesChange() {
val currentSoundDevice = callManager.callAudioManager.getCurrentSoundDevice() val currentSoundDevice = callManager.callAudioManager.getCurrentSoundDevice()
@ -143,8 +147,7 @@ class VectorCallViewModel @AssistedInject constructor(
} }
} }
private fun updateOtherKnownCall(currentCall: WebRtcCall?) { private fun updateOtherKnownCall(currentCall: WebRtcCall) {
if (currentCall == null) return
val otherCall = callManager.getCalls().firstOrNull { val otherCall = callManager.getCalls().firstOrNull {
it.callId != currentCall.callId && it.mxCall.state is CallState.Connected 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) { if (mxCall.state == CallState.Terminated) {
return return
} }
val wasConnected = mxCall.state is CallState.Connected
mxCall.state = CallState.Terminated mxCall.state = CallState.Terminated
// Close tracks ASAP // Close tracks ASAP
localVideoTrack?.setEnabled(false) localVideoTrack?.setEnabled(false)
@ -721,8 +720,7 @@ class WebRtcCall(val mxCall: MxCall,
} }
onCallEnded(this) onCallEnded(this)
if (originatedByMe) { if (originatedByMe) {
// send hang up event if (mxCall.state is CallState.Connected || mxCall.isOutgoing) {
if (wasConnected) {
mxCall.hangUp(reason) mxCall.hangUp(reason)
} else { } else {
mxCall.reject() mxCall.reject()

View file

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

View file

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