Fixed
Status Update
Comments
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
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 918b7b274374a2998b70622de9194f73862b0903
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Feb 10 13:26:19 2020
Add lint for LiveData.observe() extension function
The lint rule to replace the fragment LifecycleOwner with the
viewLifecycleOwner in calls to LiveData.observe works fine, but it misses
cases that use the LiveData.observe extension function.
This changes adds the extension function to the list of lint rules.
Test: Verified in sample app
Bug: 148996309
Change-Id: I05d1fe78d088b0d6cce5aa79454b98d25c50faef
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UnsafeFragmentLifecycleObserverDetector.kt
https://android-review.googlesource.com/1231871
Branch: androidx-master-dev
commit 918b7b274374a2998b70622de9194f73862b0903
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon Feb 10 13:26:19 2020
Add lint for LiveData.observe() extension function
The lint rule to replace the fragment LifecycleOwner with the
viewLifecycleOwner in calls to LiveData.observe works fine, but it misses
cases that use the LiveData.observe extension function.
This changes adds the extension function to the list of lint rules.
Test: Verified in sample app
Bug: 148996309
Change-Id: I05d1fe78d088b0d6cce5aa79454b98d25c50faef
M fragment/fragment-lint/src/main/java/androidx/fragment/lint/UnsafeFragmentLifecycleObserverDetector.kt
an...@google.com <an...@google.com> #6
jb...@google.com <jb...@google.com> #7
This has been fixed internally and will be available in the Fragment 1.2.2 release.
Description
Version used:
androidx.fragment:fragment:1.2.0
androidx.lifecycle:lifecycle-lifedata:2.2.0
Devices/Android versions reproduced on: Android studio lint issue. (Android Studio 4.0 canary 9)
I like your lint detector and I agree UnsafeFragmentLifecycleObserverDetector's direction.
UNSAFE_METHODS is like that.
internal val UNSAFE_METHODS = mapOf(
Method("androidx.lifecycle.LiveData", "observe") to LIVEDATA_ISSUE,
Method("androidx.activity.OnBackPressedDispatcher", "addCallback") to BACK_PRESSED_ISSUE
)
(SourceCode referenced is :
And 'inline fun <T> LiveData<T>.observe' was add in 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0'.
It isn't catch by lint in "onCreateView", "onViewCreated", "onActivityCreated", "onViewStateRestored". When I used viewModel.liveData.observe(this) { } in Fragment.
So I hope to add one unsafe method in map of 'UNSAFE_METHODS'.
Method("androidx.lifecycle.LiveDataKt", "observe") to LIVEDATA_ISSUE,
I was test in my example and works good.
Let me know your opinion.
Best Regards.
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).