diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt index 6575949552..23c7b79914 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt @@ -55,7 +55,6 @@ import im.vector.app.databinding.ActivityCallBinding import im.vector.app.features.call.dialpad.CallDialPadBottomSheet import im.vector.app.features.call.dialpad.DialPadFragment import im.vector.app.features.call.transfer.CallTransferActivity -import im.vector.app.features.call.transfer.CallTransferResult import im.vector.app.features.call.utils.EglUtils import im.vector.app.features.call.webrtc.WebRtcCall import im.vector.app.features.call.webrtc.WebRtcCallManager @@ -525,22 +524,20 @@ class VectorCallActivity : VectorBaseActivity(), CallContro val callId = withState(callViewModel) { it.callId } navigator.openCallTransfer(this, callTransferActivityResultLauncher, callId) } - is VectorCallViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure)) + is VectorCallViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure)) null -> { } } } private val callTransferActivityResultLauncher = registerStartForActivityResult { activityResult -> - when (activityResult.resultCode) { Activity.RESULT_CANCELED -> { callViewModel.handle(VectorCallViewActions.CallTransferSelectionCancelled) } - Activity.RESULT_OK -> { - activityResult.data?.extras?.getParcelable(CallTransferActivity.EXTRA_TRANSFER_RESULT)?.also { - callViewModel.handle(VectorCallViewActions.CallTransferSelectionResult(it)) - } + Activity.RESULT_OK -> { + CallTransferActivity.getCallTransferResult(activityResult.data) + ?.let { callViewModel.handle(VectorCallViewActions.CallTransferSelectionResult(it)) } } } } diff --git a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt index d4b77c7739..d8eede6a55 100644 --- a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt @@ -26,6 +26,7 @@ import com.google.android.material.tabs.TabLayoutMediator import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.error.ErrorFormatter +import im.vector.app.core.extensions.exhaustive import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityCallTransferBinding import kotlinx.parcelize.Parcelize @@ -55,8 +56,8 @@ class CallTransferActivity : VectorBaseActivity() { callTransferViewModel.observeViewEvents { when (it) { - is CallTransferViewEvents.Complete -> handleComplete() - } + is CallTransferViewEvents.Complete -> handleComplete() + }.exhaustive } sectionsPagerAdapter = CallTransferPagerAdapter(this) @@ -104,11 +105,16 @@ class CallTransferActivity : VectorBaseActivity() { } companion object { - const val EXTRA_TRANSFER_RESULT = "EXTRA_TRANSFER_RESULT" + private const val EXTRA_TRANSFER_RESULT = "EXTRA_TRANSFER_RESULT" + fun newIntent(context: Context, callId: String): Intent { return Intent(context, CallTransferActivity::class.java).also { it.putExtra(Mavericks.KEY_ARG, CallTransferArgs(callId)) } } + + fun getCallTransferResult(intent: Intent?): CallTransferResult? { + return intent?.extras?.getParcelable(EXTRA_TRANSFER_RESULT) + } } }