fix(android): sync upstream SystemBars fixes #8480 and #8481

Merged
RI
3mo ago
+171-19

What

Syncs two SystemBars fixes that are merged in ionic-team/capacitor but missing from plus:

  • #8481 — respect insetsHandling: "disable"
  • #8480 — show only the requested system bar

Plus one integration fix needed to make the two work together (details below).

Why

Both were carried by the stale upstream-sync branches, bundled with the "upstream-preferred fallback" resolution that renamed @capacitor-plus/* back to @capacitor/* and wiped the fork's changelogs. Stripping that damage from #71/#83/#85/#87/#88 also dropped these two genuine fixes on the floor. CodeRabbit flagged both as out-of-diff findings while reviewing #67, which is how they resurfaced.

They are worth having on their own merits:

  • insetsHandling: "disable" did not work. Upstream #8424 removed the insetHandlingEnabled guard, so the listener was installed and insets were rewritten regardless of config. #67 restored the guard on the CSS injections; #8481 finishes the job by returning early from initWindowInsetsListener, gating onDOMReady, and validating the config value with a warning on unknown input.
  • Hiding the status bar also showed the navigation bar. setHidden(false, "StatusBar") called show(Type.systemBars()), which covers both bars. #8480 narrows each branch to the bar actually requested and adds SystemBarsTest.

How

Cherry-picked d4ad7ff and 4c6c321 with git cherry-pick -x, preserving upstream authorship.

d4ad7ff conflicted with #67, which had just landed and reworks the same methods. Resolved by keeping #67's structure and layering #8481's config handling on top:

  • insetHandlingEnabled (boolean) becomes insetsHandling (String), with all five call sites migrated to INSETS_HANDLING_CSS.equals(insetsHandling).
  • Kept #67's ViewCompat.getRootWindowInsets(v) in initSafeAreaCSSVariables rather than upstream's WindowInsetsCompat.CONSUMED fallback, which yields zeros below API 35.
  • Kept #67's ViewCompat.requestApplyInsets(parentView) in onDOMReady over upstream's getBridge().getWebView().requestApplyInsets().

The third commit is a fork-specific integration fix. navBarVisible (added by #67) was only updated in the per-bar branches, but #8480 restructured setHidden so bar.isEmpty() — the path initSystemBars uses for the hidden config — hides or shows every bar at once. With hidden: true the navigation bar was hidden while navBarVisible stayed true, so the API < 30 safe-area fallback reported a nav bar height for a bar that was not on screen. Upstream cannot have this bug because navBarVisible only exists here.

Testing

  • bun run eslint and bun run prettier --check pass locally.
  • SystemBarsTest.java comes from upstream #8480 and runs in test-android.
  • CI (setup / lint / test-cli / test-core / test-ios / test-android) runs on this PR.

Not Tested

  • No on-device verification of insetsHandling: "disable", of hiding a single bar, or of the navBarVisible fix on an API < 30 device. All three are reasoned from the code and upstream's intent.

Opened by an AI agent (Cursor).

Open in Web Open in Cursor 

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.