Skip to content

fix(android): sync status and navigation bars with app theme#2002

Merged
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/system-bar-theme-sync
Apr 1, 2026
Merged

fix(android): sync status and navigation bars with app theme#2002
bajrangCoder merged 2 commits intoAcode-Foundation:mainfrom
bajrangCoder:fix/system-bar-theme-sync

Conversation

@bajrangCoder
Copy link
Copy Markdown
Member

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR correctly fixes Android system bar (status bar and navigation bar) theming so that bar colors and icon tints follow the app theme after a theme switch, including on OEM devices that leave stale colors behind.

Key changes:

  • Bug fix in setNavigationBarStyle (SDK ≤ 30): The old dark-theme branch evaluated uiOptions | (0x80000000 & ~0x00000010) which collapses to uiOptions | 0x80000000 — it ORed FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS (a Window flag) directly into the View system UI visibility mask and never cleared SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, so switching from a light to a dark theme left navigation bar icons in light style. The new code correctly uses uiOptions & ~lightNavigationBar.
  • New applySystemBarTheme() helper: Explicitly sets FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, disables contrast enforcement (API 29+), sets status and navigation bar colors directly, and updates icon tint styles via the existing helpers. This supplements Cordova's own BackgroundColor preference flow.
  • Improved error handling: A generic catch (Exception e) fallback added to setUiTheme.
  • Threading is safe: set-ui-theme is dispatched via runOnUiThread in the execute switch.

Minor gap: FLAG_TRANSLUCENT_NAVIGATION (0x08000000) is not cleared alongside FLAG_TRANSLUCENT_STATUS in applySystemBarTheme(). On OEM devices where this flag is set, window.setNavigationBarColor() would silently have no effect.

Confidence Score: 4/5

Safe to merge with a minor OEM edge-case gap; the core bug fix is correct and well-guarded.

All findings are P2. The main bug fix (dark-theme navigation bar style on SDK ≤ 30) is correct. Threading is handled properly. The only gap is that FLAG_TRANSLUCENT_NAVIGATION is not cleared, which is a narrow OEM edge case and not a regression. Scoring 4 to nudge the author to consider the one-liner improvement before merge.

Only System.java is changed; the applySystemBarTheme() method warrants a second look for the missing FLAG_TRANSLUCENT_NAVIGATION clear.

Important Files Changed

Filename Overview
src/plugins/system/android/com/foxdebug/system/System.java Adds applySystemBarTheme() to directly set window bar colors/flags on theme change, and fixes a pre-existing bug in setNavigationBarStyle for SDK ≤ 30 where the dark-theme branch incorrectly ORed a Window flag into View UI-visibility flags and failed to clear SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR. One minor gap: FLAG_TRANSLUCENT_NAVIGATION is not cleared, which can prevent setNavigationBarColor() from taking effect on OEM devices with translucent navigation bars.

Sequence Diagram

sequenceDiagram
    participant JS as JavaScript
    participant Cordova as Cordova Plugin Manager
    participant Plugin as System.java
    participant UI as UI Thread
    participant Window as Android Window

    JS->>Cordova: set-ui-theme(color, scheme)
    Cordova->>UI: runOnUiThread()
    UI->>Plugin: setUiTheme(color, scheme)
    Plugin->>Plugin: Color.parseColor(color)
    Plugin->>Plugin: new Theme(scheme)
    Plugin->>Cordova: preferences.set("BackgroundColor", color)
    Plugin->>Cordova: postMessage("updateSystemBars")
    Plugin->>Plugin: applySystemBarTheme()
    Plugin->>Window: clearFlags(FLAG_TRANSLUCENT_STATUS)
    Plugin->>Window: addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
    Plugin->>Window: setNavigationBarContrastEnforced(false) [API 29+]
    Plugin->>Window: setStatusBarContrastEnforced(false) [API 29+]
    Plugin->>Window: decorView.setBackgroundColor(color)
    Plugin->>Window: rootView.setBackgroundColor(color)
    Plugin->>Window: setStatusBarColor(color) [API 21+]
    Plugin->>Window: setNavigationBarColor(color) [API 21+]
    Plugin->>Plugin: setStatusBarStyle(window)
    Plugin->>Plugin: setNavigationBarStyle(window)
    Plugin->>JS: callback.success()
Loading

Reviews (1): Last reviewed commit: "fix(android): sync status and navigation..." | Re-trigger Greptile

@RohitKushvaha01 RohitKushvaha01 added the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Mar 31, 2026
@github-actions github-actions bot removed the CI: RUN ON-DEMAND PREVIEW RELEASES Triggers an on-demand preview build for this pull request via CI workflow. label Mar 31, 2026
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

Preview Release for this, has been built.

Click here to view that github actions build

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@bajrangCoder bajrangCoder merged commit cc7bf73 into Acode-Foundation:main Apr 1, 2026
6 checks passed
@bajrangCoder bajrangCoder deleted the fix/system-bar-theme-sync branch April 1, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants