[url_launcher_android] Fix WebView content obscured by navigation bar on Android 15+#11750
[url_launcher_android] Fix WebView content obscured by navigation bar on Android 15+#11750Ann3388p wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
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.
| import androidx.core.view.ViewCompat; | ||
| import androidx.core.view.WindowInsetsCompat; | ||
| import androidx.core.graphics.Insets; |
There was a problem hiding this comment.
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
- Code should follow the relevant style guides for each language (Google Java Style for Java). (link)
| ViewCompat.setOnApplyWindowInsetsListener(webview, (v, insets) -> { | ||
| Insets systemBars = insets.getInsets( | ||
| WindowInsetsCompat.Type.systemBars() | ||
| ); | ||
| v.setPadding( | ||
| systemBars.left, | ||
| systemBars.top, | ||
| systemBars.right, | ||
| systemBars.bottom | ||
| ); | ||
| return insets; | ||
| }); |
There was a problem hiding this comment.
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
- Code should follow the relevant style guides for each language (Google Java Style for Java). (link)
| Robolectric.buildActivity( | ||
| WebViewActivity.class, | ||
| WebViewActivity.createIntent( | ||
| ApplicationProvider.getApplicationContext(), | ||
| "https://flutter.dev", | ||
| false, | ||
| false, | ||
| new Bundle())) | ||
| .create() | ||
| .get(); |
There was a problem hiding this comment.
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
- 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 |
There was a problem hiding this comment.
The file is missing a newline character at the end.
| } | |
| } | |
References
- Code should follow the relevant style guides for each language (Google Java Style for Java). (link)
2ee55c7 to
9819bac
Compare
Fixes flutter/flutter#170333
Problem
On Android 15+ devices with button navigation bar, WebView content
launched via
LaunchMode.inAppWebViewis obscured by the systemnavigation bar. Interactive elements like cookie banners are not tappable.
Fix
Added
ViewCompat.setOnApplyWindowInsetsListenertoWebViewActivityto 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
[shared_preferences]///).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-assistbot 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
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