[Android] - Implement WindowInsetListener for per coordinator layout #31898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
This pull request introduces a new
MauiCoordinatorLayout
to scope window inset handling per NavigationPage on Android, replacing the previous global approach. The changes ensure that modal dialogs and navigation layouts use a local inset listener, preventing cross-contamination and improving the management of window insets. The implementation includes updates to layout XML, listener attachment logic, and cleanup routines.Navigation and Window Inset Management Improvements:
MauiCoordinatorLayout
, a subclass ofCoordinatorLayout
that owns its ownGlobalWindowInsetListener
, allowing children within its hierarchy to use a local inset listener instead of the activity-wide global listener. This is used for NavigationPage root layouts. (src/Core/src/Platform/Android/MauiCoordinatorLayout.cs
, src/Core/src/Platform/Android/MauiCoordinatorLayout.csR1-R55)navigationlayout.axml
) to useMauiCoordinatorLayout
as the root element instead of the standardCoordinatorLayout
, ensuring that navigation pages are scoped to their own inset listener. (src/Core/src/Platform/Android/Resources/Layout/navigationlayout.axml
, [1] [2]ModalFragment
) and navigation root manager logic to rely on the localMauiCoordinatorLayout
inset listener, removing the need to manually create and clean up separate listeners for modals. (src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Android.cs
, [1] [2] [3];src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs
, [4] [5]GlobalWindowInsetListener API Enhancements:
GlobalWindowInsetListenerExtensions
to prefer attaching/detaching listeners to a parentMauiCoordinatorLayout
if present, allowing for independent inset management within coordinator layout hierarchies. (src/Core/src/Platform/Android/GlobalWindowInsetListener.cs
, [1] [2]Public API Additions:
MauiCoordinatorLayout
and its constructors. (src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
, src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txtR78-R82)Issues Fixed
Fixes #