Skip to content
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
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ artifactRedirection.version.androidx.compose.material3.common=1.0.0-alpha01
artifactRedirection.version.androidx.collection=1.5.0
artifactRedirection.version.androidx.annotation=1.9.1
artifactRedirection.version.androidx.graphics=1.1.0-alpha01
artifactRedirection.version.androidx.lifecycle=2.10.0-alpha04
artifactRedirection.version.androidx.lifecycle=2.10.0-alpha05
artifactRedirection.version.androidx.navigation=2.9.1
artifactRedirection.version.androidx.navigation3=1.0.0-alpha10
artifactRedirection.version.androidx.navigation3=1.0.0-alpha11
artifactRedirection.version.androidx.navigationevent=1.0.0-beta01
artifactRedirection.version.androidx.performance=1.0.0-alpha01
artifactRedirection.version.androidx.savedstate=1.4.0-beta01
Expand Down
4 changes: 2 additions & 2 deletions libraryversions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ LEANBACK_PREFERENCE = "1.2.0-beta01"
LEANBACK_TAB = "1.1.0-beta01"
LEGACY = "1.1.0-alpha01"
LIBYUV = "0.1.0-dev01"
LIFECYCLE = "2.10.0-alpha04"
LIFECYCLE = "2.10.0-alpha05"
LIFECYCLE_EXTENSIONS = "2.2.0"
LINT = "1.0.0-alpha02"
LOADER = "1.2.0-alpha01"
MEDIA = "1.7.0-rc01"
MEDIAROUTER = "1.8.0-alpha01"
METRICS = "1.0.0-beta02"
NAVIGATION = "2.9.1"
NAVIGATION3 = "1.0.0-alpha10"
NAVIGATION3 = "1.0.0-alpha11"
NAVIGATIONEVENT = "1.0.0-beta01"
PAGING = "3.4.0-alpha01"
PALETTE = "1.1.0-alpha01"
Expand Down
3 changes: 3 additions & 0 deletions lifecycle/lifecycle-reactivestreams/api/current.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Baseline format: 1.0
RemovedFromKotlin: androidx.lifecycle.LiveDataReactiveStreams#fromPublisher(org.reactivestreams.Publisher<T>):
Source breaking change: method androidx.lifecycle.LiveDataReactiveStreams.fromPublisher(org.reactivestreams.Publisher<T>) can no longer be resolved from Kotlin source
3 changes: 2 additions & 1 deletion lifecycle/lifecycle-reactivestreams/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
package androidx.lifecycle {

public final class LiveDataReactiveStreams {
method public static <T> androidx.lifecycle.LiveData<T> fromPublisher(org.reactivestreams.Publisher<T>);
method @InaccessibleFromKotlin public static <T> androidx.lifecycle.LiveData<T> fromPublisher(org.reactivestreams.Publisher<T>);
method @KotlinOnly public static <T> androidx.lifecycle.LiveData<T> toLiveData(org.reactivestreams.Publisher<T>);
method @Deprecated public static <T> org.reactivestreams.Publisher<T> toPublisher(androidx.lifecycle.LifecycleOwner lifecycle, androidx.lifecycle.LiveData<T> liveData);
method public static <T> org.reactivestreams.Publisher<T> toPublisher(androidx.lifecycle.LiveData<T>, androidx.lifecycle.LifecycleOwner lifecycle);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Baseline format: 1.0
RemovedFromKotlin: androidx.lifecycle.LiveDataReactiveStreams#fromPublisher(org.reactivestreams.Publisher<T>):
Source breaking change: method androidx.lifecycle.LiveDataReactiveStreams.fromPublisher(org.reactivestreams.Publisher<T>) can no longer be resolved from Kotlin source
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
package androidx.lifecycle {

public final class LiveDataReactiveStreams {
method public static <T> androidx.lifecycle.LiveData<T> fromPublisher(org.reactivestreams.Publisher<T>);
method @InaccessibleFromKotlin public static <T> androidx.lifecycle.LiveData<T> fromPublisher(org.reactivestreams.Publisher<T>);
method @KotlinOnly public static <T> androidx.lifecycle.LiveData<T> toLiveData(org.reactivestreams.Publisher<T>);
method @Deprecated public static <T> org.reactivestreams.Publisher<T> toPublisher(androidx.lifecycle.LifecycleOwner lifecycle, androidx.lifecycle.LiveData<T> liveData);
method public static <T> org.reactivestreams.Publisher<T> toPublisher(androidx.lifecycle.LiveData<T>, androidx.lifecycle.LifecycleOwner lifecycle);
}
Expand Down
6 changes: 6 additions & 0 deletions lifecycle/lifecycle-runtime-compose/api/current.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ RemovedFromKotlin: androidx.lifecycle.compose.LifecycleStartStopEffectScope#getL
Source breaking change: method androidx.lifecycle.compose.LifecycleStartStopEffectScope.getLifecycle() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.compose.LocalLifecycleOwnerKt#getLocalLifecycleOwner():
Source breaking change: method androidx.lifecycle.compose.LocalLifecycleOwnerKt.getLocalLifecycleOwner() can no longer be resolved from Kotlin source


RemovedMethod: androidx.lifecycle.compose.LifecycleEffectKt#LifecycleResumeEffect(Object[], androidx.lifecycle.LifecycleOwner, kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleResumePauseEffectScope,? extends androidx.lifecycle.compose.LifecyclePauseOrDisposeEffectResult>):
Binary breaking change: Removed method androidx.lifecycle.compose.LifecycleEffectKt.LifecycleResumeEffect(Object[],androidx.lifecycle.LifecycleOwner,kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleResumePauseEffectScope,? extends androidx.lifecycle.compose.LifecyclePauseOrDisposeEffectResult>)
RemovedMethod: androidx.lifecycle.compose.LifecycleEffectKt#LifecycleStartEffect(Object[], androidx.lifecycle.LifecycleOwner, kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleStartStopEffectScope,? extends androidx.lifecycle.compose.LifecycleStopOrDisposeEffectResult>):
Binary breaking change: Removed method androidx.lifecycle.compose.LifecycleEffectKt.LifecycleStartEffect(Object[],androidx.lifecycle.LifecycleOwner,kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleStartStopEffectScope,? extends androidx.lifecycle.compose.LifecycleStopOrDisposeEffectResult>)
10 changes: 5 additions & 5 deletions lifecycle/lifecycle-runtime-compose/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ package androidx.lifecycle.compose {
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.lifecycle.Lifecycle.State!> currentStateAsState(androidx.lifecycle.Lifecycle, androidx.compose.runtime.Composer?, int);
}

public final class LifecycleOwnerKt {
method @KotlinOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(optional androidx.lifecycle.Lifecycle.State maxLifecycle, optional androidx.lifecycle.LifecycleOwner? parent);
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(androidx.lifecycle.Lifecycle.State?, androidx.lifecycle.LifecycleOwner?, androidx.compose.runtime.Composer?, int, int);
}

public interface LifecyclePauseOrDisposeEffectResult {
method public void runPauseOrOnDisposeEffect();
}
Expand Down Expand Up @@ -81,5 +76,10 @@ package androidx.lifecycle.compose {
property public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.lifecycle.LifecycleOwner> LocalLifecycleOwner;
}

public final class RememberLifecycleOwnerKt {
method @KotlinOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(optional androidx.lifecycle.Lifecycle.State maxLifecycle, optional androidx.lifecycle.LifecycleOwner? parent);
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(androidx.lifecycle.Lifecycle.State?, androidx.lifecycle.LifecycleOwner?, androidx.compose.runtime.Composer?, int, int);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ RemovedFromKotlin: androidx.lifecycle.compose.LifecycleStartStopEffectScope#getL
Source breaking change: method androidx.lifecycle.compose.LifecycleStartStopEffectScope.getLifecycle() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.compose.LocalLifecycleOwnerKt#getLocalLifecycleOwner():
Source breaking change: method androidx.lifecycle.compose.LocalLifecycleOwnerKt.getLocalLifecycleOwner() can no longer be resolved from Kotlin source


RemovedMethod: androidx.lifecycle.compose.LifecycleEffectKt#LifecycleResumeEffect(Object[], androidx.lifecycle.LifecycleOwner, kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleResumePauseEffectScope,? extends androidx.lifecycle.compose.LifecyclePauseOrDisposeEffectResult>):
Binary breaking change: Removed method androidx.lifecycle.compose.LifecycleEffectKt.LifecycleResumeEffect(Object[],androidx.lifecycle.LifecycleOwner,kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleResumePauseEffectScope,? extends androidx.lifecycle.compose.LifecyclePauseOrDisposeEffectResult>)
RemovedMethod: androidx.lifecycle.compose.LifecycleEffectKt#LifecycleStartEffect(Object[], androidx.lifecycle.LifecycleOwner, kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleStartStopEffectScope,? extends androidx.lifecycle.compose.LifecycleStopOrDisposeEffectResult>):
Binary breaking change: Removed method androidx.lifecycle.compose.LifecycleEffectKt.LifecycleStartEffect(Object[],androidx.lifecycle.LifecycleOwner,kotlin.jvm.functions.Function1<? super androidx.lifecycle.compose.LifecycleStartStopEffectScope,? extends androidx.lifecycle.compose.LifecycleStopOrDisposeEffectResult>)
10 changes: 5 additions & 5 deletions lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ package androidx.lifecycle.compose {
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.lifecycle.Lifecycle.State!> currentStateAsState(androidx.lifecycle.Lifecycle, androidx.compose.runtime.Composer?, int);
}

public final class LifecycleOwnerKt {
method @KotlinOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(optional androidx.lifecycle.Lifecycle.State maxLifecycle, optional androidx.lifecycle.LifecycleOwner? parent);
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(androidx.lifecycle.Lifecycle.State?, androidx.lifecycle.LifecycleOwner?, androidx.compose.runtime.Composer?, int, int);
}

public interface LifecyclePauseOrDisposeEffectResult {
method public void runPauseOrOnDisposeEffect();
}
Expand Down Expand Up @@ -81,5 +76,10 @@ package androidx.lifecycle.compose {
property public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.lifecycle.LifecycleOwner> LocalLifecycleOwner;
}

public final class RememberLifecycleOwnerKt {
method @KotlinOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(optional androidx.lifecycle.Lifecycle.State maxLifecycle, optional androidx.lifecycle.LifecycleOwner? parent);
method @BytecodeOnly @androidx.compose.runtime.Composable public static androidx.lifecycle.LifecycleOwner rememberLifecycleOwner(androidx.lifecycle.Lifecycle.State?, androidx.lifecycle.LifecycleOwner?, androidx.compose.runtime.Composer?, int, int);
}

}

2 changes: 1 addition & 1 deletion lifecycle/lifecycle-runtime-compose/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
errorLine1=" private fun withLifecycleOwner("
errorLine2=" ~~~~~~~~~~~~~~~~~~">
<location
file="src/androidInstrumentedTest/kotlin/androidx/lifecycle/compose/CollectAsStateWithLifecycleTests.kt"/>
file="src/androidDeviceTest/kotlin/androidx/lifecycle/compose/CollectAsStateWithLifecycleTests.kt"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2025 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.lifecycle.compose.samples

import androidx.annotation.Sampled
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.compose.currentStateAsState
import androidx.lifecycle.compose.rememberLifecycleOwner

/**
* Shows the current Lifecycle state. Used by the samples below to make changes to the Lifecycle
* easy to see.
*/
@Composable
private fun LifecycleAwareText() {
// Recompose when the Lifecycle state changes.
val lifecycleState = LocalLifecycleOwner.current.lifecycle.currentStateAsState()
Text(text = "Current lifecycle state is ${lifecycleState.value}")
}

@Sampled
@Composable
fun ComposableWithMaxLifecycle() {
// Create a LifecycleOwner tied to this composition and cap it at STARTED.
// Use this when a child should never go to RESUMED, even if the parent does.
val cappedLifecycleOwner = rememberLifecycleOwner(maxLifecycle = Lifecycle.State.STARTED)

// Make children see the capped Lifecycle instead of the parent's.
CompositionLocalProvider(LocalLifecycleOwner provides cappedLifecycleOwner) {
// Will only report CREATED or STARTED, never RESUMED.
LifecycleAwareText()
}
}

@Sampled
@Composable
fun ComposableWithParentNull() {
// Create a LifecycleOwner with no parent.
// Use this when a child needs its own independent Lifecycle, managed only
// by whether it is in the composition. Parent state changes do not affect it.
val detachedLifecycleOwner =
rememberLifecycleOwner(parent = null, maxLifecycle = Lifecycle.State.STARTED)

CompositionLocalProvider(LocalLifecycleOwner provides detachedLifecycleOwner) {
// Stays STARTED until this composable leaves the composition,
// even if the parent moves to a lower state.
LifecycleAwareText()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ import androidx.lifecycle.LifecycleRegistry
* This ensures the child is properly cleaned up even if it is referenced outside the composition.
*
* To provide the new [LifecycleOwner] to a sub-composition, use [CompositionLocalProvider]:
*
* @sample androidx.lifecycle.compose.samples.ComposableWithMaxLifecycle
*
* ```
* // Limit a component's lifecycle to STARTED
* val startedLifecycleOwner = rememberLifecycleOwner(maxLifecycle = Lifecycle.State.STARTED)
Expand All @@ -61,6 +64,7 @@ import androidx.lifecycle.LifecycleRegistry
* **Null parent:** If [parent] is **EXPLICITLY** `null`, this creates a root lifecycle that runs
* independently and manages its own state.
*
* @sample androidx.lifecycle.compose.samples.ComposableWithParentNull
* @param maxLifecycle The maximum [Lifecycle.State] this child lifecycle is allowed to enter.
* Defaults to [RESUMED].
* @param parent The [LifecycleOwner] to use as the parent, or null if it is a root. Defaults to the
Expand Down
6 changes: 4 additions & 2 deletions lifecycle/lifecycle-runtime/api/current.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ RemovedFromJava: androidx.lifecycle.ViewKt#findViewTreeLifecycleOwner(android.vi
Source breaking change: method androidx.lifecycle.ViewKt.findViewTreeLifecycleOwner(android.view.View) can no longer be resolved from Java source


RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#getCurrentState():
Source breaking change: method androidx.lifecycle.LifecycleRegistry.getCurrentState() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#getObserverCount():
Source breaking change: method androidx.lifecycle.LifecycleRegistry.getObserverCount() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#setCurrentState(androidx.lifecycle.Lifecycle.State):
Source breaking change: method androidx.lifecycle.LifecycleRegistry.setCurrentState(androidx.lifecycle.Lifecycle.State) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewKt#findViewTreeLifecycleOwner(android.view.View):
Source breaking change: method androidx.lifecycle.ViewKt.findViewTreeLifecycleOwner(android.view.View) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewTreeLifecycleOwner#get(android.view.View):
Source breaking change: method androidx.lifecycle.ViewTreeLifecycleOwner.get(android.view.View) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewTreeLifecycleOwner#set(android.view.View, androidx.lifecycle.LifecycleOwner):
Source breaking change: method androidx.lifecycle.ViewTreeLifecycleOwner.set(android.view.View,androidx.lifecycle.LifecycleOwner) can no longer be resolved from Kotlin source
6 changes: 4 additions & 2 deletions lifecycle/lifecycle-runtime/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ package androidx.lifecycle {
}

public final class ViewTreeLifecycleOwner {
method public static androidx.lifecycle.LifecycleOwner? get(android.view.View);
method public static void set(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
method @KotlinOnly public static androidx.lifecycle.LifecycleOwner? findViewTreeLifecycleOwner(android.view.View);
method @InaccessibleFromKotlin public static androidx.lifecycle.LifecycleOwner? get(android.view.View);
method @InaccessibleFromKotlin public static void set(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
method @KotlinOnly public static void setViewTreeLifecycleOwner(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
}

public final class WithLifecycleStateKt {
Expand Down
6 changes: 4 additions & 2 deletions lifecycle/lifecycle-runtime/api/restricted_current.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ RemovedFromJava: androidx.lifecycle.ViewKt#findViewTreeLifecycleOwner(android.vi
Source breaking change: method androidx.lifecycle.ViewKt.findViewTreeLifecycleOwner(android.view.View) can no longer be resolved from Java source


RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#getCurrentState():
Source breaking change: method androidx.lifecycle.LifecycleRegistry.getCurrentState() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#getObserverCount():
Source breaking change: method androidx.lifecycle.LifecycleRegistry.getObserverCount() can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.LifecycleRegistry#setCurrentState(androidx.lifecycle.Lifecycle.State):
Expand All @@ -15,3 +13,7 @@ RemovedFromKotlin: androidx.lifecycle.ReportFragment.Companion#get(android.app.A
Source breaking change: method androidx.lifecycle.ReportFragment.Companion.get(android.app.Activity) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewKt#findViewTreeLifecycleOwner(android.view.View):
Source breaking change: method androidx.lifecycle.ViewKt.findViewTreeLifecycleOwner(android.view.View) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewTreeLifecycleOwner#get(android.view.View):
Source breaking change: method androidx.lifecycle.ViewTreeLifecycleOwner.get(android.view.View) can no longer be resolved from Kotlin source
RemovedFromKotlin: androidx.lifecycle.ViewTreeLifecycleOwner#set(android.view.View, androidx.lifecycle.LifecycleOwner):
Source breaking change: method androidx.lifecycle.ViewTreeLifecycleOwner.set(android.view.View,androidx.lifecycle.LifecycleOwner) can no longer be resolved from Kotlin source
6 changes: 4 additions & 2 deletions lifecycle/lifecycle-runtime/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ package androidx.lifecycle {
}

public final class ViewTreeLifecycleOwner {
method public static androidx.lifecycle.LifecycleOwner? get(android.view.View);
method public static void set(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
method @KotlinOnly public static androidx.lifecycle.LifecycleOwner? findViewTreeLifecycleOwner(android.view.View);
method @InaccessibleFromKotlin public static androidx.lifecycle.LifecycleOwner? get(android.view.View);
method @InaccessibleFromKotlin public static void set(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
method @KotlinOnly public static void setViewTreeLifecycleOwner(android.view.View, androidx.lifecycle.LifecycleOwner? lifecycleOwner);
}

public final class WithLifecycleStateKt {
Expand Down
Loading