Skip to content

[url_launcher_android] Fix WebView content obscured by navigation bar on Android 15+#11750

Open
Ann3388p wants to merge 4 commits into
flutter:mainfrom
Ann3388p:fix/url-launcher-android-edge-to-edge-clean
Open

[url_launcher_android] Fix WebView content obscured by navigation bar on Android 15+#11750
Ann3388p wants to merge 4 commits into
flutter:mainfrom
Ann3388p:fix/url-launcher-android-edge-to-edge-clean

Conversation

@Ann3388p
Copy link
Copy Markdown

@Ann3388p Ann3388p commented May 21, 2026

Fixes flutter/flutter#170333

Problem

On Android 15+ devices with button navigation bar, WebView content
launched via LaunchMode.inAppWebView is obscured by the system
navigation bar. Interactive elements like cookie banners are not tappable.

Fix

Added ViewCompat.setOnApplyWindowInsetsListener to WebViewActivity
to apply proper padding based on system window insets, ensuring WebView
content respects the navigation bar area.

Testing

Tested on Android 15 emulator with button navigation enabled.

"Note: The existing unit tests fail to compile due to a pre-existing Robolectric 4.16 compatibility issue unrelated to this change. This can be verified by running tests on the unmodified main branch."

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the url_launcher_android package to version 6.3.31, implementing a WindowInsetsListener in WebViewActivity to prevent content from being obscured by the system navigation bar on Android 15+. It also adds a Robolectric unit test to verify WebView initialization. Review feedback identifies several Java style guide violations, including out-of-order imports, inconsistent 2-space indentation in both source and test files, and a missing trailing newline.

Comment on lines +27 to +29
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.graphics.Insets;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

These imports are out of order. According to the Google Java Style Guide, imports should be grouped by package and sorted alphabetically. These androidx imports should be placed with the other androidx imports (around line 23).

References
  1. Code should follow the relevant style guides for each language (Google Java Style for Java). (link)

Comment on lines +96 to +107
ViewCompat.setOnApplyWindowInsetsListener(webview, (v, insets) -> {
Insets systemBars = insets.getInsets(
WindowInsetsCompat.Type.systemBars()
);
v.setPadding(
systemBars.left,
systemBars.top,
systemBars.right,
systemBars.bottom
);
return insets;
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The indentation of this block is incorrect and does not match the 2-space indentation used in the rest of the file. The closing brace is also misaligned.

    ViewCompat.setOnApplyWindowInsetsListener(
        webview,
        (v, insets) -> {
          Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
          v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
          return insets;
        });
References
  1. Code should follow the relevant style guides for each language (Google Java Style for Java). (link)

Comment on lines +28 to +37
Robolectric.buildActivity(
WebViewActivity.class,
WebViewActivity.createIntent(
ApplicationProvider.getApplicationContext(),
"https://flutter.dev",
false,
false,
new Bundle()))
.create()
.get();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The indentation of the Robolectric.buildActivity call is inconsistent with the 2-space indentation used in the project.

    WebViewActivity activity =
        Robolectric.buildActivity(
            WebViewActivity.class,
            WebViewActivity.createIntent(
                ApplicationProvider.getApplicationContext(),
                "https://flutter.dev",
                false,
                false,
                new Bundle()))
            .create()
            .get();
References
  1. Code should follow the relevant style guides for each language (Google Java Style for Java). (link)


assertNotNull(activity.webview);
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The file is missing a newline character at the end.

Suggested change
}
}
References
  1. Code should follow the relevant style guides for each language (Google Java Style for Java). (link)

@Ann3388p Ann3388p force-pushed the fix/url-launcher-android-edge-to-edge-clean branch from 2ee55c7 to 9819bac Compare May 21, 2026 06:37
@reidbaker reidbaker requested a review from bparrishMines May 21, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[url_launcher] Edge to Edge issue on android 15+ with _launchUrl(url, mode: LaunchMode.inAppWebView)

1 participant