Convert compose animation-core project to add linuxX64Stubs target
- Add all needed stub actuals
Bug: 349894318
Test: ./gradlew -p compose/animation build
Change-Id: I872bcb0e1d1b5b9be13f35a7645a9704a2411e14
diff --git a/compose/animation/animation-core/build.gradle b/compose/animation/animation-core/build.gradle
index 4faa027..55f2e64e0 100644
--- a/compose/animation/animation-core/build.gradle
+++ b/compose/animation/animation-core/build.gradle
@@ -34,6 +34,7 @@
androidXMultiplatform {
android()
jvmStubs()
+ linuxX64Stubs()
defaultPlatform(PlatformIdentifier.ANDROID)
@@ -41,11 +42,11 @@
commonMain {
dependencies {
implementation(project(":compose:runtime:runtime"))
- implementation("androidx.compose.ui:ui:1.6.0")
- implementation("androidx.compose.ui:ui-unit:1.6.0")
+ implementation(project(":compose:ui:ui"))
+ implementation(project(":compose:ui:ui-unit"))
implementation(project(":compose:ui:ui-graphics"))
implementation(project(":compose:ui:ui-util"))
- implementation("androidx.collection:collection:1.4.0")
+ implementation(project(":collection:collection"))
implementation(libs.kotlinStdlib)
api(libs.kotlinCoroutinesCore)
}
@@ -69,10 +70,16 @@
}
}
+ commonStubsMain {
+ dependsOn(commonMain)
+ }
+
jvmStubsMain {
- dependsOn(jvmMain)
- dependencies {
- }
+ dependsOn(commonStubsMain)
+ }
+
+ linuxx64StubsMain {
+ dependsOn(commonStubsMain)
}
androidInstrumentedTest {
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Animation.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Animation.kt
index c2d4513..aca534e 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Animation.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Animation.kt
@@ -17,6 +17,7 @@
package androidx.compose.animation.core
import androidx.annotation.RestrictTo
+import androidx.compose.animation.core.internal.JvmDefaultWithCompatibility
/**
* This interface provides a convenient way to query from an [VectorizedAnimationSpec] or
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ArcSpline.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ArcSpline.kt
index a816ef1..740faa1 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ArcSpline.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ArcSpline.kt
@@ -16,6 +16,7 @@
package androidx.compose.animation.core
+import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.hypot
@@ -241,7 +242,7 @@
fun setPoint(time: Float) {
val percent = (if (isVertical) time2 - time else time - time1) * oneOverDeltaTime
- val angle = Math.PI.toFloat() * 0.5f * lookup(percent)
+ val angle = PI.toFloat() * 0.5f * lookup(percent)
tmpSinAngle = sin(angle)
tmpCosAngle = cos(angle)
}
@@ -308,7 +309,7 @@
var ly = 0f
var dist = 0f
for (i in ourPercent.indices) {
- val angle = Math.toRadians(90.0 * i / (ourPercent.size - 1)).toFloat()
+ val angle = toRadians(90.0 * i / (ourPercent.size - 1)).toFloat()
val s = sin(angle)
val c = cos(angle)
val px = a * s
@@ -326,7 +327,7 @@
}
for (i in lut.indices) {
val pos = i / (lut.size - 1).toFloat()
- val index = ourPercent.binarySearch(pos)
+ val index = binarySearch(ourPercent, pos)
if (index >= 0) {
lut[i] = index / (ourPercent.size - 1).toFloat()
} else if (index == -1) {
@@ -371,3 +372,7 @@
private const val UpArc = 5
}
}
+
+internal expect inline fun toRadians(value: Double): Double
+
+internal expect inline fun binarySearch(array: FloatArray, position: Float): Int
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/IntListExtension.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/IntListExtension.kt
index 95e59a1..5544fcb 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/IntListExtension.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/IntListExtension.kt
@@ -17,6 +17,7 @@
package androidx.compose.animation.core
import androidx.collection.IntList
+import kotlin.jvm.JvmOverloads
// TODO(b/311454748): Move to :collection as public API once it's back on alpha. Also, add versions
// for LongList and FloatList.
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.kt
index 3d93081..533f06e 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.kt
@@ -58,13 +58,7 @@
* lookups to build the exception message and stack trace collection. Remove if these are changed in
* kotlinx.coroutines.
*/
-private class MutationInterruptedException : CancellationException("Mutation interrupted") {
- override fun fillInStackTrace(): Throwable {
- // Avoid null.clone() on Android <= 6.0 when accessing stackTrace
- stackTrace = emptyArray()
- return this
- }
-}
+internal expect class MutationInterruptedException() : CancellationException
/**
* Mutual exclusion for UI state mutation over time.
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
index 592ef33..eb73d60 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
@@ -21,6 +21,7 @@
import androidx.annotation.FloatRange
import androidx.annotation.RestrictTo
import androidx.collection.MutableObjectList
+import androidx.compose.animation.core.internal.JvmDefaultWithCompatibility
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
@@ -49,6 +50,7 @@
import androidx.compose.ui.util.fastForEach
import kotlin.coroutines.coroutineContext
import kotlin.coroutines.resume
+import kotlin.jvm.JvmName
import kotlin.math.max
import kotlin.math.roundToLong
import kotlinx.coroutines.CancellableContinuation
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec.kt
index 266e8dd..da2f064 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorizedAnimationSpec.kt
@@ -21,6 +21,8 @@
import androidx.collection.MutableIntList
import androidx.collection.MutableIntObjectMap
import androidx.compose.animation.core.AnimationConstants.DefaultDurationMillis
+import androidx.compose.animation.core.internal.JvmDefaultWithCompatibility
+import kotlin.jvm.JvmInline
import kotlin.math.min
/**
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.kt
new file mode 100644
index 0000000..0aebdc3
--- /dev/null
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core.internal
+
+internal expect annotation class JvmDefaultWithCompatibility()
diff --git a/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/ArcSpline.commonStubs.kt b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/ArcSpline.commonStubs.kt
new file mode 100644
index 0000000..d8d41dd
--- /dev/null
+++ b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/ArcSpline.commonStubs.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+@Suppress("NOTHING_TO_INLINE")
+internal actual inline fun toRadians(value: Double): Double = implementedInJetBrainsFork()
+
+@Suppress("NOTHING_TO_INLINE")
+internal actual inline fun binarySearch(array: FloatArray, position: Float): Int =
+ implementedInJetBrainsFork()
diff --git a/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/Expect.commonStubs.kt b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/Expect.commonStubs.kt
new file mode 100644
index 0000000..6a96f9c
--- /dev/null
+++ b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/Expect.commonStubs.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+internal actual class AtomicReference<V> actual constructor(value: V) {
+ actual fun get(): V = implementedInJetBrainsFork()
+
+ actual fun set(value: V) {
+ implementedInJetBrainsFork()
+ }
+
+ actual fun getAndSet(value: V): V = implementedInJetBrainsFork()
+
+ actual fun compareAndSet(expect: V, newValue: V): Boolean = implementedInJetBrainsFork()
+}
diff --git a/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.commonStubs.kt b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.commonStubs.kt
new file mode 100644
index 0000000..ab8b58f
--- /dev/null
+++ b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/InternalMutatorMutex.commonStubs.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+import kotlinx.coroutines.CancellationException
+
+internal actual class MutationInterruptedException : CancellationException("") {
+ init {
+ implementedInJetBrainsFork()
+ }
+}
diff --git a/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/NotImplemented.commonStubs.kt b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/NotImplemented.commonStubs.kt
new file mode 100644
index 0000000..30b49a5
--- /dev/null
+++ b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/NotImplemented.commonStubs.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+@Suppress("NOTHING_TO_INLINE")
+internal inline fun implementedInJetBrainsFork(): Nothing =
+ throw NotImplementedError(
+ """
+ Implemented only in JetBrains fork.
+ Please use `org.jetbrains.compose.animation:animation-core` package instead.
+ """
+ .trimIndent()
+ )
diff --git a/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.commonStubs.kt b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.commonStubs.kt
new file mode 100644
index 0000000..423a8a9
--- /dev/null
+++ b/compose/animation/animation-core/src/commonStubsMain/kotlin/androidx/compose/animation/core/internal/JvmDefaultWithCompatibility.commonStubs.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core.internal
+
+internal actual annotation class JvmDefaultWithCompatibility()
diff --git a/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/ArcSpline.jvm.kt b/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/ArcSpline.jvm.kt
new file mode 100644
index 0000000..5ade8f9
--- /dev/null
+++ b/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/ArcSpline.jvm.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+@Suppress("NOTHING_TO_INLINE")
+internal actual inline fun toRadians(value: Double): Double {
+ return Math.toRadians(value)
+}
+
+@Suppress("NOTHING_TO_INLINE")
+internal actual inline fun binarySearch(array: FloatArray, position: Float): Int {
+ return array.binarySearch(position)
+}
diff --git a/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/InternalMotatorMutex.jvm.kt b/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/InternalMotatorMutex.jvm.kt
new file mode 100644
index 0000000..5e2d56c
--- /dev/null
+++ b/compose/animation/animation-core/src/jvmMain/kotlin/androidx/compose/animation/core/InternalMotatorMutex.jvm.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+import kotlinx.coroutines.CancellationException
+
+internal actual class MutationInterruptedException : CancellationException("Mutation interrupted") {
+ override fun fillInStackTrace(): Throwable {
+ // Avoid null.clone() on Android <= 6.0 when accessing stackTrace
+ stackTrace = emptyArray()
+ return this
+ }
+}