Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use the new CameraPreviewBuilder to get CameraPreview #2291

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading