Fixed
Status Update
Comments
ap...@google.com <ap...@google.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
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 9821a81abedf7464527fc0ff87d5fa3832bb6209
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 18 16:03:29 2021
Ensure inflated fragments that are recreated are shown
When using the new fragment state manager, if a fragment is inflated
after the host activity is RESUMED using a FragmentContainerView, the
fragment is added and correctly moves to RESUMED the first time, but
upon config change, the fragment's view is never readded to the
container. This results in the fragment moving to RESUMED but never
being reattached to the view hierarchy.
This change finds the restored fragment and indicates to the
FragmentManager that the FragmentContainerView is ready for the fragment
to be attached.
RelNote: "Fragments inflated into an already RESUMED activity using
FragmentContainerView are now properly shown after a configuration
change."
Test: DialogFragmentTest and FragmentLifecycleTest
Bug: 180538371
Change-Id: Ie14c80467b66186862319469f51bbd4d7ebcbbb9
M fragment/fragment/src/androidTest/java/androidx/fragment/app/DialogFragmentTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/StrictViewFragment.kt
A fragment/fragment/src/androidTest/res/layout/inflated_fragment_container_view_no_parent.xml
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/1595200
Branch: androidx-main
commit 9821a81abedf7464527fc0ff87d5fa3832bb6209
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 18 16:03:29 2021
Ensure inflated fragments that are recreated are shown
When using the new fragment state manager, if a fragment is inflated
after the host activity is RESUMED using a FragmentContainerView, the
fragment is added and correctly moves to RESUMED the first time, but
upon config change, the fragment's view is never readded to the
container. This results in the fragment moving to RESUMED but never
being reattached to the view hierarchy.
This change finds the restored fragment and indicates to the
FragmentManager that the FragmentContainerView is ready for the fragment
to be attached.
RelNote: "Fragments inflated into an already RESUMED activity using
FragmentContainerView are now properly shown after a configuration
change."
Test: DialogFragmentTest and FragmentLifecycleTest
Bug: 180538371
Change-Id: Ie14c80467b66186862319469f51bbd4d7ebcbbb9
M fragment/fragment/src/androidTest/java/androidx/fragment/app/DialogFragmentTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentLifecycleTest.kt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/StrictViewFragment.kt
A fragment/fragment/src/androidTest/res/layout/inflated_fragment_container_view_no_parent.xml
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.java
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment version 1.3.1
release.
ad...@gmail.com <ad...@gmail.com> #5
I am still experiencing this issue in versions 1.3.1, 1.3.2 and 1.3.3 of the fragment library. (The latest version of the fragment library at the time of writing is 1.3.3.)
Given that this issue is closed and marked as fixed, I've created a separate issue
Description
When using the new fragment state manager , if a fragment is inflated after the host activity is RESUMED, via either the deprecated , the fragment never makes it to a RESUMED state.
<fragment>
tag orFragmentContainerView
In the case of the
<fragment>
tag:VIEW_CREATED
and never makes it any furtherfor
FragmentContainerView
:RESUMED
the first time, but on configuration change, the view that inflates the fragment is never attached to the new view hierarchy, so the fragment isRESUMED
but never actually visible.We should address this issue for both components. aosp/1591056 and aosp/1593053 have been implemented for the
<fragment>
tag case. This bug will track theFragmentContainerView
case.