Skip to content

Commit 45db49e

Browse files
authored
Merge branch 'master' into mschneider/fullscreen_video
2 parents 4ecc3b0 + 1d03c58 commit 45db49e

File tree

8 files changed

+50
-16
lines changed

8 files changed

+50
-16
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Plugin that allows Flutter to communicate with a native WebView.
1010
The webview is not integrated in the widget tree, it is a native view on top of the flutter view.
1111
You won't be able see snackbars, dialogs, or other flutter widgets that would overlap with the region of the screen taken up by the webview.
1212

13+
The getSafeAcceptedType() function is available only for minimum SDK of 21.
14+
eval() function only supports SDK of 19 or greater for evaluating Javascript.
15+
1316
## Getting Started
1417

1518
For help getting started with Flutter, view our online [documentation](http://flutter.io/).
@@ -190,6 +193,9 @@ Future<Null> launch(String url, {
190193
bool supportMultipleWindows: false,
191194
bool appCacheEnabled: false,
192195
bool allowFileURLs: false,
196+
bool displayZoomControls: false,
197+
bool useWideViewPort: false,
198+
bool withOverviewMode: false,
193199
});
194200
```
195201

android/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools"
33
package="com.flutter_webview_plugin">
4+
<uses-sdk android:minSdkVersion="16" />
45
<application>
56
<provider
67
android:name="androidx.core.content.FileProvider"
78
android:authorities="${applicationId}.fileprovider"
89
android:exported="false"
9-
android:grantUriPermissions="true"
10+
android:grantUriPermissions="true"
1011
tools:replace="android:authorities">
1112
<meta-data
1213
android:name="android.support.FILE_PROVIDER_PATHS"

android/src/main/java/com/flutter_webview_plugin/BrowserClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
104104
super.onReceivedError(view, errorCode, description, failingUrl);
105105
Map<String, Object> data = new HashMap<>();
106106
data.put("url", failingUrl);
107-
data.put("code", errorCode);
107+
data.put("code", Integer.toString(errorCode));
108108
FlutterWebviewPlugin.channel.invokeMethod("onHttpError", data);
109109
}
110110

android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
9393
boolean clearCache = call.argument("clearCache");
9494
boolean clearCookies = call.argument("clearCookies");
9595
boolean withZoom = call.argument("withZoom");
96+
boolean displayZoomControls = call.argument("displayZoomControls");
9697
boolean withLocalStorage = call.argument("withLocalStorage");
98+
boolean withOverviewMode = call.argument("withOverviewMode");
9799
boolean supportMultipleWindows = call.argument("supportMultipleWindows");
98100
boolean appCacheEnabled = call.argument("appCacheEnabled");
99101
Map<String, String> headers = call.argument("headers");
@@ -120,7 +122,9 @@ private void openUrl(MethodCall call, MethodChannel.Result result) {
120122
url,
121123
headers,
122124
withZoom,
125+
displayZoomControls,
123126
withLocalStorage,
127+
withOverviewMode,
124128
scrollBar,
125129
supportMultipleWindows,
126130
appCacheEnabled,

android/src/main/java/com/flutter_webview_plugin/WebviewManager.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ public void onHideCustomView() {
292292
customViewCallback.onCustomViewHidden();
293293
customView = null;
294294
}
295+
296+
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
297+
callback.invoke(origin, true, false);
298+
299+
}
300+
295301
});
296302
}
297303

@@ -388,7 +394,9 @@ void openUrl(
388394
String url,
389395
Map<String, String> headers,
390396
boolean withZoom,
397+
boolean displayZoomControls,
391398
boolean withLocalStorage,
399+
boolean withOverviewMode,
392400
boolean scrollBar,
393401
boolean supportMultipleWindows,
394402
boolean appCacheEnabled,
@@ -401,7 +409,9 @@ void openUrl(
401409
webView.getSettings().setJavaScriptEnabled(withJavascript);
402410
webView.getSettings().setBuiltInZoomControls(withZoom);
403411
webView.getSettings().setSupportZoom(withZoom);
412+
webView.getSettings().setDisplayZoomControls(displayZoomControls);
404413
webView.getSettings().setDomStorageEnabled(withLocalStorage);
414+
webView.getSettings().setLoadWithOverviewMode(withOverviewMode);
405415
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(supportMultipleWindows);
406416

407417
webView.getSettings().setSupportMultipleWindows(supportMultipleWindows);
@@ -420,12 +430,6 @@ void openUrl(
420430

421431
if (geolocationEnabled) {
422432
webView.getSettings().setGeolocationEnabled(true);
423-
webView.setWebChromeClient(new WebChromeClient() {
424-
@Override
425-
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
426-
callback.invoke(origin, true, false);
427-
}
428-
});
429433
}
430434

431435
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
1110
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1211
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1312
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1413
945777F11EF64758001C8557 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 945777F01EF64758001C8557 /* GeneratedPluginRegistrant.m */; };
1514
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
16-
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1715
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
1816
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; };
1917
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
@@ -32,15 +30,14 @@
3230
dstSubfolderSpec = 10;
3331
files = (
3432
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
35-
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
3633
);
3734
name = "Embed Frameworks";
3835
runOnlyForDeploymentPostprocessing = 0;
3936
};
4037
/* End PBXCopyFilesBuildPhase section */
4138

4239
/* Begin PBXFileReference section */
43-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
40+
04A45F9D7EB8F4F508843D7B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
4441
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4542
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4643
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -58,6 +55,7 @@
5855
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5956
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6057
9A3CDD044DB4E60255722586 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
58+
DB142FA5095D20B047B504E1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
6159
/* End PBXFileReference section */
6260

6361
/* Begin PBXFrameworksBuildPhase section */
@@ -77,6 +75,8 @@
7775
840012C8B5EDBCF56B0E4AC1 /* Pods */ = {
7876
isa = PBXGroup;
7977
children = (
78+
DB142FA5095D20B047B504E1 /* Pods-Runner.debug.xcconfig */,
79+
04A45F9D7EB8F4F508843D7B /* Pods-Runner.release.xcconfig */,
8080
);
8181
name = Pods;
8282
sourceTree = "<group>";
@@ -86,7 +86,6 @@
8686
children = (
8787
3B80C3931E831B6300D905FE /* App.framework */,
8888
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
89-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
9089
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9190
9740EEB21CF90195004384FC /* Debug.xcconfig */,
9291
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
@@ -182,6 +181,7 @@
182181
TargetAttributes = {
183182
97C146ED1CF9000F007C117D = {
184183
CreatedOnToolsVersion = 7.3.1;
184+
DevelopmentTeam = 2RC73M8QLE;
185185
};
186186
};
187187
};
@@ -190,6 +190,7 @@
190190
developmentRegion = English;
191191
hasScannedForEncodings = 0;
192192
knownRegions = (
193+
English,
193194
en,
194195
Base,
195196
);
@@ -211,7 +212,6 @@
211212
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
212213
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */,
213214
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
214-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
215215
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
216216
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
217217
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
@@ -241,7 +241,7 @@
241241
files = (
242242
);
243243
inputPaths = (
244-
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
244+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
245245
"${PODS_ROOT}/../../../../../flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
246246
"${BUILT_PRODUCTS_DIR}/flutter_webview_plugin/flutter_webview_plugin.framework",
247247
);
@@ -252,7 +252,7 @@
252252
);
253253
runOnlyForDeploymentPostprocessing = 0;
254254
shellPath = /bin/sh;
255-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
255+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
256256
showEnvVarsInLog = 0;
257257
};
258258
9740EEB61CF901F6004384FC /* Run Script */ = {
@@ -418,6 +418,7 @@
418418
buildSettings = {
419419
ARCHS = arm64;
420420
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
421+
DEVELOPMENT_TEAM = 2RC73M8QLE;
421422
ENABLE_BITCODE = NO;
422423
FRAMEWORK_SEARCH_PATHS = (
423424
"$(inherited)",
@@ -440,6 +441,7 @@
440441
buildSettings = {
441442
ARCHS = arm64;
442443
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444+
DEVELOPMENT_TEAM = 2RC73M8QLE;
443445
ENABLE_BITCODE = NO;
444446
FRAMEWORK_SEARCH_PATHS = (
445447
"$(inherited)",

lib/src/base.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ class FlutterWebviewPlugin {
111111
/// - [invalidUrlRegex] is the regular expression of URLs that web view shouldn't load.
112112
/// For example, when webview is redirected to a specific URL, you want to intercept
113113
/// this process by stopping loading this URL and replacing webview by another screen.
114+
/// Android only settings:
115+
/// - [displayZoomControls]: display zoom controls on webview
116+
/// - [withOverviewMode]: enable overview mode for Android webview ( setLoadWithOverviewMode )
117+
/// - [useWideViewPort]: use wide viewport for Android webview ( setUseWideViewPort )
114118
Future<Null> launch(String url, {
115119
Map<String, String> headers,
116120
bool withJavascript,
@@ -121,8 +125,10 @@ class FlutterWebviewPlugin {
121125
Rect rect,
122126
String userAgent,
123127
bool withZoom,
128+
bool displayZoomControls,
124129
bool withLocalStorage,
125130
bool withLocalUrl,
131+
bool withOverviewMode,
126132
bool scrollBar,
127133
bool supportMultipleWindows,
128134
bool appCacheEnabled,
@@ -141,6 +147,7 @@ class FlutterWebviewPlugin {
141147
'enableAppScheme': enableAppScheme ?? true,
142148
'userAgent': userAgent,
143149
'withZoom': withZoom ?? false,
150+
'displayZoomControls': displayZoomControls ?? false,
144151
'withLocalStorage': withLocalStorage ?? true,
145152
'withLocalUrl': withLocalUrl ?? false,
146153
'scrollBar': scrollBar ?? true,
@@ -150,6 +157,7 @@ class FlutterWebviewPlugin {
150157
'useWideViewPort': useWideViewPort ?? false,
151158
'invalidUrlRegex': invalidUrlRegex,
152159
'geolocationEnabled': geolocationEnabled ?? false,
160+
'withOverviewMode': withOverviewMode ?? false,
153161
'debuggingEnabled': debuggingEnabled ?? false,
154162
};
155163

lib/src/webview_scaffold.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class WebviewScaffold extends StatefulWidget {
2222
this.persistentFooterButtons,
2323
this.bottomNavigationBar,
2424
this.withZoom,
25+
this.displayZoomControls,
2526
this.withLocalStorage,
2627
this.withLocalUrl,
28+
this.withOverviewMode,
29+
this.useWideViewPort,
2730
this.scrollBar,
2831
this.supportMultipleWindows,
2932
this.appCacheEnabled,
@@ -48,6 +51,7 @@ class WebviewScaffold extends StatefulWidget {
4851
final List<Widget> persistentFooterButtons;
4952
final Widget bottomNavigationBar;
5053
final bool withZoom;
54+
final bool displayZoomControls;
5155
final bool withLocalStorage;
5256
final bool withLocalUrl;
5357
final bool scrollBar;
@@ -59,6 +63,8 @@ class WebviewScaffold extends StatefulWidget {
5963
final bool resizeToAvoidBottomInset;
6064
final String invalidUrlRegex;
6165
final bool geolocationEnabled;
66+
final bool withOverviewMode;
67+
final bool useWideViewPort;
6268
final bool debuggingEnabled;
6369

6470
@override
@@ -148,8 +154,11 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
148154
userAgent: widget.userAgent,
149155
rect: _rect,
150156
withZoom: widget.withZoom,
157+
displayZoomControls: widget.displayZoomControls,
151158
withLocalStorage: widget.withLocalStorage,
152159
withLocalUrl: widget.withLocalUrl,
160+
withOverviewMode: widget.withOverviewMode,
161+
useWideViewPort: widget.useWideViewPort,
153162
scrollBar: widget.scrollBar,
154163
supportMultipleWindows: widget.supportMultipleWindows,
155164
appCacheEnabled: widget.appCacheEnabled,

0 commit comments

Comments
 (0)