Skip to content

Commit

Permalink
chore: use the new CameraPreviewBuilder to get CameraPreview (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine authored Sep 29, 2023
1 parent b7d4c8d commit 30f7cac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.viewinterop.AndroidView
import com.waz.avs.VideoPreview
import com.waz.avs.CameraPreviewBuilder

@Composable
fun CallVideoPreview(
Expand All @@ -37,11 +38,13 @@ fun CallVideoPreview(
) {
if (isCameraOn) {
Box {
val context = LocalContext.current
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = {
val videoPreview = VideoPreview(it)
videoPreview.setShouldFill(true)
val videoPreview = CameraPreviewBuilder(context)
.shouldFill(true)
.build()
onVideoPreviewCreated(videoPreview)
videoPreview
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import androidx.constraintlayout.compose.ConstraintLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import com.waz.avs.VideoPreview
import com.waz.avs.CameraPreviewBuilder
import com.waz.avs.VideoRenderer
import com.wire.android.R
import com.wire.android.model.UserAvatarData
Expand Down Expand Up @@ -214,11 +214,12 @@ private fun CameraPreview(
) {
if (isCameraOn) {
val context = LocalContext.current
val backgroundColor = colorsScheme().callingParticipantTileBackgroundColor.value.toInt()
val videoPreview = remember {
VideoPreview(context).apply {
layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)
setShouldFill(false)
}
CameraPreviewBuilder(context)
.setBackgroundColor(backgroundColor)
.shouldFill(false)
.build()
}
AndroidView(
factory = {
Expand Down

0 comments on commit 30f7cac

Please sign in to comment.