Status Update
Comments
il...@google.com <il...@google.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
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit d938453e52702fb48836cbf08b751c6354a734dc
Author: Ian Lake <ilake@google.com>
Date: Tue Mar 02 10:57:20 2021
Let FragmentViewLifecycleOwner implement ViewModelStoreOwner
SavedStateViewModelFactory makes some assumptions that
the SavedStateRegistryOwner is also a ViewModelStoreOwner.
This is almost always the case, except when using the
ViewTree APIs in Fragments. This change makes it so
that the internal FragmentViewLifecycleOwner that is
tied to the Fragment's View Lifecycle implements
ViewModelStoreOwner as well (delegating to the Fragment's
ViewModelStore).
Relnote: "Using `SavedStateViewModelFactory` now works
when used with the `SavedStateRegistryOwner` returned by
using `findViewTreeSavedStateRegistryOwner()` from a
Fragment's View."
Test: updated tests pass
BUG: 181577191
Change-Id: I21acf18f70ab6dcc60f5946d5b0d878e12bc76df
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentViewLifecycleTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentViewLifecycleOwner.java
il...@google.com <il...@google.com> #4
This has been fixed internally and we're looking to include it in the Fragment 1.3.1 release.
tf...@gmail.com <tf...@gmail.com> #5
Are there any plans to include this in any of the next releases? I just checked 1.3.2 and it doesn't seem to be there.
il...@google.com <il...@google.com> #6
Sorry, looks like this slipped through the cracks. I'll actually add this to the next release's hotlist.
b9...@gmail.com <b9...@gmail.com> #7
I upgrade 1.3.3 from 1.3.2 and can't create ViewModel in compose via androidx.lifecycle.viewmodel.compose.viewModel<T>()
anymore.
il...@google.com <il...@google.com> #8
Re #7 - please file a new bug with a sample project that reproduces your issue.
b9...@gmail.com <b9...@gmail.com> #9
Re #8 I could point out the code directly. I don't know how to describe the issue.
public ViewModelProvider(@NonNull ViewModelStoreOwner owner) {
this(owner.getViewModelStore(), owner instanceof HasDefaultViewModelProviderFactory
? ((HasDefaultViewModelProviderFactory) owner).getDefaultViewModelProviderFactory()
: NewInstanceFactory.getInstance());
}
FragmentViewLifecycleOwner
didn't implement HasDefaultViewModelProviderFactory
, so that NewInstanceFactory
will be used to create ViewModel. Which means DI framework like Hilt will failed.
il...@google.com <il...@google.com> #10
Re #9 - please file a new bug so we can track that work.
b9...@gmail.com <b9...@gmail.com> #11
Re #10,
Description
Component used:
lifecycle-viewmodel-ktx
Version used: 2.3.0
Devices/Android versions reproduced on: Pixel 4 running Android 10
Sample project to trigger the issue:https://github.com/tfcporciuncula/view-tree-owner-bug
You can repro the issue by cloning that repo, running it, and then rotating the screen causing a config change.
This is the code I'm using to create a here ):
ViewModel
in aView
(as you can seeEverything works fine, but the app crashes on orientation change with the following stacktrace:
The crash has a pretty clear cause which is this :
So it seems there's this implicit requirement of having the , which is only a
SavedStateRegistryOwner
also be aViewModelStoreOwner
, and that's not the case for the view when it's in a fragment: itsSavedStateRegistryOwner
is aFragmentViewLifecycleOwner
SavedStateRegistryOwner
and not aViewModelStoreOwner
.It feels like
findViewTreeSavedStateRegistryOwner()
should return the fragment itself (likefindViewTreeSavedStateRegistryOwner()
) instead of theFragmentViewLifecycleOwner
, so this would work. Or am I doing something wrong here?If the view is in an activity everything works fine --
findViewTreeSavedStateRegistryOwner()
returns the activity in this case, which is also aViewModelStoreOwner
so everything is good.