From fa44c8d35a793f662e1ef13aa588e7c80f9c1ea9 Mon Sep 17 00:00:00 2001 From: Jaewoong Eum Date: Tue, 10 Sep 2024 17:32:58 +0900 Subject: [PATCH] Migrate to Compose 1.7.0 stable and other compose relevant dependencies (#1177) --- .../io/getstream/video/AndroidCompose.kt | 3 +- .../android/ui/call/LandscapeControls.kt | 2 -- .../video/android/ui/call/LayoutChooser.kt | 3 -- .../android/ui/call/ParticipantsDialog.kt | 2 -- .../video/android/ui/login/LoginScreen.kt | 6 ++-- .../video/android/ui/menu/SettingsMenu.kt | 3 +- gradle/libs.versions.toml | 26 +++++++------- .../api/stream-video-android-ui-compose.api | 10 ++++-- ...eTheme.kt => StreamRippleConfiguration.kt} | 35 ++++++++----------- .../video/android/compose/theme/VideoTheme.kt | 19 +++++----- .../compose/ui/components/avatar/Avatar.kt | 4 +-- 11 files changed, 54 insertions(+), 59 deletions(-) rename stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/{StreamRippleTheme.kt => StreamRippleConfiguration.kt} (52%) diff --git a/build-logic/convention/src/main/kotlin/io/getstream/video/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/io/getstream/video/AndroidCompose.kt index 659a289666..a14f1234f2 100644 --- a/build-logic/convention/src/main/kotlin/io/getstream/video/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/io/getstream/video/AndroidCompose.kt @@ -8,6 +8,7 @@ import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.getByType import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension +import org.jetbrains.kotlin.compose.compiler.gradle.ComposeFeatureFlag /** * Configure Compose-specific options @@ -31,7 +32,7 @@ internal fun Project.configureAndroidCompose( } extensions.configure { - enableStrongSkippingMode = true + featureFlags.addAll(ComposeFeatureFlag.StrongSkipping, ComposeFeatureFlag.IntrinsicRemember) reportsDestination = layout.buildDirectory.dir("compose_compiler") stabilityConfigurationFile = rootProject.layout.projectDirectory.file("compose_compiler_config.conf") } diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LandscapeControls.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LandscapeControls.kt index 67379e3d52..2fdf65f63f 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LandscapeControls.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LandscapeControls.kt @@ -29,7 +29,6 @@ import androidx.compose.material.icons.filled.CallEnd import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue 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 @@ -48,7 +47,6 @@ import io.getstream.video.android.mock.StreamPreviewDataUtils import io.getstream.video.android.mock.previewCall import io.getstream.video.android.tooling.extensions.toPx -@OptIn(ExperimentalComposeUiApi::class) @Composable fun LandscapeControls(call: Call, onDismiss: () -> Unit) { val isCameraEnabled by call.camera.isEnabled.collectAsStateWithLifecycle() diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LayoutChooser.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LayoutChooser.kt index b4e135cd73..d6c9539fec 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LayoutChooser.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/LayoutChooser.kt @@ -14,13 +14,10 @@ * limitations under the License. */ -@file:OptIn(ExperimentalLayoutApi::class) - package io.getstream.video.android.ui.call import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.AutoAwesome diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/ParticipantsDialog.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/ParticipantsDialog.kt index ae39e7b058..be87934629 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/ParticipantsDialog.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/call/ParticipantsDialog.kt @@ -18,7 +18,6 @@ package io.getstream.video.android.ui.call import android.content.ClipboardManager import android.content.Context -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -100,7 +99,6 @@ fun ParticipantsList(call: Call) { ParticipantsListContent(call, clipboardManager, participants) } -@OptIn(ExperimentalFoundationApi::class) @Composable fun ParticipantsListContent( call: Call, diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/login/LoginScreen.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/login/LoginScreen.kt index 0730d5b048..bf37897108 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/login/LoginScreen.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/login/LoginScreen.kt @@ -27,7 +27,6 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -48,7 +47,7 @@ import androidx.compose.material.icons.filled.Email import androidx.compose.material.icons.filled.Settings import androidx.compose.material.icons.outlined.Adb import androidx.compose.material.icons.outlined.GroupAdd -import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material.ripple import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState @@ -408,7 +407,7 @@ private fun BuiltInUsersLoginDialog( .fillMaxWidth() .clickable( interactionSource = remember { MutableInteractionSource() }, - indication = rememberRipple(bounded = true), + indication = ripple(bounded = true), onClick = { login(true, LoginEvent.SignIn(user)) onDismissRequest() @@ -439,7 +438,6 @@ private fun BuiltInUsersLoginDialog( ) } -@OptIn(ExperimentalLayoutApi::class) @Composable fun SelectableDialog( items: List, diff --git a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt index c3fa19bb3e..7447eff3ce 100644 --- a/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt +++ b/demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt @@ -39,7 +39,6 @@ import androidx.compose.runtime.getValue 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 @@ -63,7 +62,7 @@ import io.getstream.video.android.util.filters.SampleAudioFilter import kotlinx.coroutines.launch import java.nio.ByteBuffer -@OptIn(ExperimentalComposeUiApi::class, ExperimentalPermissionsApi::class) +@OptIn(ExperimentalPermissionsApi::class) @Composable internal fun SettingsMenu( call: Call, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e2cfc4aa40..3420408de4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,11 +3,11 @@ androidGradlePlugin = "8.4.2" cameraCamera2 = "1.3.0" spotless = "6.21.0" nexusPlugin = "1.3.0" -kotlin = "2.0.0" -ksp = "2.0.0-1.0.22" -kotlinSerialization = "1.6.3" +kotlin = "2.0.20" +ksp = "2.0.20-1.0.25" +kotlinSerialization = "1.7.1" kotlinSerializationConverter = "1.0.0" -kotlinxCoroutines = "1.8.0" +kotlinxCoroutines = "1.8.1" kotlinDokka = "1.9.20" jvmTarget = "11" @@ -16,21 +16,21 @@ androidxMaterial = "1.11.0" androidxAppCompat = "1.6.1" androidxCore = "1.12.0" androidxAnnotation = "1.7.1" -androidxLifecycle = "2.7.0" +androidxLifecycle = "2.8.5" androidxStartup = "1.1.1" -androidxActivity = "1.9.0" +androidxActivity = "1.9.2" androidxDataStore = "1.0.0" googleService = "4.3.14" -androidxComposeBom = "2024.06.00" +androidxComposeBom = "2024.09.00" androidxComposeTracing = "1.0.0-beta01" androidxHiltNavigation = "1.2.0" -androidxComposeNavigation = "2.7.7" +androidxComposeNavigation = "2.8.0" composeStableMarker = "1.0.5" coil = "2.6.0" -landscapist = "2.3.5" -accompanist = "0.32.0" +landscapist = "2.3.6" +accompanist = "0.34.0" telephoto = "0.3.0" audioswitch = "1.1.8" libyuv = "0.30.0" @@ -44,7 +44,7 @@ tink = "1.9.0" turbine = "0.13.0" streamWebRTC = "1.1.2" -streamResult = "1.1.0" +streamResult = "1.2.0" streamChat = "6.0.13" streamLog = "1.1.4" streamPush = "1.1.7" @@ -72,10 +72,10 @@ playAppUpdate = "2.1.0" hilt = "2.51.1" leakCanary = "2.13" -binaryCompatabilityValidator = "0.14.0" +binaryCompatabilityValidator = "0.16.3" playPublisher = "3.8.4" -googleMlKitSelfieSegmentation = "16.0.0-beta4" +googleMlKitSelfieSegmentation = "16.0.0-beta6" [libraries] androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "cameraCamera2" } diff --git a/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api b/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api index 6daa63645b..cf9a49199b 100644 --- a/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api +++ b/stream-video-android-ui-compose/api/stream-video-android-ui-compose.api @@ -260,6 +260,12 @@ public final class io/getstream/video/android/compose/theme/StreamDimens$Compani public final fun defaultDimens (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/theme/StreamDimens; } +public final class io/getstream/video/android/compose/theme/StreamRippleConfiguration { + public static final field $stable I + public static final field INSTANCE Lio/getstream/video/android/compose/theme/StreamRippleConfiguration; + public final fun default (Landroidx/compose/runtime/Composer;I)Landroidx/compose/material/RippleConfiguration; +} + public final class io/getstream/video/android/compose/theme/StreamShapes { public static final field $stable I public static final field Companion Lio/getstream/video/android/compose/theme/StreamShapes$Companion; @@ -295,7 +301,7 @@ public abstract interface class io/getstream/video/android/compose/theme/StreamT public fun getColors (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/theme/StreamColors; public fun getDimens (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/theme/StreamDimens; public fun getReactionMapper (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/core/mapper/ReactionMapper; - public fun getRippleTheme (Landroidx/compose/runtime/Composer;I)Landroidx/compose/material/ripple/RippleTheme; + public fun getRippleConfiguration (Landroidx/compose/runtime/Composer;I)Landroidx/compose/material/RippleConfiguration; public fun getShapes (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/theme/StreamShapes; public fun getStyles (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/ui/components/base/styling/CompositeStyleProvider; public fun getTypography (Landroidx/compose/runtime/Composer;I)Lio/getstream/video/android/compose/theme/StreamTypography; @@ -350,7 +356,7 @@ public final class io/getstream/video/android/compose/theme/VideoTheme : io/gets } public final class io/getstream/video/android/compose/theme/VideoThemeKt { - public static final fun VideoTheme (ZLio/getstream/video/android/compose/theme/StreamColors;Lio/getstream/video/android/compose/theme/StreamDimens;Lio/getstream/video/android/compose/theme/StreamTypography;Lio/getstream/video/android/compose/theme/StreamShapes;Landroidx/compose/material/ripple/RippleTheme;Lio/getstream/video/android/core/mapper/ReactionMapper;ZLio/getstream/video/android/compose/ui/components/base/styling/CompositeStyleProvider;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V + public static final fun VideoTheme (ZLio/getstream/video/android/compose/theme/StreamColors;Lio/getstream/video/android/compose/theme/StreamDimens;Lio/getstream/video/android/compose/theme/StreamTypography;Lio/getstream/video/android/compose/theme/StreamShapes;Lio/getstream/video/android/compose/theme/StreamRippleConfiguration;Lio/getstream/video/android/core/mapper/ReactionMapper;ZLio/getstream/video/android/compose/ui/components/base/styling/CompositeStyleProvider;Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V } public final class io/getstream/video/android/compose/ui/ComposableSingletons$StreamCallActivityComposeDelegateKt { diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleTheme.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleConfiguration.kt similarity index 52% rename from stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleTheme.kt rename to stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleConfiguration.kt index 55427cd27c..9231b22ae1 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleTheme.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/StreamRippleConfiguration.kt @@ -14,36 +14,31 @@ * limitations under the License. */ +@file:OptIn(ExperimentalMaterialApi::class) + package io.getstream.video.android.compose.theme -import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.LocalContentColor +import androidx.compose.material.LocalRippleConfiguration import androidx.compose.material.MaterialTheme -import androidx.compose.material.ripple.RippleAlpha -import androidx.compose.material.ripple.RippleTheme +import androidx.compose.material.RippleConfiguration import androidx.compose.runtime.Composable -import androidx.compose.runtime.Immutable -import androidx.compose.ui.graphics.Color +import androidx.compose.runtime.ReadOnlyComposable /** - * A modified version of the default [RippleTheme] from [MaterialTheme] which + * A modified version of the default [RippleConfiguration] from [MaterialTheme] which * works in case the [MaterialTheme] is not initialized. */ -@Immutable -internal object StreamRippleTheme : RippleTheme { - @Composable - override fun defaultColor(): Color { - return RippleTheme.defaultRippleColor( - contentColor = LocalContentColor.current, - lightTheme = !isSystemInDarkTheme(), - ) - } +public object StreamRippleConfiguration { @Composable - override fun rippleAlpha(): RippleAlpha { - return RippleTheme.defaultRippleAlpha( - contentColor = LocalContentColor.current, - lightTheme = !isSystemInDarkTheme(), - ) + @ReadOnlyComposable + public fun default(): RippleConfiguration { + val rippleConfiguration = LocalRippleConfiguration.current + if (rippleConfiguration != null) return rippleConfiguration + + val contentColor = LocalContentColor.current + return RippleConfiguration(color = contentColor) } } diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/VideoTheme.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/VideoTheme.kt index 62c3d79156..58eb881d05 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/VideoTheme.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/theme/VideoTheme.kt @@ -20,8 +20,9 @@ package io.getstream.video.android.compose.theme import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box -import androidx.compose.material.ripple.LocalRippleTheme -import androidx.compose.material.ripple.RippleTheme +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.LocalRippleConfiguration +import androidx.compose.material.RippleConfiguration import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.ReadOnlyComposable @@ -72,18 +73,19 @@ private val LocalStyles = compositionLocalOf { * @param dimens The set of dimens we provide, wrapped in [StreamDimens]. * @param typography The set of typography styles we provide, wrapped in [StreamTypography]. * @param shapes The set of shapes we provide, wrapped in [StreamShapes]. - * @param rippleTheme Defines the appearance for ripples. + * @param rippleConfiguration Defines the appearance for ripples. * @param reactionMapper Defines a mapper of the emoji code from the reaction events. * @param content The content shown within the theme wrapper. */ @Composable +@OptIn(ExperimentalMaterialApi::class) public fun VideoTheme( isInDarkMode: Boolean = isSystemInDarkTheme(), colors: StreamColors = StreamColors.defaultColors(), dimens: StreamDimens = StreamDimens.defaultDimens(), typography: StreamTypography = StreamTypography.defaultTypography(colors, dimens), shapes: StreamShapes = StreamShapes.defaultShapes(dimens), - rippleTheme: RippleTheme = StreamRippleTheme, + rippleConfiguration: StreamRippleConfiguration = StreamRippleConfiguration, reactionMapper: ReactionMapper = ReactionMapper.defaultReactionMapper(), allowUIAutomationTest: Boolean = true, styles: CompositeStyleProvider = CompositeStyleProvider(), @@ -94,7 +96,7 @@ public fun VideoTheme( LocalDimens provides dimens, LocalTypography provides typography, LocalShapes provides shapes, - LocalRippleTheme provides rippleTheme, + LocalRippleConfiguration provides rippleConfiguration.default(), LocalReactionMapper provides reactionMapper, LocalStyles provides styles, ) { @@ -108,6 +110,7 @@ public fun VideoTheme( } } +@OptIn(ExperimentalMaterialApi::class) public interface StreamTheme { /** * Retrieves the current [StreamColors] at the call site's position in the hierarchy. @@ -138,11 +141,11 @@ public interface StreamTheme { get() = LocalShapes.current /** - * Retrieves the current [RippleTheme] at the call site's position in the hierarchy. + * Retrieves the current [RippleConfiguration] at the call site's position in the hierarchy. */ - public val rippleTheme: RippleTheme + public val rippleConfiguration: RippleConfiguration? @Composable @ReadOnlyComposable - get() = LocalRippleTheme.current + get() = StreamRippleConfiguration.default() /** * Retrieves the current [ReactionMapper] at the call site's position in the hierarchy. diff --git a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/avatar/Avatar.kt b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/avatar/Avatar.kt index 7362f9fa86..58041a0ff4 100644 --- a/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/avatar/Avatar.kt +++ b/stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/ui/components/avatar/Avatar.kt @@ -23,7 +23,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ripple.rememberRipple +import androidx.compose.material.ripple import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -107,7 +107,7 @@ internal fun Avatar( val clickableModifier: Modifier = if (onClick != null) { modifier.clickable( onClick = onClick, - indication = rememberRipple(bounded = false), + indication = ripple(bounded = false), interactionSource = remember { MutableInteractionSource() }, ) } else {