Fixed
Status Update
Comments
jb...@google.com <jb...@google.com>
te...@gmail.com <te...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
cl...@google.com <cl...@google.com>
cl...@google.com <cl...@google.com> #3
Fixed internally and will be available in fragment 1.6.2
.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-main
commit 6899e1031ecb6d9421c0e986a9290388c84e8a27
Author: Clara Fok <clarafok@google.com>
Date: Mon Oct 23 18:33:17 2023
Fix nested ViewModel not cleared
Ensure that child Fragment's ViewModel is cleared when the Parent ViewModel is destroyed during clearBackStack.
Test: ./gradlew fragment:fragment:cC
Bug: 296173018
Relnote: "Nested Fragment's ViewModel will now be cleared when parent ViewModel is cleared"
Change-Id: I6d83cd93421837b213d25d2fdbe5405348cd2637
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentManagerViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/SaveRestoreBackStackTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManagerViewModel.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
https://android-review.googlesource.com/2796453
Branch: androidx-main
commit 6899e1031ecb6d9421c0e986a9290388c84e8a27
Author: Clara Fok <clarafok@google.com>
Date: Mon Oct 23 18:33:17 2023
Fix nested ViewModel not cleared
Ensure that child Fragment's ViewModel is cleared when the Parent ViewModel is destroyed during clearBackStack.
Test: ./gradlew fragment:fragment:cC
Bug: 296173018
Relnote: "Nested Fragment's ViewModel will now be cleared when parent ViewModel is cleared"
Change-Id: I6d83cd93421837b213d25d2fdbe5405348cd2637
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentManagerViewModelTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/SaveRestoreBackStackTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManagerViewModel.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentStateManager.java
te...@gmail.com <te...@gmail.com> #5
Great!
na...@google.com <na...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.fragment:fragment:1.6.2
pr...@google.com <pr...@google.com> #7
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.fragment:fragment:1.7.0-alpha07
Description
Version used: 2.6.0
Devices/Android versions reproduced on: every device & tested in above SDK 23
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).
Issue:
When using navigation component in fragment, the destination fragment's viewModel (which configured savedState & restoreState) is not cleared even though the destination popped from backstack.
For clearing destination's VM, I should call `navController.clearBackStack(destinationId)`.
I know It is intended feature for preserving VM's state for later restore.
However, the problem happens in the situation that the destination fragment has nested fragment and nested fragment has its VM (call nested VM).
Nested VM never cleared when call `navController.clearBackStack(destinationId)` of parent fragment.
Sadly, VM never cleared even though activity is destroyed. (if application not terminated)
I attached sample project and screen record for reproduce.