Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@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 75ee4a9efb5e1f8ff1b1dfca5bfeb151a7605f54
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Feb 22 15:44:08 2021
Set ViewTree owners for dialogs in DialogFragment
While Fragments with a view set their ViewTree owners automatically,
since DialogFragments do not always have a view (as in the case of only
using onCreateDialog), it is possible to have a DialogFragment but no
ViewTree owners set.
We should set the ViewTree owners on the DialogFragment dialog's decor
view. This way it can be accessed.
RelNote: "Dialogs within a DialogFragment can now get access to ViewTree
owners through their DecorView"
Test: testDialogFragmentViewTree
Bug: 180691023
Change-Id: Ib92905306e16dcaee63c985f22b5e36b6718dd39
A fragment/fragment/src/androidTest/java/androidx/fragment/app/DialogFragmentViewTreeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/DialogFragment.java
https://android-review.googlesource.com/1600577
Branch: androidx-main
commit 75ee4a9efb5e1f8ff1b1dfca5bfeb151a7605f54
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Feb 22 15:44:08 2021
Set ViewTree owners for dialogs in DialogFragment
While Fragments with a view set their ViewTree owners automatically,
since DialogFragments do not always have a view (as in the case of only
using onCreateDialog), it is possible to have a DialogFragment but no
ViewTree owners set.
We should set the ViewTree owners on the DialogFragment dialog's decor
view. This way it can be accessed.
RelNote: "Dialogs within a DialogFragment can now get access to ViewTree
owners through their DecorView"
Test: testDialogFragmentViewTree
Bug: 180691023
Change-Id: Ib92905306e16dcaee63c985f22b5e36b6718dd39
A fragment/fragment/src/androidTest/java/androidx/fragment/app/DialogFragmentViewTreeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/DialogFragment.java
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be released as part of the Fragment 1.3.1
version.
You can verify this by following the 7166224
and switching your fragment dependency to 1.4.0-SNAPSHOT
.
jb...@google.com <jb...@google.com>
ma...@gwplc.com <ma...@gwplc.com> #5
With this bug essentially meaning that DialogFragments cannot be used with Compose, would it be possible to please backport this fix into the Fragment 1.3.0
version?
Description
Version used:
androidx.activity:activity-compose:1.3.0-alpha02
androidx.fragment:fragment-ktx:1.3.0-beta01
androidx.compose.runtime:runtime:1.0.0-alpah12
Devices/Android versions reproduced on:
emulator Pixel 3 API 29
Sample code:
From any fragment calling TestDialogFragment using
TestDialogFragment().show(childFragmentManager, "Test")
or Navigation way:
findNavController().navigate(MainFragmentDirections.actionToTestDialog())
class TestDialogFragment : DialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = ComposeView(requireContext()).apply {
setContent {
Surface {
TestDialogLayout()
}
}
}
}
Will cause the exception:
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@bec849f[MainActivity]
at androidx.compose.ui.platform.WindowRecomposerKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.kt:231)
Can be manually fixed by setting the ViewTreeLifecycleOwner in onCreateView at the beginning:
dialog?.window?.decorView?.let {
ViewTreeLifecycleOwner.set(it, viewLifecycleOwner)
}