Skip to content

Commit 470a14c

Browse files
Upgrade AGP, Compose, Dokka, and Kotlin.
1 parent a123f6b commit 470a14c

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

build.gradle.kts

-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ subprojects {
3838
allWarningsAsErrors = true
3939
}
4040

41-
// Required while Compose is built on a compiler that is somewhere in between Kotlin
42-
// 1.3 and 1.4. Otherwise you'll see errors like "Runtime JAR file has version 1.3 which
43-
// is older than required for API version 1.4"
44-
apiVersion = "1.3"
45-
4641
freeCompilerArgs = listOf(
4742
"-Xopt-in=kotlin.RequiresOptIn"
4843
)

buildSrc/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repositories {
99
}
1010

1111
dependencies {
12-
implementation("com.android.tools.build:gradle:7.0.0-alpha14")
13-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
14-
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0")
12+
implementation("com.android.tools.build:gradle:7.1.0-alpha01")
13+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
14+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
1515
}

buildSrc/src/main/java/DefaultAndroidConfigPlugin.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class DefaultAndroidConfigPlugin : Plugin<Project> {
2222
}
2323

2424
defaultConfig {
25-
minSdkVersion(21)
26-
targetSdkVersion(Versions.targetSdk)
25+
minSdk = 21
26+
targetSdk = Versions.targetSdk
2727
versionCode = 1
2828
versionName = "1.0"
2929

buildSrc/src/main/java/Dependencies.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
object Versions {
22
const val targetSdk = 29
3-
const val compose = "1.0.0-beta05"
3+
const val compose = "1.0.0-beta07"
44
}
55

66
object Dependencies {
77
object AndroidX {
8-
const val appcompat = "androidx.appcompat:appcompat:1.3.0-beta01"
8+
const val appcompat = "androidx.appcompat:appcompat:1.3.0"
99

1010
// Note that we're not using the actual androidx material dep yet, it's still alpha.
1111
const val material = "com.google.android.material:material:1.1.0"
@@ -14,7 +14,7 @@ object Dependencies {
1414
}
1515

1616
object Compose {
17-
const val activity = "androidx.activity:activity-compose:1.3.0-alpha02"
17+
const val activity = "androidx.activity:activity-compose:1.3.0-alpha08"
1818
const val foundation = "androidx.compose.foundation:foundation:${Versions.compose}"
1919
const val icons = "androidx.compose.material:material-icons-extended:${Versions.compose}"
2020
const val material = "androidx.compose.material:material:${Versions.compose}"

compose-backstack/src/main/java/com/zachklipp/compose/backstack/SaveableScreenStateHolder.kt

+18-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.compose.runtime.key
77
import androidx.compose.runtime.remember
88
import androidx.compose.runtime.saveable.SaveableStateHolder
99
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
10+
import androidx.compose.ui.layout.SubcomposeLayout
1011

1112
@Composable internal fun <T> rememberSaveableScreenStateHolder(): SaveableScreenStateHolder<T> {
1213
val stateHolder = rememberSaveableStateHolder()
@@ -62,7 +63,9 @@ internal class SaveableScreenStateHolder<T>(private val holder: SaveableStateHol
6263
// composed again. We have to use the compose-generated int stateKey, even though this function
6364
// accepts Any, because it doesn't _actually_ accept Any – it only accepts values that are
6465
// saveable, and the backstack item may not be saveable.
65-
holder.SaveableStateProvider(stateKey, content)
66+
holder.SaveableStateProvider(stateKey) {
67+
WorkaroundComposeStateBug(content)
68+
}
6669
}
6770

6871
/**
@@ -82,4 +85,18 @@ internal class SaveableScreenStateHolder<T>(private val holder: SaveableStateHol
8285
}
8386
}
8487
}
88+
89+
/**
90+
* TODO Remove this when the bug is fixed.
91+
* See https://issuetracker.google.com/issues/188567661#comment2.
92+
*/
93+
@Composable private fun WorkaroundComposeStateBug(content: @Composable () -> Unit) {
94+
SubcomposeLayout { constraints ->
95+
val measurable = subcompose(Unit, content).single()
96+
val placeable = measurable.measure(constraints)
97+
layout(placeable.width, placeable.height) {
98+
placeable.placeRelative(0, 0)
99+
}
100+
}
101+
}
85102
}

0 commit comments

Comments
 (0)