Files
xamarin-neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.Android/MainActivity.cs
Gerwin Kuijntjes 9421582e2c Android: toolbar colors, action mode, popup menu text fix
- Set colorPrimary/colorPrimaryDark/colorAccent to dark app colors (#31333b)
- Fix contextual action bar (CAB) background to match nav bar color
- Fix overflow button (3-dot) tint to white via OverflowMenuButton style
- Fix white-on-white popup menu text: remove global android:textColorPrimary
  override; scope white text only to CAB via ActionModeStyle/ActionModeTitleText
- Add android:windowLightStatusBar=false so status bar icons are white on dark bg

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 14:46:57 +02:00

38 lines
1.4 KiB
C#

using Android.App;
using Android.Content.PM;
using Android.Content.Res;
using Microsoft.Maui;
using Microsoft.Maui.ApplicationModel;
namespace Xamarin.Neo4j.Android
{
[Activity(
Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation |
ConfigChanges.UiMode | ConfigChanges.ScreenLayout |
ConfigChanges.SmallestScreenSize | ConfigChanges.Density
)]
public class MainActivity : MauiAppCompatActivity
{
protected override void OnResume()
{
base.OnResume();
// Re-apply theme and nav bar colours when returning to the foreground.
// ConfigChanges.UiMode prevents Activity recreation on system theme change,
// so RequestedThemeChanged may not fire reliably — we re-derive the theme
// from the current configuration instead.
if (IPlatformApplication.Current?.Application is App app)
{
var nightMode = Resources.Configuration.UiMode & UiMode.NightMask;
var theme = nightMode == UiMode.NightYes
? AppTheme.Dark
: AppTheme.Light;
MainThread.BeginInvokeOnMainThread(() => app.UpdateTheme(theme));
}
}
}
}