The Wayback Machine - https://web.archive.org/web/20221216163928/https://github.com/flutter/plugins/pull/6740
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webview_flutter] Added missing settings when developing initial AndroidWebViewController #6740

Open
wants to merge 3 commits into
base: v4_webview
Choose a base branch
from

Conversation

mvanbeusekom
Copy link
Contributor

@mvanbeusekom mvanbeusekom commented Nov 22, 2022

Added the following setters which I missed during initial development:

  • setBuiltInZoomControls
  • setDisplayZoomControls
  • setJavaScriptCanOpenWindowsAutomatically
  • setLoadWithOverviewMode
  • setSupportMultipleWindows
  • setUseWideViewPort

Part of issue flutter/flutter#94051

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@github-actions github-actions bot added p: webview_flutter Edits files for a webview_flutter plugin platform-android labels Nov 22, 2022
Copy link
Contributor

@bparrishMines bparrishMines left a comment

I don't think we should expose support for the following methods yet.

setBuiltInZoomControls
setDisplayZoomControls
setJavaScriptCanOpenWindowsAutomatically
setLoadWithOverviewMode
setSupportMultipleWindows
setUseWideViewPort

All of these are called on the WebView in the constructor because they are required to display the WebView correctly as a PlatformView.

These should just be set in the constructor to the same values we have in the current implementation:

https://github.com/flutter/plugins/blob/main/packages/webview_flutter/webview_flutter_android/lib/webview_android_widget.dart#L119

@override
Future<void> setUserAgent(String? userAgent) =>
_webView.settings.setUserAgentString(userAgent);

/// Sets the restrictions that apply on automatic media playback.
Future<void> setAutoMediaPlaybackPolicy(
Copy link
Contributor

@bparrishMines bparrishMines Nov 23, 2022

Choose a reason for hiding this comment

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

Since this is Android only, I think this would be better as setMediaPlaybackRequiresUserGesture(bool). The enum was used before because iOS could set the specific media that requires gestures.

Copy link
Contributor Author

@mvanbeusekom mvanbeusekom Nov 23, 2022

Choose a reason for hiding this comment

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

Updated the method callback to match the Android specific name.

@mvanbeusekom mvanbeusekom requested a review from bparrishMines Nov 23, 2022
@mvanbeusekom
Copy link
Contributor Author

mvanbeusekom commented Nov 23, 2022

I don't think we should expose support for the following methods yet.

setBuiltInZoomControls
setDisplayZoomControls
setJavaScriptCanOpenWindowsAutomatically
setLoadWithOverviewMode
setSupportMultipleWindows
setUseWideViewPort

All of these are called on the WebView in the constructor because they are required to display the WebView correctly as a PlatformView.

These should just be set in the constructor to the same values we have in the current implementation:

https://github.com/flutter/plugins/blob/main/packages/webview_flutter/webview_flutter_android/lib/webview_android_widget.dart#L119

Updated the AndroidWebViewController to initialise the android_view.webView with default settings in it's constructor. Removed the separate setters.

/// default value is true for apps targeting Build.VERSION_CODES.Q and below,
/// and false when targeting Build.VERSION_CODES.R and above.
Future<void> enableFileAccess(bool enabled) =>
_webView.settings.setAllowFileAccess(enabled);
Copy link
Contributor

@bparrishMines bparrishMines Nov 23, 2022

Choose a reason for hiding this comment

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

Ah, I forgot about this one. This is already called in the loadFile method. enableFileAccess can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: webview_flutter Edits files for a webview_flutter plugin platform-android
2 participants