mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Merge pull request #5083 from vector-im/feature/dla/hold_call_for_transfer_selection
Hold call for transfer selection
This commit is contained in:
commit
235f2c78f8
9 changed files with 38 additions and 10 deletions
1
changelog.d/5081.bugfix
Normal file
1
changelog.d/5081.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Selecting Transfer in a call should immediately put the other person on hold until the call connects or the Transfer is cancelled.
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.call
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.KeyguardManager
|
||||
import android.app.PictureInPictureParams
|
||||
import android.content.Context
|
||||
|
@ -43,6 +44,7 @@ import com.google.android.material.card.MaterialCardView
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||
import im.vector.app.core.extensions.setTextOrHide
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.core.utils.PERMISSIONS_FOR_AUDIO_IP_CALL
|
||||
|
@ -518,13 +520,19 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
|
|||
}
|
||||
is VectorCallViewEvents.ShowCallTransferScreen -> {
|
||||
val callId = withState(callViewModel) { it.callId }
|
||||
navigator.openCallTransfer(this, callId)
|
||||
navigator.openCallTransfer(this, callTransferActivityResultLauncher, callId)
|
||||
}
|
||||
null -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val callTransferActivityResultLauncher = registerStartForActivityResult { activityResult ->
|
||||
if (activityResult.resultCode == Activity.RESULT_CANCELED) {
|
||||
callViewModel.handle(VectorCallViewActions.CallTransferSelectionCancelled)
|
||||
}
|
||||
}
|
||||
|
||||
private fun onErrorTimoutConnect(turn: TurnServerResponse?) {
|
||||
Timber.tag(loggerTag.value).d("onErrorTimoutConnect $turn")
|
||||
// TODO ask to use default stun, etc...
|
||||
|
|
|
@ -36,5 +36,6 @@ sealed class VectorCallViewActions : VectorViewModelAction {
|
|||
object ToggleCamera : VectorCallViewActions()
|
||||
object ToggleHDSD : VectorCallViewActions()
|
||||
object InitiateCallTransfer : VectorCallViewActions()
|
||||
object CallTransferSelectionCancelled : VectorCallViewActions()
|
||||
object TransferCall : VectorCallViewActions()
|
||||
}
|
||||
|
|
|
@ -319,10 +319,14 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||
call?.sendDtmfDigit(action.digit)
|
||||
}
|
||||
VectorCallViewActions.InitiateCallTransfer -> {
|
||||
call?.updateRemoteOnHold(true)
|
||||
_viewEvents.post(
|
||||
VectorCallViewEvents.ShowCallTransferScreen
|
||||
)
|
||||
}
|
||||
VectorCallViewActions.CallTransferSelectionCancelled -> {
|
||||
call?.updateRemoteOnHold(false)
|
||||
}
|
||||
VectorCallViewActions.TransferCall -> {
|
||||
handleCallTransfer()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.call.transfer
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
@ -55,7 +56,7 @@ class CallTransferActivity : VectorBaseActivity<ActivityCallTransferBinding>() {
|
|||
|
||||
callTransferViewModel.observeViewEvents {
|
||||
when (it) {
|
||||
is CallTransferViewEvents.Dismiss -> finish()
|
||||
is CallTransferViewEvents.Complete -> handleComplete()
|
||||
CallTransferViewEvents.Loading -> showWaitingView()
|
||||
is CallTransferViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure))
|
||||
}
|
||||
|
@ -93,6 +94,11 @@ class CallTransferActivity : VectorBaseActivity<ActivityCallTransferBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleComplete() {
|
||||
setResult(Activity.RESULT_OK)
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun newIntent(context: Context, callId: String): Intent {
|
||||
|
|
|
@ -19,7 +19,7 @@ package im.vector.app.features.call.transfer
|
|||
import im.vector.app.core.platform.VectorViewEvents
|
||||
|
||||
sealed class CallTransferViewEvents : VectorViewEvents {
|
||||
object Dismiss : CallTransferViewEvents()
|
||||
object Complete : CallTransferViewEvents()
|
||||
object Loading : CallTransferViewEvents()
|
||||
object FailToTransfer : CallTransferViewEvents()
|
||||
}
|
||||
|
|
|
@ -50,14 +50,14 @@ class CallTransferViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
private val callListener = object : WebRtcCall.Listener {
|
||||
override fun onStateUpdate(call: MxCall) {
|
||||
if (call.state is CallState.Ended) {
|
||||
_viewEvents.post(CallTransferViewEvents.Dismiss)
|
||||
_viewEvents.post(CallTransferViewEvents.Complete)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
if (call == null) {
|
||||
_viewEvents.post(CallTransferViewEvents.Dismiss)
|
||||
_viewEvents.post(CallTransferViewEvents.Complete)
|
||||
} else {
|
||||
call.addListener(callListener)
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class CallTransferViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
} else {
|
||||
call?.transferToUser(action.selectedUserId, null)
|
||||
}
|
||||
_viewEvents.post(CallTransferViewEvents.Dismiss)
|
||||
_viewEvents.post(CallTransferViewEvents.Complete)
|
||||
} catch (failure: Throwable) {
|
||||
_viewEvents.post(CallTransferViewEvents.FailToTransfer)
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class CallTransferViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
} else {
|
||||
call?.transferToUser(result.userId, result.roomId)
|
||||
}
|
||||
_viewEvents.post(CallTransferViewEvents.Dismiss)
|
||||
_viewEvents.post(CallTransferViewEvents.Complete)
|
||||
} catch (failure: Throwable) {
|
||||
_viewEvents.post(CallTransferViewEvents.FailToTransfer)
|
||||
}
|
||||
|
|
|
@ -524,9 +524,13 @@ class DefaultNavigator @Inject constructor(
|
|||
context.startActivity(RoomDevToolActivity.intent(context, roomId))
|
||||
}
|
||||
|
||||
override fun openCallTransfer(context: Context, callId: String) {
|
||||
override fun openCallTransfer(
|
||||
context: Context,
|
||||
activityResultLauncher: ActivityResultLauncher<Intent>,
|
||||
callId: String
|
||||
) {
|
||||
val intent = CallTransferActivity.newIntent(context, callId)
|
||||
context.startActivity(intent)
|
||||
activityResultLauncher.launch(intent)
|
||||
}
|
||||
|
||||
override fun openCreatePoll(context: Context, roomId: String, editedEventId: String?, mode: PollMode) {
|
||||
|
|
|
@ -149,7 +149,11 @@ interface Navigator {
|
|||
|
||||
fun openDevTools(context: Context, roomId: String)
|
||||
|
||||
fun openCallTransfer(context: Context, callId: String)
|
||||
fun openCallTransfer(
|
||||
context: Context,
|
||||
activityResultLauncher: ActivityResultLauncher<Intent>,
|
||||
callId: String
|
||||
)
|
||||
|
||||
fun openCreatePoll(context: Context, roomId: String, editedEventId: String?, mode: PollMode)
|
||||
|
||||
|
|
Loading…
Reference in a new issue