Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,44 @@ static void PlatformSetColor(Color color)

if (statusBarOverlay is null)
{
Comment on lines 52 to 53
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SetBackgroundColor(platformColor) is now only called when the overlay is first created. If statusBarOverlay already exists (found by tag), this method no longer updates its color, so subsequent PlatformSetColor calls won't change the overlay color. Consider moving the background-color update back outside the if (statusBarOverlay is null) block (and/or updating it in the existing-overlay path).

Copilot uses AI. Check for mistakes.
var statusBarHeight = Activity.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0;
var statusBarPixelSize = statusBarHeight > 0 ? Activity.Resources?.GetDimensionPixelSize(statusBarHeight) ?? 0 : 0;

statusBarOverlay = new(Activity)
void SetupStatusBarOverlay(int statusBarPixelSize)
{
LayoutParameters = new FrameLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, statusBarPixelSize + 3)
statusBarOverlay = new(Activity)
{
Gravity = GravityFlags.Top
}
};

statusBarOverlay.Tag = statusBarOverlayTag;
decorGroup.AddView(statusBarOverlay);
statusBarOverlay.SetZ(0);
LayoutParameters =
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
statusBarPixelSize + 3)
{
Gravity = GravityFlags.Top
}
};

statusBarOverlay.Tag = statusBarOverlayTag;
decorGroup.AddView(statusBarOverlay);
statusBarOverlay.SetZ(0);
statusBarOverlay.SetBackgroundColor(platformColor);
}

if (OperatingSystem.IsAndroidVersionAtLeast(36))
{
window.DecorView.Post(() =>
{
var insets = window.DecorView.RootWindowInsets;
var top = insets?.GetInsets(WindowInsets.Type.StatusBars()).Top ?? 0;

Comment on lines +74 to +78
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Android 36+, statusBarOverlay is only assigned inside the DecorView.Post callback. Until that runs, FindViewWithTag will keep returning null on subsequent PlatformSetColor calls, causing multiple posts and potentially multiple overlays being added. Add a guard in the posted callback (re-check FindViewWithTag / statusBarOverlay before creating), or create/add the overlay immediately and only adjust its height once insets are available.

Copilot uses AI. Check for mistakes.
SetupStatusBarOverlay(top);
});
}
else
{
var statusBarHeight = Activity.Resources?.GetIdentifier("status_bar_height", "dimen", "android") ?? 0;
var statusBarPixelSize = statusBarHeight > 0
? Activity.Resources?.GetDimensionPixelSize(statusBarHeight) ?? 0
: 0;

SetupStatusBarOverlay(statusBarPixelSize);
}
}

statusBarOverlay.SetBackgroundColor(platformColor);
}
else
{
Expand Down
Loading