Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ subprojects {
allWarningsAsErrors = true
}

// Required while Compose is built on a compiler that is somewhere in between Kotlin
// 1.3 and 1.4. Otherwise you'll see errors like "Runtime JAR file has version 1.3 which
// is older than required for API version 1.4"
apiVersion = "1.3"

freeCompilerArgs = listOf(
"-Xopt-in=kotlin.RequiresOptIn"
)
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
}

dependencies {
implementation("com.android.tools.build:gradle:7.0.0-alpha14")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0")
implementation("com.android.tools.build:gradle:7.1.0-alpha01")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/DefaultAndroidConfigPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class DefaultAndroidConfigPlugin : Plugin<Project> {
}

defaultConfig {
minSdkVersion(21)
targetSdkVersion(Versions.targetSdk)
minSdk = 21
targetSdk = Versions.targetSdk
versionCode = 1
versionName = "1.0"

Expand Down
6 changes: 3 additions & 3 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
object Versions {
const val targetSdk = 29
const val compose = "1.0.0-beta05"
const val compose = "1.0.0-beta07"
}

object Dependencies {
object AndroidX {
const val appcompat = "androidx.appcompat:appcompat:1.3.0-beta01"
const val appcompat = "androidx.appcompat:appcompat:1.3.0"

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

object Compose {
const val activity = "androidx.activity:activity-compose:1.3.0-alpha02"
const val activity = "androidx.activity:activity-compose:1.3.0-alpha08"
const val foundation = "androidx.compose.foundation:foundation:${Versions.compose}"
const val icons = "androidx.compose.material:material-icons-extended:${Versions.compose}"
const val material = "androidx.compose.material:material:${Versions.compose}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.SaveableStateHolder
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.ui.layout.SubcomposeLayout

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

/**
Expand All @@ -82,4 +85,18 @@ internal class SaveableScreenStateHolder<T>(private val holder: SaveableStateHol
}
}
}

/**
* TODO Remove this when the bug is fixed.
* See https://issuetracker.google.com/issues/188567661#comment2.
*/
@Composable private fun WorkaroundComposeStateBug(content: @Composable () -> Unit) {
SubcomposeLayout { constraints ->
val measurable = subcompose(Unit, content).single()
val placeable = measurable.measure(constraints)
layout(placeable.width, placeable.height) {
placeable.placeRelative(0, 0)
}
}
}
}