Skip to content

feat(android): add opt-in hideNavigationBar option for immersive mode#468

Open
dalmasonto wants to merge 2 commits intoCap-go:mainfrom
dalmasonto:fix/hide-navigation-bar-immersive-mode
Open

feat(android): add opt-in hideNavigationBar option for immersive mode#468
dalmasonto wants to merge 2 commits intoCap-go:mainfrom
dalmasonto:fix/hide-navigation-bar-immersive-mode

Conversation

@dalmasonto
Copy link

@dalmasonto dalmasonto commented Mar 9, 2026

Summary

  • Adds a new hideNavigationBar boolean option to openWebView() that hides the Android system navigation bar using sticky immersive mode
  • When enabled, the WebView dialog uses WindowInsetsControllerCompat with BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE to hide the system navigation bar
  • The navigation bar temporarily reappears when the user swipes from the bottom edge, then auto-hides again after a short delay

Motivation

Apps that use immersive mode in their main Activity (hiding the system navigation bar) currently see it reappear when the InAppBrowser WebViewDialog opens, 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

File Change
src/definitions.ts Added hideNavigationBar?: boolean to OpenWebViewOptions with JSDoc
android/.../Options.java Added hideNavigationBar field with getter/setter (default: false)
android/.../InAppBrowserPlugin.java Parse hideNavigationBar from plugin call options
android/.../WebViewDialog.java Conditionally apply immersive mode in presentWebView() when option is enabled
README.md Documented the new option in the options table

Usage

await InAppBrowser.openWebView({
  url: 'https://example.com',
  hideNavigationBar: true, // opt-in to immersive mode
});

Test plan

  • Tested on Android device with hideNavigationBar: true — system nav bar hides correctly
  • Verified swipe-from-bottom temporarily shows nav bar, then auto-hides
  • Verified default behavior (hideNavigationBar: false or omitted) is unchanged
  • Verified no impact on iOS (option is Android-only)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added hideNavigationBar option to the in-app browser configuration. When enabled, hides the Android system navigation bar using immersive mode (defaults to disabled).
  • Documentation

    • Updated documentation with comprehensive details on the new navigation bar hiding option, including usage examples and default behavior.

dalmasonto and others added 2 commits March 9, 2026 23:43
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>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new hideNavigationBar option to the capacitor-inappbrowser plugin, enabling developers to hide the Android system navigation bar using immersive mode. The option is added across TypeScript definitions, Java configuration classes, plugin wiring, and WebViewDialog implementation.

Changes

Cohort / File(s) Summary
Documentation
README.md
Added two documentation entries describing the new hideNavigationBar boolean option with default false and immersive mode behavior details.
TypeScript Definitions
src/definitions.ts
Added optional hideNavigationBar?: boolean property to OpenWebViewOptions interface with JSDoc describing the Android navigation bar hiding feature.
Java Configuration
android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java
Introduced new private boolean field hideNavigationBar with public getter getHideNavigationBar() and setter setHideNavigationBar(boolean).
Plugin Integration
android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java
Added call to read hideNavigationBar option from plugin invocation and forward it to Options via setHideNavigationBar(boolean) method.
WebView Implementation
android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java
Implemented navigation bar hiding logic using WindowInsetsControllerCompat to configure transient system bars on swipe and hide navigation bars when option is enabled.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • riderx

Poem

🐰 A bar hides away, in immersive delight,
The navigation takes flight from the sight!
With a swipe, it returns, by the coder's design,
Hide and seek with the UI—oh, how it does shine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new optional hideNavigationBar feature for Android immersive mode in the InAppBrowser.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 38dcdd3 and f15f6c7.

📒 Files selected for processing (5)
  • README.md
  • android/src/main/java/ee/forgr/capacitor_inappbrowser/InAppBrowserPlugin.java
  • android/src/main/java/ee/forgr/capacitor_inappbrowser/Options.java
  • android/src/main/java/ee/forgr/capacitor_inappbrowser/WebViewDialog.java
  • src/definitions.ts

Comment on lines +376 to +384
// 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());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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.java

Repository: 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.

Comment on lines +613 to +623
/**
* 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
/**
* 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.

@riderx
Copy link
Member

riderx commented Mar 17, 2026

@dalmasonto please check AI comments and resolve them then I can merge

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