-
Notifications
You must be signed in to change notification settings - Fork 473
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?
Changes from 1 commit
c8bb250
d232160
74bc57f
bebea47
23fad18
2fa5a76
1d0eeef
3c36391
057968c
42c6154
26de3a4
07a243c
cdb62a9
a298d83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,11 +20,12 @@ namespace CommunityToolkit.Maui.Core.Views; | |||||||||||||||
| /// </summary> | ||||||||||||||||
| public class MauiMediaElement : CoordinatorLayout | ||||||||||||||||
| { | ||||||||||||||||
| static Android.Views.Window window => Platform.CurrentActivity?.Window ?? throw new InvalidOperationException("Current activity is null"); | ||||||||||||||||
| static Android.Views.View decorView => window.DecorView ?? throw new InvalidOperationException("DecorView is null"); | ||||||||||||||||
| static AndroidX.Core.View.WindowInsetsControllerCompat insetsController => WindowCompat.GetInsetsController(window, decorView) ?? throw new InvalidOperationException("InsetsController is null"); | ||||||||||||||||
| readonly RelativeLayout relativeLayout; | ||||||||||||||||
| readonly PlayerView playerView; | ||||||||||||||||
|
|
||||||||||||||||
| int defaultSystemUiVisibility; | ||||||||||||||||
| bool isSystemBarVisible; | ||||||||||||||||
| bool isFullScreen; | ||||||||||||||||
|
|
||||||||||||||||
| #pragma warning disable CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. | ||||||||||||||||
|
|
@@ -78,7 +79,7 @@ protected override void OnVisibilityChanged(Android.Views.View changedView, [Gen | |||||||||||||||
| base.OnVisibilityChanged(changedView, visibility); | ||||||||||||||||
| if (isFullScreen && visibility is ViewStates.Visible) | ||||||||||||||||
| { | ||||||||||||||||
| SetSystemBarsVisibility(); | ||||||||||||||||
| SetStatusBarsHidden(isFullScreen); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -131,77 +132,31 @@ void OnFullscreenButtonClick(object? sender, PlayerView.FullscreenButtonClickEve | |||||||||||||||
| isFullScreen = false; | ||||||||||||||||
| layout?.RemoveView(relativeLayout); | ||||||||||||||||
| AddView(relativeLayout); | ||||||||||||||||
| relativeLayout.Invalidate(); | ||||||||||||||||
| } | ||||||||||||||||
| // Hide/Show the SystemBars and Status bar | ||||||||||||||||
| SetSystemBarsVisibility(); | ||||||||||||||||
| SetStatusBarsHidden(isFullScreen); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
| /// <summary> | |
| /// Sets the visibility of system bars (status bar and navigation bar). | |
| /// </summary> | |
| /// <param name="hidden">If <see langword="true"/>, hides the system bars; otherwise, shows them.</param> | |
| /// <exception cref="InvalidOperationException">Thrown when the current activity, DecorView, or InsetsController is null.</exception> |
Copilot
AI
Nov 20, 2025
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.
The method SetStatusBarsHidden is marked as public static, but it should be private or internal since it's an implementation detail of system bar visibility management. Making it public exposes internal Android-specific behavior that shouldn't be part of the public API surface. Consider changing the visibility to private or internal.
| public static void SetStatusBarsHidden(bool hidden) | |
| static void SetStatusBarsHidden(bool hidden) |
Uh oh!
There was an error while loading. Please reload this page.