Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandar-apostolov committed Apr 1, 2024
2 parents 0cdb6e5 + 53b7591 commit 591ee86
Show file tree
Hide file tree
Showing 74 changed files with 1,713 additions and 573 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ object Configuration {
const val minSdk = 24
const val majorVersion = 0
const val minorVersion = 5
const val patchVersion = 3
const val patchVersion = 4
const val versionName = "$majorVersion.$minorVersion.$patchVersion"
const val versionCode = 17
const val versionCode = 18
const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT"
const val artifactGroup = "io.getstream"
const val streamVideoCallGooglePlayVersion = "1.0.6"
Expand Down
1 change: 1 addition & 0 deletions demo-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ dependencies {
// Stream Video SDK
implementation(project(":stream-video-android-ui-compose"))
implementation(project(":stream-video-android-ui-xml"))
implementation(project(":stream-video-android-filters-video"))
compileOnly(project(":stream-video-android-previewdata"))

// Stream Chat SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ import io.getstream.video.android.compose.ui.components.call.renderer.copy
import io.getstream.video.android.core.Call
import io.getstream.video.android.core.RealtimeConnection
import io.getstream.video.android.core.call.state.ChooseLayout
import io.getstream.video.android.filters.video.BlurredBackgroundVideoFilter
import io.getstream.video.android.filters.video.VirtualBackgroundVideoFilter
import io.getstream.video.android.mock.StreamPreviewDataUtils
import io.getstream.video.android.mock.previewCall
import io.getstream.video.android.tooling.extensions.toPx
import io.getstream.video.android.tooling.util.StreamFlavors
import io.getstream.video.android.ui.menu.SettingsMenu
import io.getstream.video.android.ui.menu.VideoFilter
import io.getstream.video.android.ui.menu.availableVideoFilters
import io.getstream.video.android.util.config.AppConfig
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
Expand All @@ -118,9 +122,8 @@ fun CallScreen(
val speakingWhileMuted by call.state.speakingWhileMuted.collectAsStateWithLifecycle()
var isShowingSettingMenu by remember { mutableStateOf(false) }
var isShowingLayoutChooseMenu by remember { mutableStateOf(false) }
var isShowingReactionsMenu by remember { mutableStateOf(false) }
var isShowingAvailableDeviceMenu by remember { mutableStateOf(false) }
var isBackgroundBlurEnabled by remember { mutableStateOf(false) }
var selectedVideoFilter by remember { mutableIntStateOf(0) }
var isShowingFeedbackDialog by remember { mutableStateOf(false) }
var isShowingStats by remember { mutableStateOf(false) }
var layout by remember { mutableStateOf(LayoutType.DYNAMIC) }
Expand Down Expand Up @@ -378,7 +381,7 @@ fun CallScreen(
),
onIcon = Icons.Default.MoreVert,
onStyle = VideoTheme.styles.buttonStyles.secondaryIconButtonStyle(),
offStyle = VideoTheme.styles.buttonStyles.tetriaryIconButtonStyle(),
offStyle = VideoTheme.styles.buttonStyles.tertiaryIconButtonStyle(),
) {
showingLandscapeControls = when (it) {
ToggleableState.On -> false
Expand Down Expand Up @@ -445,22 +448,32 @@ fun CallScreen(
if (isShowingSettingMenu) {
SettingsMenu(
call = call,
selectedVideoFilter = selectedVideoFilter,
showDebugOptions = showDebugOptions,
isBackgroundBlurEnabled = isBackgroundBlurEnabled,
onDismissed = { isShowingSettingMenu = false },
onSelectVideoFilter = { filterIndex ->
selectedVideoFilter = filterIndex

when (val filter = availableVideoFilters[filterIndex]) {
is VideoFilter.None -> {
call.videoFilter = null
}
is VideoFilter.BlurredBackground -> {
call.videoFilter = BlurredBackgroundVideoFilter()
}
is VideoFilter.VirtualBackground -> {
call.videoFilter = VirtualBackgroundVideoFilter(context, filter.drawable)
}
}
},
onShowFeedback = {
isShowingSettingMenu = false
isShowingFeedbackDialog = true
},
onToggleBackgroundBlur = {
isBackgroundBlurEnabled = !isBackgroundBlurEnabled
isShowingSettingMenu = false
},
onShowCallStats = {
isShowingStats = true
isShowingSettingMenu = false
},
)
) {
isShowingStats = true
isShowingSettingMenu = false
}
}

if (isShowingFeedbackDialog) {
Expand Down Expand Up @@ -511,7 +524,7 @@ fun CallScreen(
},
negativeButton = Triple(
"Leave",
VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
) {
showRecordingWarning = false
acceptedCallRecording = false
Expand All @@ -534,7 +547,7 @@ fun CallScreen(
},
negativeButton = Triple(
"Cancel",
VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
) {
showEndRecordingDialog = false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fun FeedbackDialog(call: Call, onDismiss: () -> Unit) {
StreamButton(
modifier = Modifier.align(Alignment.BottomEnd),
text = "Close",
style = VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
style = VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
) {
onDismiss()
}
Expand Down Expand Up @@ -190,7 +190,7 @@ fun FeedbackDialog(call: Call, onDismiss: () -> Unit) {
},
negativeButton = Triple(
"Not now",
ButtonStyles.tetriaryButtonStyle(StyleSize.S),
ButtonStyles.tertiaryButtonStyle(StyleSize.S),
) {
onDismiss()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private fun CallJoinHeader(
StreamButton(
modifier = Modifier.fillMaxWidth(),
icon = Icons.Default.Logout,
style = VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
style = VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
text = stringResource(id = R.string.sign_out),
onClick = {
showMenu = false
Expand Down Expand Up @@ -390,7 +390,7 @@ private fun CallActualContent(
)
Spacer(modifier = Modifier.height(VideoTheme.dimens.spacingS))
StreamButton(
style = VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
style = VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
modifier = Modifier
.fillMaxWidth()
.testTag("scan_qr_code"),
Expand Down Expand Up @@ -520,7 +520,7 @@ private fun SignOutDialog(
},
negativeButton = Triple(
stringResource(R.string.cancel),
VideoTheme.styles.buttonStyles.tetriaryButtonStyle(),
VideoTheme.styles.buttonStyles.tertiaryButtonStyle(),
) {
onDismissRequest()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private fun LoginContent(
icon = Icons.Outlined.GroupAdd,
enabled = !isLoading,
text = stringResource(id = R.string.random_user_sign_in),
style = ButtonStyles.tetriaryButtonStyle(),
style = ButtonStyles.tertiaryButtonStyle(),
onClick = {
login(true, null)
},
Expand Down Expand Up @@ -394,7 +394,7 @@ fun SelectableDialog(
selectedText = item.displayName
showDialog = !showDialog
},
style = ButtonStyles.tetriaryButtonStyle(),
style = ButtonStyles.tertiaryButtonStyle(),
modifier = Modifier.padding(horizontal = 8.dp).fillMaxWidth(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import androidx.compose.material.icons.automirrored.filled.ReadMore
import androidx.compose.material.icons.filled.Audiotrack
import androidx.compose.material.icons.filled.AutoGraph
import androidx.compose.material.icons.filled.BluetoothAudio
import androidx.compose.material.icons.filled.BlurOff
import androidx.compose.material.icons.filled.BlurOn
import androidx.compose.material.icons.filled.Feedback
import androidx.compose.material.icons.filled.Headphones
import androidx.compose.material.icons.filled.HeadsetMic
Expand All @@ -51,10 +49,8 @@ fun defaultStreamMenu(
codecList: List<MediaCodecInfo>,
onCodecSelected: (MediaCodecInfo) -> Unit,
isScreenShareEnabled: Boolean,
isBackgroundBlurEnabled: Boolean,
onToggleScreenShare: () -> Unit = {},
onShowCallStats: () -> Unit,
onToggleBackgroundBlurClick: () -> Unit,
onToggleAudioFilterClick: () -> Unit,
onRestartSubscriberIceClick: () -> Unit,
onRestartPublisherIceClick: () -> Unit,
Expand All @@ -79,13 +75,6 @@ fun defaultStreamMenu(
action = onShowCallStats,
),
)
add(
ActionMenuItem(
title = if (isBackgroundBlurEnabled) "Disable background blur" else "Enable background blur",
icon = if (isBackgroundBlurEnabled) Icons.Default.BlurOff else Icons.Default.BlurOn,
action = onToggleBackgroundBlurClick,
),
)
add(
SubMenuItem(
title = "Choose audio device",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import android.app.Activity
import android.app.DownloadManager
import android.content.Context
import android.content.Context.DOWNLOAD_SERVICE
import android.graphics.Bitmap
import android.media.MediaCodecList
import android.media.projection.MediaProjectionManager
import android.net.Uri
Expand All @@ -30,6 +29,8 @@ import android.os.Environment
import android.widget.Toast
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.VideoFile
import androidx.compose.runtime.Composable
Expand All @@ -39,6 +40,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.IntOffset
Expand All @@ -51,27 +53,25 @@ import com.google.accompanist.permissions.rememberPermissionState
import io.getstream.video.android.compose.theme.VideoTheme
import io.getstream.video.android.core.Call
import io.getstream.video.android.core.call.audio.AudioFilter
import io.getstream.video.android.core.call.video.BitmapVideoFilter
import io.getstream.video.android.core.mapper.ReactionMapper
import io.getstream.video.android.tooling.extensions.toPx
import io.getstream.video.android.ui.call.ReactionsMenu
import io.getstream.video.android.ui.menu.base.ActionMenuItem
import io.getstream.video.android.ui.menu.base.DynamicMenu
import io.getstream.video.android.ui.menu.base.MenuItem
import io.getstream.video.android.util.BlurredBackgroundVideoFilter
import io.getstream.video.android.util.SampleAudioFilter
import io.getstream.video.android.util.filters.SampleAudioFilter
import kotlinx.coroutines.launch
import java.nio.ByteBuffer

@OptIn(ExperimentalComposeUiApi::class, ExperimentalPermissionsApi::class)
@Composable
internal fun SettingsMenu(
call: Call,
selectedVideoFilter: Int,
showDebugOptions: Boolean,
isBackgroundBlurEnabled: Boolean,
onDismissed: () -> Unit,
onSelectVideoFilter: (Int) -> Unit,
onShowFeedback: () -> Unit,
onToggleBackgroundBlur: () -> Unit,
onShowCallStats: () -> Unit,
) {
val context = LocalContext.current
Expand Down Expand Up @@ -103,26 +103,10 @@ internal fun SettingsMenu(
}
}

val onToggleBackgroundBlurClick: () -> Unit = {
onToggleBackgroundBlur()

if (call.videoFilter == null) {
call.videoFilter = object : BitmapVideoFilter() {
val filter = BlurredBackgroundVideoFilter()

override fun filter(bitmap: Bitmap) {
filter.applyFilter(bitmap)
}
}
} else {
call.videoFilter = null
}
}

val onToggleAudioFilterClick: () -> Unit = {
if (call.audioFilter == null) {
call.audioFilter = object : AudioFilter {
override fun filter(
override fun applyFilter(
audioFormat: Int,
channelCount: Int,
sampleRate: Int,
Expand Down Expand Up @@ -211,6 +195,15 @@ internal fun SettingsMenu(
) {
onDismissed()
}
Spacer(Modifier.height(VideoTheme.dimens.spacingS))
VideoFiltersMenu(
selectedFilterIndex = selectedVideoFilter,
onSelectFilter = { filterIndex ->
onDismissed()
onSelectVideoFilter(filterIndex)
},
)
Spacer(Modifier.height(VideoTheme.dimens.spacingS))
},
items = defaultStreamMenu(
showDebugOptions = showDebugOptions,
Expand All @@ -229,10 +222,8 @@ internal fun SettingsMenu(
onRestartPublisherIceClick = onRestartPublisherIceClick,
onRestartSubscriberIceClick = onRestartSubscriberIceClick,
onToggleAudioFilterClick = onToggleAudioFilterClick,
onToggleBackgroundBlurClick = onToggleBackgroundBlurClick,
onSwitchSfuClick = onSwitchSfuClick,
onShowCallStats = onShowCallStats,
isBackgroundBlurEnabled = isBackgroundBlurEnabled,
isScreenShareEnabled = isScreenSharing,
loadRecordings = onLoadRecordings,
),
Expand Down Expand Up @@ -284,18 +275,15 @@ private fun SettingsMenuPreview() {
onCodecSelected = {
},
isScreenShareEnabled = false,
isBackgroundBlurEnabled = true,
onToggleScreenShare = { },
onShowCallStats = { },
onToggleBackgroundBlurClick = { },
onToggleAudioFilterClick = { },
onRestartSubscriberIceClick = { },
onRestartPublisherIceClick = { },
onKillSfuWsClick = { },
onSwitchSfuClick = { },
availableDevices = emptyList(),
onDeviceSelected = {
},
onDeviceSelected = {},
onShowFeedback = {},
loadRecordings = { emptyList() },
),
Expand Down
Loading

0 comments on commit 591ee86

Please sign in to comment.