Skip to content

Commit 0a4739d

Browse files
authored
[Jetcaster] Update to SNAPSHOT 6860046 (android#192)
* Update to SNAPSHOT 6860046 * Remove explicit runtime dependency * Remove commented out Modifier.align * Try forcing downgrade of R8
1 parent c6ebe25 commit 0a4739d

File tree

7 files changed

+52
-22
lines changed

7 files changed

+52
-22
lines changed

Jetcaster/app/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ android {
8484
}
8585

8686
buildFeatures {
87-
compose true
87+
// We turn off the Compose feature for now, due to using Compose SNAPSHOTs where the
88+
// Compose compiler artifact has changed artifact group/name.
89+
// Instead we add the compiler manually below in the dependencies {}. Also see
90+
// the root build.gradle for info on how to apply the plugin.
91+
// TODO: remove this once we upgrade to an AGP version which uses the new artifact details
92+
93+
// compose true
8894
}
8995

9096
composeOptions {
@@ -104,6 +110,8 @@ dependencies {
104110

105111
implementation Libs.AndroidX.Lifecycle.viewmodel
106112

113+
kotlinCompilerPlugin Libs.AndroidX.Compose.compiler
114+
107115
implementation Libs.AndroidX.Compose.foundation
108116
implementation Libs.AndroidX.Compose.material
109117
implementation Libs.AndroidX.Compose.materialIconsExtended

Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ import androidx.compose.foundation.Icon
2020
import androidx.compose.foundation.Image
2121
import androidx.compose.foundation.Text
2222
import androidx.compose.foundation.background
23+
import androidx.compose.foundation.layout.Box
2324
import androidx.compose.foundation.layout.Column
24-
import androidx.compose.foundation.layout.ColumnScope.align
2525
import androidx.compose.foundation.layout.Row
2626
import androidx.compose.foundation.layout.Spacer
27-
import androidx.compose.foundation.layout.Stack
2827
import androidx.compose.foundation.layout.aspectRatio
2928
import androidx.compose.foundation.layout.fillMaxHeight
3029
import androidx.compose.foundation.layout.fillMaxSize
@@ -282,7 +281,6 @@ fun HomeCategoryTabIndicator(
282281
Spacer(
283282
modifier.padding(horizontal = 24.dp)
284283
.preferredHeight(4.dp)
285-
.align(Alignment.CenterHorizontally)
286284
.background(color, RoundedCornerShape(topLeftPercent = 100, topRightPercent = 100))
287285
)
288286
}
@@ -323,7 +321,7 @@ private fun FollowedPodcastCarouselItem(
323321
Column(
324322
modifier.padding(horizontal = 12.dp, vertical = 8.dp)
325323
) {
326-
Stack(
324+
Box(
327325
Modifier
328326
.weight(1f)
329327
.align(Alignment.CenterHorizontally)

Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import androidx.compose.foundation.Image
2121
import androidx.compose.foundation.Text
2222
import androidx.compose.foundation.clickable
2323
import androidx.compose.foundation.contentColor
24+
import androidx.compose.foundation.layout.Box
2425
import androidx.compose.foundation.layout.Column
2526
import androidx.compose.foundation.layout.ConstraintLayout
2627
import androidx.compose.foundation.layout.Dimension
2728
import androidx.compose.foundation.layout.PaddingValues
2829
import androidx.compose.foundation.layout.Spacer
29-
import androidx.compose.foundation.layout.Stack
3030
import androidx.compose.foundation.layout.aspectRatio
3131
import androidx.compose.foundation.layout.fillMaxSize
3232
import androidx.compose.foundation.layout.fillMaxWidth
@@ -69,7 +69,7 @@ import com.example.jetcaster.ui.theme.JetcasterTheme
6969
import com.example.jetcaster.ui.theme.Keyline1
7070
import com.example.jetcaster.util.ToggleFollowPodcastIconButton
7171
import com.example.jetcaster.util.viewModelProviderFactoryOf
72-
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
72+
import dev.chrisbanes.accompanist.coil.CoilImage
7373
import java.time.format.DateTimeFormatter
7474
import java.time.format.FormatStyle
7575

@@ -142,8 +142,9 @@ fun EpisodeListItem(
142142

143143
if (podcast.imageUrl != null) {
144144
// If we have an image Url, we can show it using [CoilImage]
145-
CoilImageWithCrossfade(
145+
CoilImage(
146146
data = podcast.imageUrl,
147+
fadeIn = true,
147148
contentScale = ContentScale.Crop,
148149
loading = { /* TODO do something better here */ },
149150
modifier = Modifier.preferredSize(56.dp)
@@ -306,15 +307,16 @@ private fun TopPodcastRowItem(
306307
modifier: Modifier = Modifier
307308
) {
308309
Column(modifier) {
309-
Stack(
310+
Box(
310311
Modifier
311312
.fillMaxWidth()
312313
.aspectRatio(1f)
313314
.align(Alignment.CenterHorizontally)
314315
) {
315316
if (podcastImageUrl != null) {
316-
CoilImageWithCrossfade(
317+
CoilImage(
317318
data = podcastImageUrl,
319+
fadeIn = true,
318320
contentScale = ContentScale.Crop,
319321
loading = { /* TODO do something better here */ },
320322
modifier = Modifier.fillMaxSize().clip(MaterialTheme.shapes.medium)

Jetcaster/app/src/main/java/com/example/jetcaster/util/ItemSwitcher.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import androidx.compose.animation.asDisposableClock
2020
import androidx.compose.animation.core.TransitionDefinition
2121
import androidx.compose.animation.core.TransitionState
2222
import androidx.compose.animation.core.createAnimation
23-
import androidx.compose.foundation.layout.Stack
23+
import androidx.compose.foundation.layout.Box
2424
import androidx.compose.runtime.Composable
2525
import androidx.compose.runtime.invalidate
2626
import androidx.compose.runtime.key
@@ -93,7 +93,7 @@ fun <T> ItemSwitcher(
9393
}
9494
}
9595
}
96-
Stack(modifier) {
96+
Box(modifier) {
9797
state.invalidate = invalidate
9898
state.items.forEach { (item, transition) ->
9999
key(item) {

Jetcaster/app/src/main/java/com/example/jetcaster/util/Pager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import androidx.compose.animation.AnimatedFloatModel
2020
import androidx.compose.animation.core.AnimationClockObservable
2121
import androidx.compose.animation.core.AnimationEndReason
2222
import androidx.compose.animation.core.fling
23-
import androidx.compose.foundation.Box
24-
import androidx.compose.foundation.ContentGravity
2523
import androidx.compose.foundation.gestures.draggable
24+
import androidx.compose.foundation.layout.Box
2625
import androidx.compose.runtime.Composable
2726
import androidx.compose.runtime.Immutable
2827
import androidx.compose.runtime.getValue
@@ -31,6 +30,7 @@ import androidx.compose.runtime.mutableStateOf
3130
import androidx.compose.runtime.remember
3231
import androidx.compose.runtime.setValue
3332
import androidx.compose.runtime.structuralEqualityPolicy
33+
import androidx.compose.ui.Alignment
3434
import androidx.compose.ui.Layout
3535
import androidx.compose.ui.Measurable
3636
import androidx.compose.ui.Modifier
@@ -143,7 +143,7 @@ fun Pager(
143143
val pageData = PageData(page)
144144
val scope = PagerScope(state, page)
145145
key(pageData) {
146-
Box(gravity = ContentGravity.Center, modifier = pageData) {
146+
Box(alignment = Alignment.Center, modifier = pageData) {
147147
scope.pageContent()
148148
}
149149
}

Jetcaster/build.gradle

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import com.example.jetcaster.buildsrc.Libs
1818
import com.example.jetcaster.buildsrc.Versions
19-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2019

2120
buildscript {
2221
repositories {
@@ -25,6 +24,10 @@ buildscript {
2524
}
2625

2726
dependencies {
27+
// Downgrade R8 due to b/169095082
28+
// TODO remove this
29+
classpath 'com.android.tools:r8:2.1.66'
30+
2831
classpath Libs.androidGradlePlugin
2932
classpath Libs.Kotlin.gradlePlugin
3033
}
@@ -61,7 +64,13 @@ subprojects {
6164
}
6265
}
6366

64-
tasks.withType(KotlinCompile).all {
67+
// Create a configuration which allows us to intercept the JARs, and add them to
68+
// Kotlin Compiler freeCompilerArgs. This is needed because we can't currently use the
69+
// built-in `compose` feature in AGP, since it depends on the old Compose Compiler artifacts.
70+
// TODO: Remove this once AGP uses the new Compose Compiler artifact name
71+
def compilerPluginConfig = project.configurations.create("kotlinCompilerPlugin")
72+
73+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { compile ->
6574
kotlinOptions {
6675
// Treat all Kotlin warnings as errors
6776
allWarningsAsErrors = true
@@ -78,5 +87,16 @@ subprojects {
7887
// Set JVM target to 1.8
7988
jvmTarget = "1.8"
8089
}
90+
91+
compile.dependsOn(compilerPluginConfig)
92+
compile.doFirst {
93+
if (!compilerPluginConfig.isEmpty()) {
94+
// Add the compiler plugin JARs using the -Xplugin flag
95+
compile.kotlinOptions.freeCompilerArgs +=
96+
"-Xplugin=${compilerPluginConfig.files.first()}"
97+
// Need to turn on the IR compiler too
98+
compile.kotlinOptions.useIR = true
99+
}
100+
}
81101
}
82102
}

Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
package com.example.jetcaster.buildsrc
1818

1919
object Versions {
20-
const val ktlint = "0.38.1"
20+
const val ktlint = "0.39.0"
2121
}
2222

2323
object Libs {
24-
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha11"
24+
const val androidGradlePlugin = "com.android.tools.build:gradle:4.2.0-alpha12"
2525
const val jdkDesugar = "com.android.tools:desugar_jdk_libs:1.0.9"
2626

2727
const val junit = "junit:junit:4.13"
2828

2929
const val material = "com.google.android.material:material:1.1.0"
3030

3131
object Accompanist {
32-
private const val version = "0.2.2"
32+
private const val version = "0.2.3.compose-6860046-SNAPSHOT"
3333
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
3434
}
3535

@@ -61,8 +61,10 @@ object Libs {
6161
const val coreKtx = "androidx.core:core-ktx:1.5.0-alpha02"
6262

6363
object Compose {
64-
const val snapshot = ""
65-
const val version = "1.0.0-alpha03"
64+
const val snapshot = "6860046"
65+
const val version = "1.0.0-SNAPSHOT"
66+
67+
const val compiler = "androidx.compose.compiler:compiler:$version"
6668

6769
const val runtime = "androidx.compose.runtime:runtime:$version"
6870
const val foundation = "androidx.compose.foundation:foundation:${version}"

0 commit comments

Comments
 (0)