feat(android): add opt-in hideNavigationBar option for immersive mode#468
feat(android): add opt-in hideNavigationBar option for immersive mode#468dalmasonto wants to merge 2 commits intoCap-go:mainfrom
Conversation
Adds a new `hideNavigationBar` option that hides the Android system
navigation bar in the WebView dialog using sticky immersive mode
(BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE).
When apps use immersive mode in their main activity to hide the
system nav bar, the WebViewDialog (which runs in a separate window)
doesn't inherit this setting, causing the nav bar to reappear and
overlap the bottom of the WebView content.
Usage:
InAppBrowser.openWebView({
url: 'https://example.com',
hideNavigationBar: true,
})
The nav bar can still be accessed via edge swipe — it appears
temporarily as a translucent overlay, then auto-hides.
Changes:
- Options.java: add hideNavigationBar field with getter/setter
- InAppBrowserPlugin.java: parse hideNavigationBar from plugin call
- WebViewDialog.java: apply immersive mode in presentWebView()
- definitions.ts: add hideNavigationBar to OpenWebViewOptions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java`:
- Around line 376-384: Extract the immersive-mode block (the
WindowInsetsControllerCompat behavior and
hide(WindowInsetsCompat.Type.navigationBars())) currently in presentWebView()
into a new private helper method (e.g., applyImmersiveModeIfNeeded()) that
checks _options != null and _options.getHideNavigationBar(), then call that
helper from presentWebView() and also invoke it from show(),
restoreVisibleMode(), and wherever the dialog transitions from hidden to visible
(the setHidden(false) path) so immersive mode is reapplied whenever the dialog
becomes visible.
In `@src/definitions.ts`:
- Around line 613-623: The JSDoc for the hideNavigationBar property should
explicitly mark it as Android-only so generated docs don't imply iOS support;
update the comment above the hideNavigationBar?: boolean declaration to include
the same Android-only platform note used by other Android-only fields (e.g., add
a short sentence like "Android-only: ..." or the existing "@platform android"
tag style you use elsewhere) so the API docs clearly indicate this option
applies only to Android.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1bed11c8-72bc-43c9-a740-f38e3c731b84
📒 Files selected for processing (5)
README.mdandroid/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.javaandroid/src/main/java/ee/forgr/capacitor_inappbrowser/Options.javaandroid/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.javasrc/definitions.ts
| // Hide the Android system navigation bar if the option is enabled. | ||
| // Uses sticky immersive mode: the bar reappears on edge swipe, | ||
| // then auto-hides again after a short delay. | ||
| if (_options != null && _options.getHideNavigationBar()) { | ||
| insetsController.setSystemBarsBehavior( | ||
| WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE | ||
| ); | ||
| insetsController.hide(WindowInsetsCompat.Type.navigationBars()); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n=== immersive-mode application ===\n'
rg -n -C2 'getHideNavigationBar\(|BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE|hide\(WindowInsetsCompat\.Type\.navigationBars\(\)\)' \
android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java
printf '\n=== later visibility paths ===\n'
rg -n -C2 '\bshow\(\)|restoreVisibleMode\(|setHidden\(false\)' \
android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java \
android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.javaRepository: Cap-go/capacitor-inappbrowser
Length of output: 12145
Reapply immersive mode settings when the dialog becomes visible.
The hideNavigationBar option is only enforced during initial presentWebView() setup (lines 379–384). Dialogs opened with hidden: true or shown again after hide() do not reapply these settings, causing the navigation bar to appear visible even though the option is enabled.
Extract the immersive-mode logic into a helper method and invoke it from all visibility restoration paths (show(), restoreVisibleMode(), and setHidden(false) transitions).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java`
around lines 376 - 384, Extract the immersive-mode block (the
WindowInsetsControllerCompat behavior and
hide(WindowInsetsCompat.Type.navigationBars())) currently in presentWebView()
into a new private helper method (e.g., applyImmersiveModeIfNeeded()) that
checks _options != null and _options.getHideNavigationBar(), then call that
helper from presentWebView() and also invoke it from show(),
restoreVisibleMode(), and wherever the dialog transitions from hidden to visible
(the setHidden(false) path) so immersive mode is reapplied whenever the dialog
becomes visible.
| /** | ||
| * If true, hides the Android system navigation bar using sticky immersive mode. | ||
| * The navigation bar reappears temporarily when the user swipes from the bottom edge, | ||
| * then auto-hides again. Useful for apps that use immersive mode in their main activity | ||
| * and want the WebView dialog to match. | ||
| * @since 8.2.1 | ||
| * @default false | ||
| * @example | ||
| * hideNavigationBar: true | ||
| */ | ||
| hideNavigationBar?: boolean; |
There was a problem hiding this comment.
Call out that this option is Android-only in the generated docs.
Right now this reads like a general openWebView() option even though the implementation is Android-specific. Please add the same explicit platform note used by the other Android-only fields so the generated API docs don't imply iOS support.
Suggested doc tweak
/**
* If true, hides the Android system navigation bar using sticky immersive mode.
* The navigation bar reappears temporarily when the user swipes from the bottom edge,
* then auto-hides again. Useful for apps that use immersive mode in their main activity
* and want the WebView dialog to match.
+ * **Android only** — ignored on iOS.
* `@since` 8.2.1
* `@default` false
* `@example`
* hideNavigationBar: true
*/As per coding guidelines, src/definitions.ts is the source of truth for TypeScript interfaces and types that auto-generate API documentation.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** | |
| * If true, hides the Android system navigation bar using sticky immersive mode. | |
| * The navigation bar reappears temporarily when the user swipes from the bottom edge, | |
| * then auto-hides again. Useful for apps that use immersive mode in their main activity | |
| * and want the WebView dialog to match. | |
| * @since 8.2.1 | |
| * @default false | |
| * @example | |
| * hideNavigationBar: true | |
| */ | |
| hideNavigationBar?: boolean; | |
| /** | |
| * If true, hides the Android system navigation bar using sticky immersive mode. | |
| * The navigation bar reappears temporarily when the user swipes from the bottom edge, | |
| * then auto-hides again. Useful for apps that use immersive mode in their main activity | |
| * and want the WebView dialog to match. | |
| * **Android only** — ignored on iOS. | |
| * `@since` 8.2.1 | |
| * `@default` false | |
| * `@example` | |
| * hideNavigationBar: true | |
| */ | |
| hideNavigationBar?: boolean; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/definitions.ts` around lines 613 - 623, The JSDoc for the
hideNavigationBar property should explicitly mark it as Android-only so
generated docs don't imply iOS support; update the comment above the
hideNavigationBar?: boolean declaration to include the same Android-only
platform note used by other Android-only fields (e.g., add a short sentence like
"Android-only: ..." or the existing "@platform android" tag style you use
elsewhere) so the API docs clearly indicate this option applies only to Android.
|
@dalmasonto please check AI comments and resolve them then I can merge |



Summary
hideNavigationBarboolean option toopenWebView()that hides the Android system navigation bar using sticky immersive modeWindowInsetsControllerCompatwithBEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPEto hide the system navigation barMotivation
Apps that use immersive mode in their main
Activity(hiding the system navigation bar) currently see it reappear when the InAppBrowserWebViewDialogopens, since the dialog runs in a separate window that doesn't inherit the activity's insets configuration. This creates a jarring UX where the nav bar flickers in and out.This new option allows apps to opt-in to the same immersive behavior inside the WebView dialog, so the experience is consistent throughout the app.
Changes
src/definitions.tshideNavigationBar?: booleantoOpenWebViewOptionswith JSDocandroid/.../Options.javahideNavigationBarfield with getter/setter (default:false)android/.../InAppBrowserPlugin.javahideNavigationBarfrom plugin call optionsandroid/.../WebViewDialog.javapresentWebView()when option is enabledREADME.mdUsage
Test plan
hideNavigationBar: true— system nav bar hides correctlyhideNavigationBar: falseor omitted) is unchanged🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
hideNavigationBaroption to the in-app browser configuration. When enabled, hides the Android system navigation bar using immersive mode (defaults to disabled).Documentation