Fixed
Status Update
Comments
je...@gmail.com <je...@gmail.com> #2
The only currently supported strategy for adding Fragments to compose is via
ap...@google.com <ap...@google.com> #3
Yes, I am familiar with AndroidViewBinding, however, as far as I know it has some limitations, like, I can't decide at runtime what fragment to commit.
ap...@google.com <ap...@google.com> #4
I also can't give parameters to the fragment being inflated.
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit ffe9335a155bf0dea9c3558e50da01d526579040
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Mar 26 20:24:54 2024
Create AndroidFragment to allow adding fragments in Compose
Adding new AndroidFragment API that creates the given Fragment class and
adds it to the enclosing FragmentManager, within Compose.
It handles setting the ViewCompositionStrategy and saving the state of
the fragment across recompositions.
RelNote: "The new AndroidFragment Composable allows adding fragments
into the Compose hierarchy via the fragment class name."
Test: added AndroidFragmentTest
Bug: 230126482
Bug: 312895363
Change-Id: Icf84199bbe487b2a2b6a95d2b6e09415f810e77a
M docs-tip-of-tree/build.gradle
M fragment/fragment-compose/api/current.txt
M fragment/fragment-compose/api/restricted_current.txt
M fragment/fragment-compose/build.gradle
A fragment/fragment-compose/samples/build.gradle
A fragment/fragment-compose/samples/src/main/java/androidx/fragment/compose/samples/FragmentComposeSamples.kt
M fragment/fragment-compose/src/androidTest/AndroidManifest.xml
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/AndroidFragmentTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentRecreateTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentRemoveTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/SimpleEditTextFragment.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/test/EmptyTestActivity.kt
A fragment/fragment-compose/src/androidTest/res/layout/content.xml
A fragment/fragment-compose/src/androidTest/res/layout/sample_edit_test_layout.xml
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/AndroidFragment.kt
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/FragmentState.kt
M fragment/fragment/api/current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
M settings.gradle
https://android-review.googlesource.com/2989182
Branch: androidx-main
commit ffe9335a155bf0dea9c3558e50da01d526579040
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Mar 26 20:24:54 2024
Create AndroidFragment to allow adding fragments in Compose
Adding new AndroidFragment API that creates the given Fragment class and
adds it to the enclosing FragmentManager, within Compose.
It handles setting the ViewCompositionStrategy and saving the state of
the fragment across recompositions.
RelNote: "The new AndroidFragment Composable allows adding fragments
into the Compose hierarchy via the fragment class name."
Test: added AndroidFragmentTest
Bug: 230126482
Bug: 312895363
Change-Id: Icf84199bbe487b2a2b6a95d2b6e09415f810e77a
M docs-tip-of-tree/build.gradle
M fragment/fragment-compose/api/current.txt
M fragment/fragment-compose/api/restricted_current.txt
M fragment/fragment-compose/build.gradle
A fragment/fragment-compose/samples/build.gradle
A fragment/fragment-compose/samples/src/main/java/androidx/fragment/compose/samples/FragmentComposeSamples.kt
M fragment/fragment-compose/src/androidTest/AndroidManifest.xml
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/AndroidFragmentTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentRecreateTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/FragmentRemoveTest.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/SimpleEditTextFragment.kt
A fragment/fragment-compose/src/androidTest/java/androidx/fragment/compose/test/EmptyTestActivity.kt
A fragment/fragment-compose/src/androidTest/res/layout/content.xml
A fragment/fragment-compose/src/androidTest/res/layout/sample_edit_test_layout.xml
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/AndroidFragment.kt
A fragment/fragment-compose/src/main/java/androidx/fragment/compose/FragmentState.kt
M fragment/fragment/api/current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentTransaction.java
M settings.gradle
jb...@google.com <jb...@google.com> #6
Hey, Thanks to checking this out, I just checked this sample in the the repository, but this does not solve my issue.
I don't have access to the actual fragment class, we use an abstraction that just returns me a instance of Fragment with the arguments set, so this won't solve the issue for me, would it be possible to allow passing the Fragment instance ?
Description
NavType should not require extended classes to override the
name
property. Name is used exclusively internal forNavInflater
for classes that are inflated from XML. All the types that need to implementname
already do, and custom NavTypes should not have this requirement.Instead of being abstract, the
name
property should default to another string (i.e. "nav_type").