Skip to content

fix(v3/android): apply the "color" field in SetStatusBar - #6193

Open
sinspired wants to merge 1 commit into
wailsapp:masterfrom
sinspired:fix/v3/statusBarColor
Open

sinspired wants to merge 1 commit into
wailsapp:masterfrom
sinspired:fix/v3/statusBarColor

Conversation

@sinspired

Copy link
Copy Markdown
Contributor

Description

application.Mobile.SetStatusBar(json) on Android only ever applied the
"style" (icon light/dark) and "hidden" keys from its JSON payload.
WailsBridge.setStatusBar() never read a "color" key, so there was no
way to set the status-bar background color at runtime — it always
reflected whatever android:statusBarColor resolved to statically in
the app's theme at Activity creation.

This becomes a real, user-visible bug for any app that implements its
own in-app light/dark toggle (as opposed to following the OS-level
day/night setting): switching themes updates the status-bar icon color
correctly, but the background stays at whatever the static theme
resolved to when the Activity launched — e.g. light icons rendered over
a background that's still light, making the status bar unreadable.
Reproduced on a real Android 9 device; on some other devices/emulators
this silently self-corrects only because the OS-level dark mode happens
to already match, which is what made it easy to miss.

This PR adds optional color support:

  • WailsBridge.setStatusBar() now also reads "color" ("#RRGGBB" or
    "#AARRGGBB") and applies it via Window.setStatusBarColor(),
    alongside the existing style/hidden handling.
  • Purely additive: unknown/missing "color" is a no-op, so this is
    fully backward compatible — no method signature changed, no existing
    behaviour changed for callers that don't send it.
  • iOS is intentionally untouched: UIStatusBarStyle has no
    background-color concept (the status bar there is always a
    transparent overlay), so a "color" key isn't meaningful on that
    platform and mobile_features_ios.go doesn't need a matching field.

Is a WEP required?

This adds a new optional key to an existing JSON payload rather than a
new method or interface change — MobileManager.SetStatusBar's
signature is unchanged, and no other file needs updating to keep the
interface satisfied. My read is this is small enough to not need one,
but flagging it since it's technically a new capability rather than a
strict regression fix, and I'd rather ask than assume.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • WEP (proposal only; no implementation)
  • Breaking change
  • This change requires a documentation update

How Has This Been Tested?

Reproduced and verified on a real Android 9 device (美图 V3): before this
change, toggling the app's in-app dark theme changed the status-bar icon
color but left the background white, making the icon text unreadable;
after applying this fix, the background now follows the app's chosen
color and the icon/background stay in sync. Also verified no regression
on an Android (Pixel 10 Pro, emulator) build where the OS-level dark
mode already masked the bug.

  • Windows
  • macOS
  • Linux
  • Android
  • iOS (not applicable — no code path touched on this platform)

Test Configuration

<paste your wails3 doctor output here>

Checklist:

  • (v3) Added an entry to v3/UNRELEASED_CHANGELOG.md
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (English
    source only — mobile-api.md and the SetStatusBar doc comment in
    mobile_features_android.go; translated doc copies are
    community-maintained and left untouched)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my
    feature works — this is a thin Android UI call with no branching
    logic to unit test; verified manually on-device as above
  • New and existing unit tests pass locally with my changes

application.Mobile.SetStatusBar(json) has always accepted only "style"
(icon light/dark) and "hidden" in its JSON payload on Android — the
"color" key that callers might reasonably expect a status-bar API to
support (matching how the equivalent theme attribute
android:statusBarColor already colors it statically) was never read by
WailsBridge.setStatusBar(), so the status-bar background could only ever
reflect whatever was baked into the app's static theme at Activity
creation, never anything set at runtime.

This is easy to hit for any app that switches between light/dark themes
at runtime from JS rather than following the OS-level day/night setting:
the icon style updates correctly (that part was already wired), but the
background color stays stuck at whatever the static theme resolved to
when the Activity was created, silently mismatching the new icon color —
e.g. light icons on a still-light background, unreadable status-bar text.

Add color handling: parse an optional "color" key ("#RRGGBB" /
"#AARRGGBB") and apply it via Window.setStatusBarColor(), alongside the
existing style/hidden handling. No API surface changes — "color" is a
new optional key in an existing JSON payload, so this is fully backward
compatible with callers that don't send it.

Not applicable to iOS: UIStatusBarStyle has no background-color concept
there (the iOS status bar is always a transparent overlay tinted by
whatever view sits behind it), so this is an Android-only addition and
mobile_features_ios.go is untouched.

Touches:
- v3/internal/commands/build_assets/android/app/src/main/java/com/wails/app/WailsBridge.java
- v3/pkg/application/mobile_features_android.go (doc comment)
- v3/examples/mobile/build/android/app/src/main/java/com/wails/app/WailsBridge.java
@github-actions github-actions Bot added Bug Something isn't working v3 cli labels Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working cli v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant