Status Update
Comments
il...@google.com <il...@google.com>
tr...@gmail.com <tr...@gmail.com> #2
Branch: androidx-master-dev
commit c60f33e229e31ab328ef6b59dab63b264954831c
Author: Alexandre Elias <aelias@google.com>
Date: Fri Jul 10 16:23:09 2020
Semantics no-op cleanups
Partly in response to lmr's broad code review, I did a pass of
superficial API/implementation cleanup. The main changes are:
- I changed each Boolean SemanticsProperty where false is equivalent to
not being present to take "Unit" instead. This is conceptually
clearer: it avoids questions like "can I cancel out a semantics from a
merged child by setting it to false?" Because "property = Unit" looks
weird, I also changed the style of these to "property()".
- I moved the Semantics id generator closer to where it's used, in
SemanticsModifierCore. I made it internal and an AtomicInt.
(Note that integer ids are heavily used in the Android
AccessibilityNodeInfo APIs so I can't simply remove them entirely.)
- I deleted dead code. Some examples include SemanticsHintOverrides,
a public API not connected to anything, and SemanticsPropertyKey
merge() open method which is never called. (In both cases I have
a different plan in mind for accessibility.)
Fixes: 145951226
Fixes: 145955412
Test: existing tests
Relnote: "Single-value semantics properties now use a calling style.
For example, 'semantics { hidden = true }' is now written as:
'semantics { hidden() }'."
Change-Id: Ic1afd12ea22c926babc9662f1804d80b33aa0cfc
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
M ui/ui-core/api/0.1.0-dev15.txt
M ui/ui-core/api/current.txt
M ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-core/api/public_plus_experimental_current.txt
M ui/ui-core/api/restricted_0.1.0-dev15.txt
M ui/ui-core/api/restricted_current.txt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
D ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
M ui/ui-foundation/api/0.1.0-dev15.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev15.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
M ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
M ui/ui-text/api/0.1.0-dev15.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev15.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
a....@gmail.com <a....@gmail.com> #3
sj...@gmail.com <sj...@gmail.com> #4
This would be really appreciated. Especially when dealing with legacy Android views wrapped in an AndroidView
that require specific methods to be called on certain lifecycle states, like a camera/scanner view for example.
sj...@gmail.com <sj...@gmail.com> #5
As a workaround I created this function utilizing produceState()
:
@Composable
fun currentLifecycleState(): State<Lifecycle.State> {
val lifecycleOwner = LocalLifecycleOwner.current
return produceState(
initialValue = Lifecycle.State.INITIALIZED,
) {
val observer = object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onStart(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onResume(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onPause(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onStop(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onDestroy(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
}
lifecycleOwner.lifecycle.addObserver(observer)
awaitDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
}
sa...@google.com <sa...@google.com>
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit c1f4d85af7a690c310fc9dd60e27654ba2f4896e
Author: sanura <sanura@google.com>
Date: Tue Mar 07 01:16:59 2023
Add Lifecycle extension for composable collectAsState()
Adding a Lifecycle composable extension for developers
wanting to directly expose Lifecycle.State as a Compose State.
RelNote: "`Lifecycle.collectAsState()` extension added to
directly expose `Lifecycle.State` as Compose `State`. This
is equivalent (and a shorter alternative) to
`lifecycle.currentStateFlow.collectAsState()`."
Bug: 235529345
Test: lifecycleCollectAsState()
Change-Id: I1101507a270980554046f7505b356c9c923ad48e
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
A lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleExtTest.kt
A lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleExt.kt
lm...@gmail.com <lm...@gmail.com> #7
lm...@gmail.com <lm...@gmail.com> #8
lm...@gmail.com <lm...@gmail.com> #9
ap...@google.com <ap...@google.com> #10
Branch: androidx-main
commit e9afa3a28b32897fef6717fea079c6296f3a2e5a
Author: sanura <sanura@google.com>
Date: Tue Apr 25 01:07:17 2023
Create LifecycleEventEffect composable
Adding LifecycleEventEffect composable API to
be used when running SideEffects based on a
particular Lifecycle.Event.
RelNote: "`LifecycleEventEffect` API has been
added to run side effects based on `Lifecycle.Event`."
Test: LifecycleEventEffectTest
Bug: 235529345
Change-Id: Ic9794d7e59b1a66cc7f31cbaebed9b3d3dee5dd3
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/CollectAsStateWithLifecycleTests.kt
A lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleExtTest.kt
A lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 25a2002ab933ea551295483aa3f7e278d60dbe75
Author: sanura <sanura@google.com>
Date: Wed May 03 20:20:56 2023
Create LifecycleResumeEffect composable
Adding LifecycleResumeEffect composable API to be used when
running SideEffects based on ON_RESUME/ON_PAUSE event callbacks.
RelNote: "`LifecycleResumeEffect` API has been added to run side
effects based on both `Lifecycle.Event.ON_RESUME` and
`Lifecycle.Event.ON_PAUSE` event callbacks."
Test: lifecycleResumeEffectTest
Bug: 235529345
Change-Id: I603860f21eb6a433c909d7ae6f8120f6d23179aa
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 2b090a54b8182927eb0e96062e0a14d065a8561a
Author: sanura <sanura@google.com>
Date: Tue May 02 19:53:55 2023
Create LifecycleStartEffect composable
Adding LifecycleStartEffect composable API to be used when
running SideEffects based on ON_START/ON_STOP event callbacks.
RelNote: "`LifecycleStartEffect` API has been added to run side
effects based on `Lifecycle.Event.ON_START` and
`Lifecycle.Event.ON_STOP` event callbacks."
Test: lifecycleStartEffectTest
Bug: 235529345
Change-Id: I5a8d1e6f152b7083e086146ba97044c4b454db84
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
st...@gmail.com <st...@gmail.com> #13
Is there a target API version where this may be released?
il...@google.com <il...@google.com> #14
This is still in progress for inclusion in Lifecycle 2.7.0-alpha01.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit ad273fa4882a38a5a2f72004044ce3173b2c06a9
Author: sanura <sanura@google.com>
Date: Fri May 05 02:02:59 2023
Add samples for LifecycleEffects
Adding samples for LifecycleEventEffect,
LifecycleStartEffect, and LifecycleResumeEffect.
RelNote: "All composables in `LifecycleEffect` now
link sample usages."
Test: ./gradlew bOS
Bug: 235529345
Change-Id: Ib4786f4b586cf9390f3dbe6f3b0fc86c60267a86
M lifecycle/lifecycle-runtime-compose/samples/src/main/java/androidx/lifecycle/compose/samples/LifecycleComposeSamples.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
sa...@google.com <sa...@google.com>
lm...@gmail.com <lm...@gmail.com> #16
ka...@gmail.com <ka...@gmail.com> #17
When will this be released?
na...@google.com <na...@google.com> #18
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-runtime-compose:2.7.0-alpha01
sj...@gmail.com <sj...@gmail.com> #19
Just want to say that Lifecycle 2.7.0
stable has been finally released. Thank you very much 🙏🏼
ey...@gmail.com <ey...@gmail.com> #20
jb...@google.com <jb...@google.com> #21
Yes, those are the Lifecycle.State
s that reflect those particular Lifecycle.Event
s. Please take a look at the
ey...@gmail.com <ey...@gmail.com> #22
jb...@google.com <jb...@google.com> #23
Receiving a state from the flow would be the signal that a change has occurred and the new state is that particular change. There are cases where you don't care how you get to a state, just that you are there. We also offer Lifecycle.Event
s.
il...@google.com <il...@google.com> #24
If you look at the Lifecycle.asFlow()
to get a Flow of Lifecycle.Event
) and one for Lifecycle State (where you can use Lifecycle.currentStateFlow
to get the current Lifecycle.State
).
Make sure you are using the right API.
ey...@gmail.com <ey...@gmail.com> #25
il...@google.com <il...@google.com> #26
Lifecycle.asFlow()
works outside of Compose too and gives you Lifecycle.Event
instances as they occur. That's why that API exists separately from currentStateFlow
.
Description
Component used: Lifecycle
Version used: 2.5.0-rc01
Reacting to a Lifecycle.State changes is currently fairly complicated in a Jetpack Compose based app, requiring a with registering a
DisposableEffect
based approachLifecycleObserver
with theLocalLifecycleOwner
.Ideally, this would come in two forms:
Lifecycle.State
asState
, perhaps something likeLocalLifecycleOwner.current.lifecycle.currentStateFlow.collectAsState()
LifecycleEventEffect
that would only run the effect when theLifecycle.State
changes.