Skip to content

Commit

Permalink
element-hq#7761 Added ring when starting jitsi call
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jul 13, 2024
1 parent b0158f1 commit 9888273
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -161,6 +173,8 @@ class VectorJitsiActivity : VectorBaseActivity<ActivityJitsiBinding>(), JitsiMee
}
.setNegativeButton(R.string.action_cancel, null)
.show()

CallAndroidService.onCancelJitsiCallRinging(applicationContext)
}

private val pictureInPictureModeChangedInfoConsumer = Consumer<PictureInPictureModeChangedInfo> {
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 9888273

Please sign in to comment.