-
Couldn't load subscription status.
- Fork 461
Refactor system bar visibility handling on Android #2905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor system bar visibility handling on Android #2905
Conversation
Modernized the handling of system bar visibility in the `MauiMediaElement` class by replacing the legacy `SetSystemBarsVisibility` method with a new `SetStatusBarsHidden` method. This leverages modern Android APIs (`WindowManagerFlags` and `WindowInsetsControllerCompat`) for better compatibility and maintainability. Introduced static properties (`window`, `decorView`, `insetsController`) to encapsulate window-related logic with improved error handling. Removed legacy code for Android versions below API 30, simplifying the codebase. Updated fullscreen handling logic to align with modern Android development practices. Improved layout invalidation on fullscreen button clicks and ensured consistent system bar visibility management across the codebase. Enhanced code readability, maintainability, and robustness by reducing duplication, leveraging modern APIs, and improving error handling. Has legacy support from android 26 and is tested against 26, 33,34, and 35 with both button and gesture navigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the system bar visibility handling in the MauiMediaElement Android class by replacing legacy APIs with modern Android approaches. The change improves maintainability and compatibility while fixing issues with tab bar sizing after exiting fullscreen mode.
Key Changes:
- Replaced legacy
SetSystemBarsVisibilitymethod withSetStatusBarsHiddenusing modern Android APIs - Introduced static properties for better window-related logic encapsulation
- Removed support for Android versions below API 26, simplifying the codebase
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.android.cs
Outdated
Show resolved
Hide resolved
…android.cs Good catch Co-authored-by: Copilot <[email protected]>
Refactored `MauiMediaElement` to improve encapsulation by removing static properties (`window`, `decorView`, `insetsController`) and localizing their instantiation within the `SetStatusBarsHidden` method. This change reduces reliance on static properties and enhances maintainability. Updated `using` directives to include aliases for `Android.Views.View` and `Android.Views.Window` to resolve naming conflicts.
Description of Change
Modernized the handling of system bar visibility in the
MauiMediaElementclass by replacing the legacySetSystemBarsVisibilitymethod with a newSetStatusBarsHiddenmethod. This leverages modern Android APIs (WindowManagerFlagsandWindowInsetsControllerCompat) for better compatibility and maintainability.Introduced static properties (
window,decorView,insetsController) to encapsulate window-related logic with improved error handling. Removed legacy code for Android versions below API 30, simplifying the codebase.Updated fullscreen handling logic to align with modern Android development practices. Improved layout invalidation on fullscreen button clicks and ensured consistent system bar visibility management across the codebase.
Enhanced code readability, maintainability, and robustness by reducing duplication, leveraging modern APIs, and improving error handling.
Has legacy support from android 26 and is tested against 26, 33,34, and 35 with both button and gesture navigation.
Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Tested against android 26, 33, 34, and 35. I tested against gesture navigation and 3 button navigation on each platform with media element sample app page. It fixes the issue raised where tab bar size is incorrect upon leaving full screen mode.