From 7d8739522a14b6698f92333046575bbe86c804ab Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Thu, 21 May 2026 09:04:13 +0200 Subject: [PATCH 1/3] Try MAUI 10 SafeAreaEdges=Container on ContentPage for edge-to-edge MAUI 10's MauiAppCompatActivity.OnCreate unconditionally calls WindowCompat.SetDecorFitsSystemWindows(window, false), embracing edge-to-edge regardless of targetSdkVersion. The pre-.NET-10 windowOptOutEdgeToEdgeEnforcement style is therefore moot - MAUI itself is opting in, not Android API 36. Fortunately MAUI 10 ships a built-in solution: ContentPage now implements ISafeAreaView2 and exposes a SafeAreaEdges bindable property. When set, MAUI's inset listener on the ContentViewGroup (decompiled at SafeAreaExtensions.ApplyAdjustedSafeAreaInsetsPx) pads the page so the BlazorWebView sits inside the system-bar safe area. Default is SafeAreaEdges.None, which is why our untouched ContentPage draws under the bars today. Setting SafeAreaEdges="Container" on MainPage.xaml is a 1-line change that should obviate the AndroidEdgeToEdgeInsets JS-injection workaround (left in place but unused; can be deleted if this approach is adopted). Not yet verified on-device - Agent 2 holds the emulator lock. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/FwLite/FwLiteMaui/MainPage.xaml | 3 ++- backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/FwLite/FwLiteMaui/MainPage.xaml b/backend/FwLite/FwLiteMaui/MainPage.xaml index 11f4574c9a..b16b9382f1 100644 --- a/backend/FwLite/FwLiteMaui/MainPage.xaml +++ b/backend/FwLite/FwLiteMaui/MainPage.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:FwLiteMaui" xmlns:shared="clr-namespace:FwLiteShared;assembly=FwLiteShared" - x:Class="FwLiteMaui.MainPage"> + x:Class="FwLiteMaui.MainPage" + SafeAreaEdges="Container"> diff --git a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs index 21879541d9..090004407a 100644 --- a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs +++ b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs @@ -36,6 +36,13 @@ private partial void BlazorWebViewInitialized(object? sender, BlazorWebViewIniti ? (e.WebView.WebChromeClient ?? new Android.Webkit.WebChromeClient()) : new Android.Webkit.WebChromeClient(); e.WebView.SetWebChromeClient(new PermissionManagingBlazorWebChromeClient(baseClient, activity)); + + // Edge-to-edge handling is delegated to MAUI 10's built-in SafeAreaEdges + // support on ContentPage (see MainPage.xaml: SafeAreaEdges="Container"). + // MAUI 10 unconditionally calls WindowCompat.SetDecorFitsSystemWindows(false) + // in MauiAppCompatActivity.OnCreate, then pads the ContentViewGroup so the + // BlazorWebView lives inside the system-bar safe area. No manual JS-injected + // CSS variables needed. } private partial void BlazorWebViewOnUrlLoading(object? sender, UrlLoadingEventArgs e) From ff100d57e88ecc4105e2e1a25488c716edf24f06 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Thu, 21 May 2026 11:00:11 +0200 Subject: [PATCH 2/3] Brand-color the system-bar gutter on Android edge-to-edge MAUI 10 / .NET 10 unconditionally puts the activity in edge-to-edge mode on Android, so the existing windowOptOutEdgeToEdgeEnforcement style was a no-op and the BlazorWebView was drawing behind the system bars. MainPage's SafeAreaEdges="Container" (from the previous commit) pads the WebView back inside the safe area. This commit paints the surrounding gutter with the brand color (colorPrimaryDark) and pins the system-bar icons to light, matching the pre-MAUI-10 look across both system theme toggles and the app's in-app theme override. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../FwLiteMaui/MainPage.xaml.Android.cs | 10 +++---- .../Platforms/Android/MainActivity.cs | 27 +++++++++++++++++-- .../Android/Resources/values-v35/styles.xml | 6 ----- .../Android/Resources/values/styles.xml | 5 ---- 4 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values-v35/styles.xml delete mode 100644 backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values/styles.xml diff --git a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs index 090004407a..e8113baa93 100644 --- a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs +++ b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs @@ -37,12 +37,10 @@ private partial void BlazorWebViewInitialized(object? sender, BlazorWebViewIniti : new Android.Webkit.WebChromeClient(); e.WebView.SetWebChromeClient(new PermissionManagingBlazorWebChromeClient(baseClient, activity)); - // Edge-to-edge handling is delegated to MAUI 10's built-in SafeAreaEdges - // support on ContentPage (see MainPage.xaml: SafeAreaEdges="Container"). - // MAUI 10 unconditionally calls WindowCompat.SetDecorFitsSystemWindows(false) - // in MauiAppCompatActivity.OnCreate, then pads the ContentViewGroup so the - // BlazorWebView lives inside the system-bar safe area. No manual JS-injected - // CSS variables needed. + // Edge-to-edge handling: MAUI 10 unconditionally opts the activity into + // edge-to-edge on Android, and MainPage's SafeAreaEdges="Container" pads + // the BlazorWebView inside the system-bar safe area. MainActivity paints + // the surrounding gutter with the brand color (colorPrimaryDark). } private partial void BlazorWebViewOnUrlLoading(object? sender, UrlLoadingEventArgs e) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs b/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs index ee6edadf3a..cdcca7493d 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs @@ -1,7 +1,9 @@ using Android.App; using Android.Content; using Android.Content.PM; +using Android.Content.Res; using Android.OS; +using AndroidX.Core.View; using FwLiteShared.Auth; using Microsoft.Identity.Client; @@ -16,9 +18,30 @@ public class MainActivity : MauiAppCompatActivity { protected override void OnCreate(Bundle? savedInstanceState) { - //custom style, declared in Android/Resources/values/styles.xml, values-v35 is used based on the android version - Theme?.ApplyStyle(Resource.Style.OptOutEdgeToEdgeEnforcement, force: false); base.OnCreate(savedInstanceState); + ApplyBrandedSystemBars(); + } + + public override void OnConfigurationChanged(Configuration newConfig) + { + base.OnConfigurationChanged(newConfig); + // MAUI re-decides system-bar icon appearance on config changes, so + // re-pin it after the base call. + ApplyBrandedSystemBars(); + } + + // Paints the system-bar gutter left around the BlazorWebView (by + // MainPage's SafeAreaEdges="Container") with the brand color and pins + // the icons to light so they stay readable regardless of system theme + // or in-app theme overrides. + private void ApplyBrandedSystemBars() + { + if (Window is null) return; + Window.SetBackgroundDrawableResource(Resource.Color.colorPrimaryDark); + var controller = WindowCompat.GetInsetsController(Window, Window.DecorView); + if (controller is null) return; + controller.AppearanceLightStatusBars = false; + controller.AppearanceLightNavigationBars = false; } protected override void OnActivityResult(int requestCode, Result resultCode, Intent? data) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values-v35/styles.xml b/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values-v35/styles.xml deleted file mode 100644 index 9df79fe9b4..0000000000 --- a/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values-v35/styles.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values/styles.xml b/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values/styles.xml deleted file mode 100644 index 2ad8b4dd86..0000000000 --- a/backend/FwLite/FwLiteMaui/Platforms/Android/Resources/values/styles.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - From 933880868ae89290288310b7a5eda1adba15aa47 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Thu, 21 May 2026 14:15:25 +0200 Subject: [PATCH 3/3] Drop redundant comments Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs | 5 ----- backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs | 6 ------ 2 files changed, 11 deletions(-) diff --git a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs index e8113baa93..21879541d9 100644 --- a/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs +++ b/backend/FwLite/FwLiteMaui/MainPage.xaml.Android.cs @@ -36,11 +36,6 @@ private partial void BlazorWebViewInitialized(object? sender, BlazorWebViewIniti ? (e.WebView.WebChromeClient ?? new Android.Webkit.WebChromeClient()) : new Android.Webkit.WebChromeClient(); e.WebView.SetWebChromeClient(new PermissionManagingBlazorWebChromeClient(baseClient, activity)); - - // Edge-to-edge handling: MAUI 10 unconditionally opts the activity into - // edge-to-edge on Android, and MainPage's SafeAreaEdges="Container" pads - // the BlazorWebView inside the system-bar safe area. MainActivity paints - // the surrounding gutter with the brand color (colorPrimaryDark). } private partial void BlazorWebViewOnUrlLoading(object? sender, UrlLoadingEventArgs e) diff --git a/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs b/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs index cdcca7493d..c8b0d36594 100644 --- a/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs +++ b/backend/FwLite/FwLiteMaui/Platforms/Android/MainActivity.cs @@ -25,15 +25,9 @@ protected override void OnCreate(Bundle? savedInstanceState) public override void OnConfigurationChanged(Configuration newConfig) { base.OnConfigurationChanged(newConfig); - // MAUI re-decides system-bar icon appearance on config changes, so - // re-pin it after the base call. ApplyBrandedSystemBars(); } - // Paints the system-bar gutter left around the BlazorWebView (by - // MainPage's SafeAreaEdges="Container") with the brand color and pins - // the icons to light so they stay readable regardless of system theme - // or in-app theme overrides. private void ApplyBrandedSystemBars() { if (Window is null) return;