diff --git a/.gitignore b/.gitignore index 7ff29501cc..cb239629fc 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,6 @@ lcp.patch # direnv file containing Maven Central secrets .envrc + +# Kotlin +.kotlin/ diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 148fdd2469..c224ad564b 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/README.md b/README.md index db98a2bb8f..9d77ff4fa5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ | Readium | Android min SDK | Android compile SDK | Kotlin compiler (✻) | Gradle (✻) | |-----------|-----------------|---------------------|---------------------|------------| -| `develop` | 21 | 35 | 1.9.24 | 8.10.2 | +| `develop` | 21 | 35 | 2.0.21 | 8.10.2 | | 3.0.0 | 21 | 34 | 1.9.24 | 8.6.0 | | 2.3.0 | 21 | 33 | 1.7.10 | 6.9.3 | diff --git a/build.gradle.kts b/build.gradle.kts index 5a6a65465e..9d79e831e0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { alias(libs.plugins.dokka) alias(libs.plugins.ktlint) + alias(libs.plugins.compose.compiler) apply false } subprojects { diff --git a/gradle.properties b/gradle.properties index 947bc243bb..dd882096fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,3 +27,7 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official + +# FIXME: There are still a few issues with KSP and K2. It probably won't be ready until Room is +# updated to 2.7.0 (currently in alpha), and the KSP2 issue with @TypeConverters is fixed. +#ksp.useKSP2=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8589e26323..82ba693732 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -kotlin = "1.9.24" +kotlin = "2.0.21" agp = "8.7.2" desugar_jdk_libs = "2.0.4" gradle-maven-publish-plugin = "0.28.0" @@ -10,16 +10,13 @@ androidx-annotation = "1.9.1" androidx-appcompat = "1.7.0" androidx-browser = "1.8.0" androidx-cardview = "1.0.0" -# Make sure to align with the Kotlin version -# https://developer.android.com/jetpack/androidx/releases/compose-kotlin -androidx-compose-compiler = "1.5.14" -androidx-compose-animation = "1.7.5" -androidx-compose-foundation = "1.7.5" -androidx-compose-material = "1.7.5" -androidx-compose-material3 = "1.3.1" -androidx-compose-runtime = "1.7.5" -androidx-compose-ui = "1.7.5" -androidx-constraintlayout = "2.2.0" +androidx-compose-animation = "1.6.7" +androidx-compose-foundation = "1.6.7" +androidx-compose-material = "1.6.7" +androidx-compose-material3 = "1.2.1" +androidx-compose-runtime = "1.6.7" +androidx-compose-ui = "1.6.7" +androidx-constraintlayout = "2.1.4" androidx-core = "1.15.0" androidx-datastore = "1.1.1" androidx-fragment-ktx = "1.8.5" @@ -49,11 +46,11 @@ junit = "4.13.2" kotlinx-coroutines = "1.9.0" kotlinx-coroutines-test = "1.9.0" kotlinx-datetime = "0.6.1" -kotlinx-serialization-json = "1.6.3" +kotlinx-serialization-json = "1.7.3" # Make sure to align with the Kotlin version. # See https://github.com/google/ksp/releases -ksp = "1.9.24-1.0.20" +ksp = "2.0.21-1.0.25" ktlint = "11.5.1" @@ -150,6 +147,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } [bundles] diff --git a/readium/lcp/build.gradle.kts b/readium/lcp/build.gradle.kts index f7bb85f947..f0dd3a6f49 100644 --- a/readium/lcp/build.gradle.kts +++ b/readium/lcp/build.gradle.kts @@ -11,6 +11,11 @@ plugins { android { namespace = "org.readium.r2.lcp" + + kotlinOptions { + // See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041 + freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility") + } } dependencies { diff --git a/readium/navigator/build.gradle.kts b/readium/navigator/build.gradle.kts index 54310f3481..013535d3d1 100644 --- a/readium/navigator/build.gradle.kts +++ b/readium/navigator/build.gradle.kts @@ -15,6 +15,11 @@ android { buildFeatures { viewBinding = true } + + kotlinOptions { + // See https://github.com/readium/kotlin-toolkit/pull/525#issuecomment-2300084041 + freeCompilerArgs = freeCompilerArgs + ("-Xconsistent-data-class-copy-visibility") + } } dependencies { diff --git a/readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt b/readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt index a6cbda9ad7..baad948843 100644 --- a/readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt +++ b/readium/navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt @@ -481,6 +481,7 @@ internal class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView } } + @Deprecated("Deprecated in Java") override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { val count = childCount val width = r - l diff --git a/readium/shared/src/main/java/org/readium/r2/shared/util/Url.kt b/readium/shared/src/main/java/org/readium/r2/shared/util/Url.kt index b404d6bf05..4cc174133f 100644 --- a/readium/shared/src/main/java/org/readium/r2/shared/util/Url.kt +++ b/readium/shared/src/main/java/org/readium/r2/shared/util/Url.kt @@ -205,7 +205,6 @@ public sealed class Url : Parcelable { * WARNING: Strict URL comparisons can be a source of bug, if the URLs are not normalized. * In most cases, you should compare using [Url.isEquivalent]. */ - @DelicateReadiumApi override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false diff --git a/test-app/build.gradle.kts b/test-app/build.gradle.kts index d8d2f6df30..bff512d1bb 100644 --- a/test-app/build.gradle.kts +++ b/test-app/build.gradle.kts @@ -9,6 +9,7 @@ plugins { kotlin("android") kotlin("plugin.parcelize") alias(libs.plugins.ksp) + alias(libs.plugins.compose.compiler) } android { @@ -37,9 +38,6 @@ android { jvmTarget = JavaVersion.VERSION_1_8.toString() freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn" } - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.androidx.compose.compiler.get() - } buildFeatures { viewBinding = true compose = true diff --git a/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/Flow.kt b/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/Flow.kt index c160eacebd..6c3ccdc435 100644 --- a/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/Flow.kt +++ b/test-app/src/main/java/org/readium/r2/testapp/utils/extensions/Flow.kt @@ -10,12 +10,19 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.remember -import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.lifecycle.flowWithLifecycle import kotlin.time.Duration import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.* +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.conflate +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.stateIn /** * Collects safely the [Flow] as a [State] when the local lifecycle is started.