Show screen sharing permission dialog.

This commit is contained in:
Onuray Sahin 2022-04-19 17:47:06 +03:00
parent 00bbb94b3b
commit 99cab794c4
8 changed files with 65 additions and 21 deletions

View File

@ -66,6 +66,11 @@ class CallControlsBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetC
callViewModel.handle(VectorCallViewActions.InitiateCallTransfer)
dismiss()
}
views.callControlsShareScreen.views.bottomSheetActionClickableZone.debouncedClicks {
callViewModel.handle(VectorCallViewActions.InitiateScreenSharing)
dismiss()
}
}
private fun renderState(state: VectorCallViewState) {

View File

@ -24,6 +24,7 @@ import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP
import android.content.res.Configuration
import android.graphics.Color
import android.media.projection.MediaProjectionManager
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
@ -525,6 +526,7 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
navigator.openCallTransfer(this, callTransferActivityResultLauncher, callId)
}
is VectorCallViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure))
is VectorCallViewEvents.ShowScreenSharingPermissionDialog -> handleShowScreenSharingPermissionDialog()
else -> Unit
}
}
@ -628,6 +630,18 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
}
}
private val screenSharingPermissionActivityResultLauncher = registerStartForActivityResult { activityResult ->
if (activityResult.resultCode == Activity.RESULT_OK) {
callViewModel.handle(VectorCallViewActions.StartScreenSharing)
}
}
private fun handleShowScreenSharingPermissionDialog() {
getSystemService<MediaProjectionManager>()?.let {
navigator.openScreenSharingPermissionDialog(it.createScreenCaptureIntent(), screenSharingPermissionActivityResultLauncher)
}
}
companion object {
private const val EXTRA_MODE = "EXTRA_MODE"
private const val FRAGMENT_DIAL_PAD_TAG = "FRAGMENT_DIAL_PAD_TAG"

View File

@ -40,4 +40,6 @@ sealed class VectorCallViewActions : VectorViewModelAction {
object CallTransferSelectionCancelled : VectorCallViewActions()
data class CallTransferSelectionResult(val callTransferResult: CallTransferResult) : VectorCallViewActions()
object TransferCall : VectorCallViewActions()
object InitiateScreenSharing : VectorCallViewActions()
object StartScreenSharing : VectorCallViewActions()
}

View File

@ -30,6 +30,7 @@ sealed class VectorCallViewEvents : VectorViewEvents {
object ShowDialPad : VectorCallViewEvents()
object ShowCallTransferScreen : VectorCallViewEvents()
object FailToTransfer : VectorCallViewEvents()
object ShowScreenSharingPermissionDialog : VectorCallViewEvents()
// data class CallAnswered(val content: CallAnswerContent) : VectorCallViewEvents()
// data class CallHangup(val content: CallHangupContent) : VectorCallViewEvents()
// object CallAccepted : VectorCallViewEvents()

View File

@ -341,6 +341,14 @@ class VectorCallViewModel @AssistedInject constructor(
setState { VectorCallViewState(action.callArgs) }
setupCallWithCurrentState()
}
is VectorCallViewActions.InitiateScreenSharing -> {
_viewEvents.post(
VectorCallViewEvents.ShowScreenSharingPermissionDialog
)
}
is VectorCallViewActions.StartScreenSharing -> {
call?.shareScreen()
}
}
}

View File

@ -770,6 +770,10 @@ class WebRtcCall(
return currentCaptureFormat
}
fun shareScreen() {
// TODO. Will be handled within the next PR.
}
private suspend fun release() {
listeners.clear()
mxCall.removeListener(this)

View File

@ -600,4 +600,9 @@ class DefaultNavigator @Inject constructor(
roomEncryptionTrustLevel = threadTimelineArgs.roomEncryptionTrustLevel
)))
}
override fun openScreenSharingPermissionDialog(screenCaptureIntent: Intent,
activityResultLauncher: ActivityResultLauncher<Intent>) {
activityResultLauncher.launch(screenCaptureIntent)
}
}

View File

@ -168,4 +168,9 @@ interface Navigator {
fun openThread(context: Context, threadTimelineArgs: ThreadTimelineArgs, eventIdToNavigate: String? = null)
fun openThreadList(context: Context, threadTimelineArgs: ThreadTimelineArgs)
fun openScreenSharingPermissionDialog(
screenCaptureIntent: Intent,
activityResultLauncher: ActivityResultLauncher<Intent>
)
}