Status Update
Comments
al...@google.com <al...@google.com>
[Deleted User] <[Deleted User]> #2
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
ky...@gmail.com <ky...@gmail.com> #3
This is a platform behavior change.
al...@google.com <al...@google.com> #4
rg...@google.com <rg...@google.com>
da...@gmail.com <da...@gmail.com> #6
Any progress?
ho...@eure.jp <ho...@eure.jp> #7
vr...@deezer.com <vr...@deezer.com> #9
br...@monzo.com <br...@monzo.com> #10
This issue is also stopping us from being able to support edge-to-edge in Android 15. Given it's a enforced requirement for targeting Android 15, couldn't this be prioritised higher? Companies like us have hundreds of screens to fix so waiting until 2025 for a workaround is going to be tough work.
rg...@google.com <rg...@google.com>
ti...@google.com <ti...@google.com> #11
Maybe you can create a static method, com.your.company.ViewGroupCompat#installCompatInsetsDispatch
, like this:
After creating the method, you need to call ViewGroupCompat.installCompatInsetsDispatch(getWindow().getDecorView())
in onCreate()
of your activity to make the behavior compatible with API 30+.
When the new library with the API is released, you can replace com.your.company.ViewGroupCompat
with androidx.core.view.ViewGroupCompat
.
br...@monzo.com <br...@monzo.com> #12
Wow quick response, thanks! I just tried applying that workaround to our root view and can confirm it fixes the issue. (Also FYI there's a typo in the PR; "comsumed")
en...@gmail.com <en...@gmail.com> #13
I'm getting a crash when using new version of ktx-core 1.16.0-alpha01
with fixed ViewCompat and ViewGroupCompat on API < 30. This is related to FragmentContainerView
:
java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.fragment.app.FragmentContainerView.setOnApplyWindowInsetsListener, parameter listener
at androidx.fragment.app.FragmentContainerView.setOnApplyWindowInsetsListener(Unknown Source:2)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:255)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.dispatchApplyWindowInsets(ViewGroupCompat.java:264)
at androidx.core.view.ViewGroupCompat.lambda$installCompatInsetsDispatch$0(ViewGroupCompat.java:218)
at androidx.core.view.ViewGroupCompat$$ExternalSyntheticLambda1.onApplyWindowInsets(D8$$SyntheticClass:0)
at android.view.View.dispatchApplyWindowInsets(View.java:10499)
at android.view.ViewGroup.dispatchApplyWindowInsets(ViewGroup.java:7191)
at android.view.ViewRootImpl.dispatchApplyInsets(ViewRootImpl.java:1925)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2030)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
at android.view.Choreographer.doCallbacks(Choreographer.java:790)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
ti...@google.com <ti...@google.com> #14
Re
I think the @NonNull
annotation of androidx.fragment.app.FragmentContainerView.setOnApplyWindowInsetsListener
has been removed since
Do you mind upgrading your androidx.fragment version to 1.4.0-alpha09 or above? The latest version is
ti...@google.com <ti...@google.com> #17
Ah, you are right. It still requires a non-null object since the required type is not OnApplyWindowInsetsListener?
but OnApplyWindowInsetsListener
.
public override fun setOnApplyWindowInsetsListener(listener: OnApplyWindowInsetsListener) {
applyWindowInsetsListener = listener
}
Hi Jeremy,
Do you mind checking why androidx.fragment.app.FragmentContainerView.setOnApplyWindowInsetsListener
requires a non-null parameter? The restriction was added in
ap...@google.com <ap...@google.com> #18
Project: platform/frameworks/support
Branch: androidx-main
Author: Jeremy Woods <
Link:
Change the nullability of setOnApplyWindowInsetsListener
Expand for full commit details
Change the nullability of setOnApplyWindowInsetsListener
Since setOnApplyWindowInsetsListener overrides a method from the View
class which is in java and has no nullability, we did not know the
proper nullability.
It seems there are cases when the inset listener could indeed be null,
so we can make that nullable now.
RelNote: "FragmentContainerView's `setOnApplyWindowInsetsListener`
override now takes a null listener."
Test: All tests pass
Bug: 282790626
Change-Id: I575f0b5da72d096b14393afd9819ab66e061b002
Files:
- M
fragment/fragment/src/main/java/androidx/fragment/app/FragmentContainerView.kt
Hash: 415aeef3c0a44db3b614b717a65f8f028feef165
Date: Wed Jan 08 18:27:20 2025
jb...@google.com <jb...@google.com> #19
Hey Tiger,
I made it nullable again. We will release this in the next couple of weeks or so.
ti...@google.com <ti...@google.com> #20
Thank you Jeremy.
Since androidx.core
as mentioned at
If the issue mentioned at
de...@gmail.com <de...@gmail.com> #21
Any update on this to fix the crashing? Also does this new API will also fix the callback not being triggered after configuration change (orientation) for Android Tablet running on Android 21? We noticed another fragmented behavior between phone at tablet size devices where the setOnApplyWindowInsetsListener
callback is not being triggered in Fragments after configuration change.
Activity (callback is being triggered on both phone and tablet after configuration change)
ViewCompat.setOnApplyWindowInsetsListener(root) { _: View, insets: WindowInsetsCompat ->
// Return WindowInsetsCompat.CONSUMED if you don't want the window insets to keep passing down
// to descendant views including all views of Fragment(s) under this Activity
insets
}
Fragment with Jetpack Navigation (callback is being triggered regardless of Android version on phone size device after configuration change, but not on tablet running on Android 21)
ViewCompat.setOnApplyWindowInsetsListener(root) { _: View, insets: WindowInsetsCompat ->
// Return WindowInsetsCompat.CONSUMED if you don't want the window insets to keep passing down
// to descendant views including all views of Fragment(s) under this Activity
WindowInsetsCompat.CONSUMED
}
Also hoping
gr...@gmail.com <gr...@gmail.com> #22
Any chance this issue gets higher priority? It's a shame that Google is forcing developers to migrate to Android 15 and setup edge-to-edge while still having critical compatibility issues with older Android versions even in apps with relatively modern stack (Fragment + Compose)
ch...@gmail.com <ch...@gmail.com> #23
ti...@google.com <ti...@google.com> #24
Hi Jeremy,
Do you have any update about the new release?
jb...@google.com <jb...@google.com> #25
Build cut is this Wednesday and it will be released next week as part of Fragment 1.8.6
.
Description
According to docs
WindowInsetsCompat.CONSUMED
used inViewCompat.setOnApplyWindowInsetsListener
lambda should affect only View's direct children. This is working as expected on API >= 30, but on lower API's it affects whole View hierarchy making all other Views (even indirect children) ignore Insets.This behaviour is reproduced here:https://github.com/ai-corpo/InsetsTest . On API 30
NestedScrollView
respects bottom Inset even if topAppBar
returnedWindowInsetsCompat.CONSUMED
, but on lower API's same code makesNestedScrollView
ignore Insets.