Move androidx.compose.ui.platform.LocalLifecycleOwner to common
Sync the state with JetBrains fork. Previously it was reverted due to infrastructure issues. See aosp/2950349
Test: N/A
Change-Id: I3521e95a5e938a47af29598eac05bce7251bf1df
diff --git a/camera/integration-tests/avsynctestapp/build.gradle b/camera/integration-tests/avsynctestapp/build.gradle
index ebd2c4e..5f9a182 100644
--- a/camera/integration-tests/avsynctestapp/build.gradle
+++ b/camera/integration-tests/avsynctestapp/build.gradle
@@ -66,7 +66,7 @@
// Align dependencies in debugRuntimeClasspath and debugAndroidTestRuntimeClasspath.
androidTestImplementation("androidx.annotation:annotation-experimental:1.4.1")
androidTestImplementation(project(":annotation:annotation"))
- androidTestImplementation("androidx.lifecycle:lifecycle-common:2.8.3")
+ androidTestImplementation(project(":lifecycle:lifecycle-common"))
// Testing framework
testImplementation(libs.kotlinCoroutinesTest)
diff --git a/compose/ui/ui/build.gradle b/compose/ui/ui/build.gradle
index 8905d36..134d810 100644
--- a/compose/ui/ui/build.gradle
+++ b/compose/ui/ui/build.gradle
@@ -56,6 +56,8 @@
api(project(":compose:ui:ui-text"))
api(project(":compose:ui:ui-unit"))
api(project(":compose:ui:ui-util"))
+
+ api(project(":lifecycle:lifecycle-runtime-compose"))
}
}
@@ -87,8 +89,8 @@
implementation("androidx.collection:collection:1.4.2")
implementation("androidx.customview:customview-poolingcontainer:1.0.0")
implementation("androidx.savedstate:savedstate-ktx:1.2.1")
- api("androidx.lifecycle:lifecycle-runtime-compose:2.8.3")
- implementation("androidx.lifecycle:lifecycle-viewmodel:2.6.1")
+ implementation("androidx.lifecycle:lifecycle-viewmodel:2.8.3")
+ implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.3")
implementation("androidx.emoji2:emoji2:1.2.0")
implementation("androidx.profileinstaller:profileinstaller:1.3.1")
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidCompositionLocals.android.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidCompositionLocals.android.kt
index fd0963c..16452b7 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidCompositionLocals.android.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidCompositionLocals.android.kt
@@ -34,7 +34,6 @@
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.res.ImageVectorCache
import androidx.compose.ui.res.ResourceIdCache
-import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.savedstate.SavedStateRegistryOwner
@@ -54,12 +53,11 @@
internal val LocalResourceIdCache =
staticCompositionLocalOf { noLocalProvidedFor("LocalResourceIdCache") }
-/** The CompositionLocal containing the current [LifecycleOwner]. */
@Deprecated(
"Moved to lifecycle-runtime-compose library in androidx.lifecycle.compose package.",
ReplaceWith("androidx.lifecycle.compose.LocalLifecycleOwner"),
)
-val LocalLifecycleOwner
+actual val LocalLifecycleOwner
get() = LocalLifecycleOwner
/** The CompositionLocal containing the current [SavedStateRegistryOwner]. */
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/CompositionLocals.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/CompositionLocals.kt
index 41037c6..d8f78e6 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/CompositionLocals.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/CompositionLocals.kt
@@ -42,6 +42,7 @@
import androidx.compose.ui.text.input.TextInputService
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
+import androidx.lifecycle.LifecycleOwner
/** The CompositionLocal to provide communication with platform accessibility service. */
val LocalAccessibilityManager = staticCompositionLocalOf { null }
@@ -151,6 +152,13 @@
*/
val LocalWindowInfo = staticCompositionLocalOf { noLocalProvidedFor("LocalWindowInfo") }
+/** The CompositionLocal containing the current [LifecycleOwner]. */
+@Deprecated(
+ "Moved to lifecycle-runtime-compose library in androidx.lifecycle.compose package.",
+ ReplaceWith("androidx.lifecycle.compose.LocalLifecycleOwner"),
+)
+expect val LocalLifecycleOwner: ProvidableCompositionLocal
+
internal val LocalPointerIconService = staticCompositionLocalOf { null }
/** @see LocalScrollCaptureInProgress */
diff --git a/lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt b/compose/ui/ui/src/commonStubsMain/kotlin/androidx/compose/ui/platform/CompositionLocals.commonStubs.kt
similarity index 65%
copy from lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt
copy to compose/ui/ui/src/commonStubsMain/kotlin/androidx/compose/ui/platform/CompositionLocals.commonStubs.kt
index 1a1c7e5..3147a63 100644
--- a/lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt
+++ b/compose/ui/ui/src/commonStubsMain/kotlin/androidx/compose/ui/platform/CompositionLocals.commonStubs.kt
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-@file:JvmName("LocalLifecycleOwnerKt")
-
-package androidx.lifecycle.compose
+package androidx.compose.ui.platform
import androidx.compose.runtime.ProvidableCompositionLocal
-import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.implementedInJetBrainsFork
import androidx.lifecycle.LifecycleOwner
-public actual val LocalLifecycleOwner: ProvidableCompositionLocal =
- staticCompositionLocalOf {
- error("CompositionLocal LocalLifecycleOwner not present")
- }
+@Deprecated(
+ "Moved to lifecycle-runtime-compose library in androidx.lifecycle.compose package.",
+ ReplaceWith("androidx.lifecycle.compose.LocalLifecycleOwner"),
+)
+actual val LocalLifecycleOwner: ProvidableCompositionLocal
+ get() = implementedInJetBrainsFork()
diff --git a/lifecycle/lifecycle-runtime-compose/build.gradle b/lifecycle/lifecycle-runtime-compose/build.gradle
index be2d776..0ffdf85 100644
--- a/lifecycle/lifecycle-runtime-compose/build.gradle
+++ b/lifecycle/lifecycle-runtime-compose/build.gradle
@@ -23,6 +23,7 @@
*/
import androidx.build.LibraryType
import androidx.build.PlatformIdentifier
+import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
plugins {
id("AndroidXPlugin")
@@ -32,7 +33,8 @@
androidXMultiplatform {
android()
- desktop()
+ jvmStubs()
+ linuxX64Stubs()
defaultPlatform(PlatformIdentifier.ANDROID)
@@ -41,7 +43,7 @@
dependencies {
api(projectOrArtifact(":lifecycle:lifecycle-runtime"))
api("androidx.annotation:annotation:1.8.1")
- api("androidx.compose.runtime:runtime:1.6.5")
+ api(project(":compose:runtime:runtime"))
}
}
@@ -67,6 +69,18 @@
implementation(project(":kruth:kruth"))
}
}
+
+ nonAndroidMain {
+ dependsOn(commonMain)
+ }
+
+ jvmStubsMain {
+ dependsOn(nonAndroidMain)
+ }
+
+ linuxx64StubsMain {
+ dependsOn(nonAndroidMain)
+ }
}
}
diff --git a/lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt b/lifecycle/lifecycle-runtime-compose/src/nonAndroidMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.nonAndroid.kt
similarity index 96%
rename from lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt
rename to lifecycle/lifecycle-runtime-compose/src/nonAndroidMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.nonAndroid.kt
index 1a1c7e5..07eda1d 100644
--- a/lifecycle/lifecycle-runtime-compose/src/desktopMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.desktop.kt
+++ b/lifecycle/lifecycle-runtime-compose/src/nonAndroidMain/kotlin/androidx/lifecycle/compose/LocalLifecycleOwner.nonAndroid.kt
@@ -21,6 +21,7 @@
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.lifecycle.LifecycleOwner
+import kotlin.jvm.JvmName
public actual val LocalLifecycleOwner: ProvidableCompositionLocal =
staticCompositionLocalOf {
diff --git a/test/uiautomator/integration-tests/testapp/build.gradle b/test/uiautomator/integration-tests/testapp/build.gradle
index 80f7aa2..3d68617 100644
--- a/test/uiautomator/integration-tests/testapp/build.gradle
+++ b/test/uiautomator/integration-tests/testapp/build.gradle
@@ -43,7 +43,7 @@
androidTestImplementation(libs.testRunner)
// Align dependencies in debugRuntimeClasspath and debugAndroidTestRuntimeClasspath.
- androidTestImplementation("androidx.lifecycle:lifecycle-common:2.8.3")
+ androidTestImplementation(project(":lifecycle:lifecycle-common"))
androidTestImplementation(project(":annotation:annotation"))
androidTestImplementation(libs.junit)
androidTestImplementation(libs.testMonitor)
diff --git a/wear/compose/integration-tests/navigation/build.gradle b/wear/compose/integration-tests/navigation/build.gradle
index b29b94ada..9f6379f 100644
--- a/wear/compose/integration-tests/navigation/build.gradle
+++ b/wear/compose/integration-tests/navigation/build.gradle
@@ -55,6 +55,6 @@
implementation(project(':wear:compose:compose-navigation'))
// Align dependencies in debugRuntimeClasspath and debugAndroidTestRuntimeClasspath.
- androidTestImplementation("androidx.lifecycle:lifecycle-common:2.8.3")
+ androidTestImplementation(project(":lifecycle:lifecycle-common"))
androidTestImplementation(project(":annotation:annotation"))
}