#7761 Added ring when starting jitsi call

This commit is contained in:
roman.turubayev@econophysica.com 2024-07-13 14:22:10 +07:00
parent b0158f1a93
commit 98882735bf
2 changed files with 46 additions and 2 deletions

View File

@ -131,6 +131,13 @@ class CallAndroidService : VectorAndroidService() {
ACTION_CALL_TERMINATED -> {
handleCallTerminated(intent)
}
ACTION_OUTGOING_JITSI_RINGING_CALL -> {
mediaSession?.isActive = true
callRingPlayerOutgoing?.start()
}
ACTION_JITSI_CALL_TERMINATED -> {
callRingPlayerOutgoing?.stop()
}
else -> {
handleUnexpectedState(null)
}
@ -316,8 +323,10 @@ class CallAndroidService : VectorAndroidService() {
private const val ACTION_INCOMING_RINGING_CALL = "im.vector.app.core.services.CallService.ACTION_INCOMING_RINGING_CALL"
private const val ACTION_OUTGOING_RINGING_CALL = "im.vector.app.core.services.CallService.ACTION_OUTGOING_RINGING_CALL"
private const val ACTION_OUTGOING_JITSI_RINGING_CALL = "im.vector.app.core.services.CallService.ACTION_OUTGOING_JITSI_RINGING_CALL"
private const val ACTION_ONGOING_CALL = "im.vector.app.core.services.CallService.ACTION_ONGOING_CALL"
private const val ACTION_CALL_TERMINATED = "im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED"
private const val ACTION_JITSI_CALL_TERMINATED = "im.vector.app.core.services.CallService.ACTION_JITSI_CALL_TERMINATED"
private const val EXTRA_CALL_ID = "EXTRA_CALL_ID"
private const val EXTRA_IS_IN_BG = "EXTRA_IS_IN_BG"
@ -377,6 +386,26 @@ class CallAndroidService : VectorAndroidService() {
}
context.startService(intent)
}
fun onOutgoingJitsiCallRinging(
context: Context,
) {
val intent = Intent(context, CallAndroidService::class.java)
.apply {
action = ACTION_OUTGOING_JITSI_RINGING_CALL
}
ContextCompat.startForegroundService(context, intent)
}
fun onCancelJitsiCallRinging(
context: Context,
) {
val intent = Intent(context, CallAndroidService::class.java)
.apply {
action = ACTION_JITSI_CALL_TERMINATED
}
context.startService(intent)
}
}
inner class CallServiceBinder : Binder() {

View File

@ -39,6 +39,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.services.CallAndroidService
import im.vector.app.databinding.ActivityJitsiBinding
import im.vector.lib.core.utils.compat.getParcelableExtraCompat
import kotlinx.parcelize.Parcelize
@ -87,10 +88,10 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
jitsiViewModel.observeViewEvents {
when (it) {
is JitsiCallViewEvents.JoinConference -> configureJitsiView(it)
is JitsiCallViewEvents.JoinConference -> handleJoinConference(it)
is JitsiCallViewEvents.ConfirmSwitchingConference -> handleConfirmSwitching(it)
JitsiCallViewEvents.FailJoiningConference -> handleFailJoining()
JitsiCallViewEvents.Finish -> finish()
JitsiCallViewEvents.Finish -> handleFinish()
JitsiCallViewEvents.LeaveConference -> handleLeaveConference()
}
}
@ -150,6 +151,17 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
private fun handleLeaveConference() {
val leaveBroadcastIntent = BroadcastIntentHelper.buildHangUpIntent()
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(leaveBroadcastIntent)
CallAndroidService.onCancelJitsiCallRinging(applicationContext)
}
private fun handleJoinConference(joinConference: JitsiCallViewEvents.JoinConference) {
configureJitsiView(joinConference)
CallAndroidService.onOutgoingJitsiCallRinging(applicationContext)
}
private fun handleFinish() {
CallAndroidService.onCancelJitsiCallRinging(applicationContext)
finish()
}
private fun handleConfirmSwitching(action: JitsiCallViewEvents.ConfirmSwitchingConference) {
@ -161,6 +173,8 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
}
.setNegativeButton(R.string.action_cancel, null)
.show()
CallAndroidService.onCancelJitsiCallRinging(applicationContext)
}
private val pictureInPictureModeChangedInfoConsumer = Consumer<PictureInPictureModeChangedInfo> {
@ -192,6 +206,7 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
private fun handleFailJoining() {
Toast.makeText(this, getString(R.string.error_jitsi_join_conf), Toast.LENGTH_LONG).show()
CallAndroidService.onCancelJitsiCallRinging(applicationContext)
finish()
}