Skip to content

Conversation

ne0rrmatrix
Copy link
Contributor

  • Bug fix

Description of Change

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.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional 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.

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.
@Copilot Copilot AI review requested due to automatic review settings October 11, 2025 10:30
Copy link
Contributor

@Copilot Copilot AI left a 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 SetSystemBarsVisibility method with SetStatusBarsHidden using modern Android APIs
  • Introduced static properties for better window-related logic encapsulation
  • Removed support for Android versions below API 26, simplifying the codebase

ne0rrmatrix and others added 2 commits October 11, 2025 03:36
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] TabBar position is changed after MediaElement exits fullscreen mode on Android

1 participant