diff --git a/build.gradle b/build.gradle index f047a9ba00..aceb5f108f 100644 --- a/build.gradle +++ b/build.gradle @@ -111,7 +111,13 @@ subprojects { } } - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { + // Create a configuration which allows us to intercept the JARs, and add them to + // Kotlin Compiler freeCompilerArgs. This is needed because we can't currently use the + // built-in `compose` feature in AGP, since it depends on the old Compose Compiler artifacts. + // TODO: Remove this once AGP uses the new Compose Compiler artifact name + def compilerPluginConfig = project.configurations.create("kotlinCompilerPlugin") + + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile -> kotlinOptions { // Treat all Kotlin warnings as errors allWarningsAsErrors = true @@ -128,6 +134,17 @@ subprojects { // Set JVM target to 1.8 jvmTarget = "1.8" } + + compile.dependsOn(compilerPluginConfig) + compile.doFirst { + if (!compilerPluginConfig.isEmpty()) { + // Add the compiler plugin JARs using the -Xplugin flag + compile.kotlinOptions.freeCompilerArgs += + "-Xplugin=${compilerPluginConfig.files.first()}" + // Need to turn on the IR compiler too + compile.kotlinOptions.useIR = true + } + } } } diff --git a/buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt b/buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt index 0fa3e06403..5bd13d2981 100644 --- a/buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt +++ b/buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt @@ -21,7 +21,7 @@ object Versions { } object Libs { - const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha10" + const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha11" const val gradlePlayPublisher = "com.github.triplet.gradle:play-publisher:3.0.0" @@ -59,7 +59,7 @@ object Libs { } object Accompanist { - private const val version = "0.2.2.ui-6824694-SNAPSHOT" + private const val version = "0.2.3.compose-6854728-SNAPSHOT" const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version" } @@ -164,13 +164,15 @@ object Libs { } object Compose { - const val snapshot = "6824694" + const val snapshot = "6854728" const val version = "1.0.0-SNAPSHOT" @get:JvmStatic val snapshotUrl: String get() = "https://androidx.dev/snapshots/builds/$snapshot/artifacts/ui/repository/" + const val compiler = "androidx.compose.compiler:compiler:$version" + const val runtime = "androidx.compose.runtime:runtime:$version" const val livedata = "androidx.compose.runtime:runtime-livedata:$version" diff --git a/common-ui-compose/build.gradle b/common-ui-compose/build.gradle index ca153f0c5c..69ab527631 100644 --- a/common-ui-compose/build.gradle +++ b/common-ui-compose/build.gradle @@ -34,7 +34,13 @@ android { } buildFeatures { - compose true + // We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the + // Compose compiler artifact has changed artifact group/name. + // Instead we add the compiler manually below in the dependencies {}. Also see + // the root build.gradle for info on how to apply the plugin. + // TODO: remove this once we upgrade to an AGP version which uses the new artifact details + + // compose true } composeOptions { @@ -51,6 +57,9 @@ dependencies { implementation Libs.AndroidX.coreKtx implementation Libs.AndroidX.Lifecycle.livedata + // Temporary workaround (see above) + kotlinCompilerPlugin Libs.AndroidX.Compose.compiler + implementation Libs.AndroidX.Compose.runtime implementation Libs.AndroidX.Compose.foundation implementation Libs.AndroidX.Compose.ui diff --git a/common-ui-compose/src/main/java/app/tivi/common/compose/ExpandingFloatingActionButton.kt b/common-ui-compose/src/main/java/app/tivi/common/compose/ExpandingFloatingActionButton.kt index 469ad0349e..0c7c769097 100644 --- a/common-ui-compose/src/main/java/app/tivi/common/compose/ExpandingFloatingActionButton.kt +++ b/common-ui-compose/src/main/java/app/tivi/common/compose/ExpandingFloatingActionButton.kt @@ -18,8 +18,7 @@ package app.tivi.common.compose import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.ExperimentalAnimationApi -import androidx.compose.foundation.Box -import androidx.compose.foundation.ContentGravity +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.padding @@ -29,6 +28,7 @@ import androidx.compose.material.FloatingActionButton import androidx.compose.material.MaterialTheme import androidx.compose.material.contentColorFor import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape @@ -56,7 +56,7 @@ fun ExpandableFloatingActionButton( shape = shape, modifier = modifier ) { - Row(verticalAlignment = ContentGravity.CenterVertically) { + Row(verticalAlignment = Alignment.CenterVertically) { AnimatedVisibility(visible = expanded) { Spacer(Modifier.preferredWidth(20.dp)) } diff --git a/common-ui-compose/src/main/java/app/tivi/common/compose/PosterCard.kt b/common-ui-compose/src/main/java/app/tivi/common/compose/PosterCard.kt index 1bf74e192c..fbadc33f1d 100644 --- a/common-ui-compose/src/main/java/app/tivi/common/compose/PosterCard.kt +++ b/common-ui-compose/src/main/java/app/tivi/common/compose/PosterCard.kt @@ -18,7 +18,7 @@ package app.tivi.common.compose import androidx.compose.foundation.Text import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Stack +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.material.Card import androidx.compose.material.EmphasisAmbient @@ -30,7 +30,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import app.tivi.data.entities.TiviShow import app.tivi.data.entities.TmdbImageEntity -import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade +import dev.chrisbanes.accompanist.coil.CoilImage @Composable fun PosterCard( @@ -40,7 +40,7 @@ fun PosterCard( modifier: Modifier = Modifier ) { Card(modifier = modifier) { - Stack( + Box( modifier = if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier ) { // TODO: remove text if the image has loaded (and animated in). @@ -53,8 +53,9 @@ fun PosterCard( ) } if (poster != null) { - CoilImageWithCrossfade( + CoilImage( data = poster, + fadeIn = true, modifier = Modifier.matchParentSize() ) } diff --git a/common-ui-compose/src/main/java/app/tivi/common/compose/vector.kt b/common-ui-compose/src/main/java/app/tivi/common/compose/vector.kt index 5179a51c72..b7cf99eadd 100644 --- a/common-ui-compose/src/main/java/app/tivi/common/compose/vector.kt +++ b/common-ui-compose/src/main/java/app/tivi/common/compose/vector.kt @@ -17,8 +17,8 @@ package app.tivi.common.compose import androidx.annotation.DrawableRes -import androidx.compose.foundation.Box import androidx.compose.foundation.contentColor +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment diff --git a/ui-account/build.gradle b/ui-account/build.gradle index 2a3c51b8bc..e3be46772e 100644 --- a/ui-account/build.gradle +++ b/ui-account/build.gradle @@ -41,7 +41,13 @@ android { } buildFeatures { - compose true + // We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the + // Compose compiler artifact has changed artifact group/name. + // Instead we add the compiler manually below in the dependencies {}. Also see + // the root build.gradle for info on how to apply the plugin. + // TODO: remove this once we upgrade to an AGP version which uses the new artifact details + + // compose true } composeOptions { @@ -56,10 +62,8 @@ dependencies { implementation project(':domain') implementation project(':common-ui-view') implementation project(':common-ui-compose') - implementation project(':trakt-auth') - implementation Libs.AndroidX.Lifecycle.livedata implementation Libs.AndroidX.Lifecycle.viewmodel @@ -68,6 +72,9 @@ dependencies { implementation Libs.AndroidX.Fragment.fragmentKtx implementation Libs.AndroidX.Navigation.fragment + // Temporary workaround (see above) + kotlinCompilerPlugin Libs.AndroidX.Compose.compiler + implementation Libs.AndroidX.Compose.runtime implementation Libs.AndroidX.Compose.foundation implementation Libs.AndroidX.Compose.ui diff --git a/ui-account/src/main/java/app/tivi/account/AccountUi.kt b/ui-account/src/main/java/app/tivi/account/AccountUi.kt index e5d339e06a..27b7fb47e7 100644 --- a/ui-account/src/main/java/app/tivi/account/AccountUi.kt +++ b/ui-account/src/main/java/app/tivi/account/AccountUi.kt @@ -48,7 +48,7 @@ import androidx.ui.tooling.preview.Preview import app.tivi.common.compose.VectorImage import app.tivi.data.entities.TraktUser import app.tivi.trakt.TraktAuthState -import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade +import dev.chrisbanes.accompanist.coil.CoilImage import org.threeten.bp.OffsetDateTime import org.threeten.bp.ZoneOffset @@ -116,8 +116,9 @@ private fun UserRow( ) { val avatarUrl = user.avatarUrl if (avatarUrl != null) { - CoilImageWithCrossfade( + CoilImage( data = avatarUrl, + fadeIn = true, modifier = Modifier.preferredSize(40.dp) .clip(RoundedCornerShape(50)) ) diff --git a/ui-discover/build.gradle b/ui-discover/build.gradle index e8dd732a6c..6e1bd19485 100644 --- a/ui-discover/build.gradle +++ b/ui-discover/build.gradle @@ -42,7 +42,13 @@ android { } buildFeatures { - compose true + // We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the + // Compose compiler artifact has changed artifact group/name. + // Instead we add the compiler manually below in the dependencies {}. Also see + // the root build.gradle for info on how to apply the plugin. + // TODO: remove this once we upgrade to an AGP version which uses the new artifact details + + // compose true } composeOptions { @@ -67,6 +73,9 @@ dependencies { implementation Libs.AndroidX.Fragment.fragmentKtx implementation Libs.AndroidX.Navigation.fragment + // Temporary workaround (see above) + kotlinCompilerPlugin Libs.AndroidX.Compose.compiler + implementation Libs.AndroidX.Compose.runtime implementation Libs.AndroidX.Compose.foundation implementation Libs.AndroidX.Compose.ui diff --git a/ui-discover/src/main/java/app/tivi/home/discover/Discover.kt b/ui-discover/src/main/java/app/tivi/home/discover/Discover.kt index ff23ef4635..8784d21771 100644 --- a/ui-discover/src/main/java/app/tivi/home/discover/Discover.kt +++ b/ui-discover/src/main/java/app/tivi/home/discover/Discover.kt @@ -21,13 +21,12 @@ import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.foundation.Icon import androidx.compose.foundation.Text import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope.align -import androidx.compose.foundation.layout.RowScope.alignWithSiblings +import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.Stack import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth @@ -80,7 +79,7 @@ fun Discover( actioner: (DiscoverAction) -> Unit ) { Surface(Modifier.fillMaxSize()) { - Stack(Modifier.fillMaxSize()) { + Box(Modifier.fillMaxSize()) { var appBarHeight by rememberMutableState { 0 } LazyColumn(Modifier.fillMaxSize()) { @@ -273,7 +272,7 @@ private fun Header( title: String, modifier: Modifier = Modifier, loading: Boolean = false, - action: (@Composable () -> Unit)? = null + action: @Composable RowScope.() -> Unit = {} ) { Row(modifier) { Spacer(Modifier.preferredWidth(16.dp)) @@ -296,7 +295,7 @@ private fun Header( ) } - if (action != null) action() + action() Spacer(Modifier.preferredWidth(16.dp)) } diff --git a/ui-episodedetails/build.gradle b/ui-episodedetails/build.gradle index b73cc362e7..8fc56c3edd 100644 --- a/ui-episodedetails/build.gradle +++ b/ui-episodedetails/build.gradle @@ -49,7 +49,13 @@ android { } buildFeatures { - compose true + // We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the + // Compose compiler artifact has changed artifact group/name. + // Instead we add the compiler manually below in the dependencies {}. Also see + // the root build.gradle for info on how to apply the plugin. + // TODO: remove this once we upgrade to an AGP version which uses the new artifact details + + // compose true } composeOptions { @@ -73,6 +79,9 @@ dependencies { implementation Libs.AndroidX.Fragment.fragment implementation Libs.AndroidX.Fragment.fragmentKtx + // Temporary workaround (see above) + kotlinCompilerPlugin Libs.AndroidX.Compose.compiler + implementation Libs.AndroidX.Compose.runtime implementation Libs.AndroidX.Compose.foundation implementation Libs.AndroidX.Compose.ui diff --git a/ui-episodedetails/src/main/java/app/tivi/episodedetails/EpisodeDetails.kt b/ui-episodedetails/src/main/java/app/tivi/episodedetails/EpisodeDetails.kt index fa12d7c435..68e5a11c8c 100644 --- a/ui-episodedetails/src/main/java/app/tivi/episodedetails/EpisodeDetails.kt +++ b/ui-episodedetails/src/main/java/app/tivi/episodedetails/EpisodeDetails.kt @@ -28,10 +28,10 @@ import androidx.compose.foundation.ScrollableColumn import androidx.compose.foundation.Text import androidx.compose.foundation.background import androidx.compose.foundation.contentColor +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.Stack import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize @@ -100,7 +100,7 @@ import app.tivi.data.entities.EpisodeWatchEntry import app.tivi.data.entities.PendingAction import app.tivi.data.entities.Season import app.tivi.ui.animations.lerp -import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade +import dev.chrisbanes.accompanist.coil.CoilImage import kotlinx.coroutines.launch import org.threeten.bp.OffsetDateTime import kotlin.math.absoluteValue @@ -112,9 +112,9 @@ fun EpisodeDetails( viewState: EpisodeDetailsViewState, actioner: (EpisodeDetailsAction) -> Unit ) { - Stack { + Box { Column { - Stack { + Box { if (viewState.episode != null && viewState.season != null) { Backdrop( season = viewState.season, @@ -246,10 +246,11 @@ private fun Backdrop( modifier: Modifier ) { Surface(modifier = modifier) { - Stack(Modifier.fillMaxSize()) { + Box(Modifier.fillMaxSize()) { if (episode.tmdbBackdropPath != null) { - CoilImageWithCrossfade( + CoilImage( data = episode, + fadeIn = true, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize() ) @@ -449,7 +450,7 @@ private fun EpisodeWatchSwipeBackground( toState = wouldCompleteOnRelease ) - Stack( + Box( Modifier.fillMaxSize() .background(MaterialTheme.colors.onSurface.copy(alpha = 0.2f), RectangleShape) ) { diff --git a/ui-showdetails/build.gradle b/ui-showdetails/build.gradle index 1a4949bfef..36dadcd125 100644 --- a/ui-showdetails/build.gradle +++ b/ui-showdetails/build.gradle @@ -49,7 +49,13 @@ android { } buildFeatures { - compose true + // We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the + // Compose compiler artifact has changed artifact group/name. + // Instead we add the compiler manually below in the dependencies {}. Also see + // the root build.gradle for info on how to apply the plugin. + // TODO: remove this once we upgrade to an AGP version which uses the new artifact details + + // compose true } composeOptions { @@ -78,6 +84,9 @@ dependencies { implementation Libs.Insetter.ktx + // Temporary workaround (see above) + kotlinCompilerPlugin Libs.AndroidX.Compose.compiler + implementation Libs.AndroidX.Compose.runtime implementation Libs.AndroidX.Compose.foundation implementation Libs.AndroidX.Compose.ui diff --git a/ui-showdetails/src/main/java/app/tivi/showdetails/details/ShowDetails.kt b/ui-showdetails/src/main/java/app/tivi/showdetails/details/ShowDetails.kt index d24e8fd6c2..629ca90b30 100644 --- a/ui-showdetails/src/main/java/app/tivi/showdetails/details/ShowDetails.kt +++ b/ui-showdetails/src/main/java/app/tivi/showdetails/details/ShowDetails.kt @@ -18,7 +18,6 @@ package app.tivi.showdetails.details import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.ExperimentalAnimationApi -import androidx.compose.foundation.Box import androidx.compose.foundation.Icon import androidx.compose.foundation.ScrollState import androidx.compose.foundation.ScrollableColumn @@ -27,6 +26,7 @@ import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.contentColor import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ConstraintLayout import androidx.compose.foundation.layout.ExperimentalLayout @@ -126,7 +126,6 @@ import app.tivi.data.views.FollowedShowsWatchStats import app.tivi.ui.animations.lerp import coil.request.ImageRequest import dev.chrisbanes.accompanist.coil.CoilImage -import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade import kotlinx.coroutines.launch import org.threeten.bp.OffsetDateTime @@ -251,8 +250,9 @@ private fun ShowDetailsScrollingContent( .onSizeChanged(onBackdropSizeChanged) ) { if (backdropImage != null) { - CoilImageWithCrossfade( + CoilImage( data = backdropImage, + fadeIn = true, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize().offset { size -> Offset( @@ -282,8 +282,9 @@ private fun ShowDetailsScrollingContent( if (posterImage != null) { Spacer(modifier = Modifier.preferredWidth(16.dp)) - CoilImageWithCrossfade( + CoilImage( data = posterImage, + fadeIn = true, alignment = Alignment.TopStart, modifier = Modifier.weight(1f, fill = false) .aspectRatio(2 / 3f)