Skip to content

Commit 7e8735b

Browse files
authored
Merge branch 'master' into master
2 parents bf76bac + 24abc82 commit 7e8735b

File tree

10 files changed

+67
-17
lines changed

10 files changed

+67
-17
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# 0.3.6
2+
3+
- Allow web contents debugging in Chrome
4+
- Android: allow geolocation and file chooser simultaneously
5+
- Add min sdk requirement and descriptions
6+
- fix bug android webview httperror exception
7+
- Exposes displayZoomControls, withOverviewMode and useWideViewPort settings for Android WebView
8+
9+
# 0.3.5
10+
11+
- Ability to choose from camera or gallery when using
12+
- Support for webview’s estimated loading progress #255
13+
- Fix back button handler to be compatible with the WillPopScope widget
14+
15+
# 0.3.4
16+
17+
- WebView always hidden on iOS
18+
119
# 0.3.3
220

321
- BREAKING CHANGE - AndroidX support

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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ public void onProgressChanged(WebView view, int progress) {
243243
args.put("progress", progress / 100.0);
244244
FlutterWebviewPlugin.channel.invokeMethod("onProgressChanged", args);
245245
}
246+
247+
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
248+
callback.invoke(origin, true, false);
249+
}
246250
});
247251
}
248252

@@ -339,7 +343,9 @@ void openUrl(
339343
String url,
340344
Map<String, String> headers,
341345
boolean withZoom,
346+
boolean displayZoomControls,
342347
boolean withLocalStorage,
348+
boolean withOverviewMode,
343349
boolean scrollBar,
344350
boolean supportMultipleWindows,
345351
boolean appCacheEnabled,
@@ -352,7 +358,9 @@ void openUrl(
352358
webView.getSettings().setJavaScriptEnabled(withJavascript);
353359
webView.getSettings().setBuiltInZoomControls(withZoom);
354360
webView.getSettings().setSupportZoom(withZoom);
361+
webView.getSettings().setDisplayZoomControls(displayZoomControls);
355362
webView.getSettings().setDomStorageEnabled(withLocalStorage);
363+
webView.getSettings().setLoadWithOverviewMode(withOverviewMode);
356364
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(supportMultipleWindows);
357365

358366
webView.getSettings().setSupportMultipleWindows(supportMultipleWindows);
@@ -371,12 +379,6 @@ void openUrl(
371379

372380
if (geolocationEnabled) {
373381
webView.getSettings().setGeolocationEnabled(true);
374-
webView.setWebChromeClient(new WebChromeClient() {
375-
@Override
376-
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
377-
callback.invoke(origin, true, false);
378-
}
379-
});
380382
}
381383

382384
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
@@ -115,6 +115,10 @@ class FlutterWebviewPlugin {
115115
/// - [invalidUrlRegex] is the regular expression of URLs that web view shouldn't load.
116116
/// For example, when webview is redirected to a specific URL, you want to intercept
117117
/// this process by stopping loading this URL and replacing webview by another screen.
118+
/// Android only settings:
119+
/// - [displayZoomControls]: display zoom controls on webview
120+
/// - [withOverviewMode]: enable overview mode for Android webview ( setLoadWithOverviewMode )
121+
/// - [useWideViewPort]: use wide viewport for Android webview ( setUseWideViewPort )
118122
Future<Null> launch(String url, {
119123
Map<String, String> headers,
120124
bool withJavascript,
@@ -125,9 +129,11 @@ class FlutterWebviewPlugin {
125129
Rect rect,
126130
String userAgent,
127131
bool withZoom,
132+
bool displayZoomControls,
128133
bool withLocalStorage,
129134
bool withLocalUrl,
130135
String localUrlScope,
136+
bool withOverviewMode,
131137
bool scrollBar,
132138
bool supportMultipleWindows,
133139
bool appCacheEnabled,
@@ -146,6 +152,7 @@ class FlutterWebviewPlugin {
146152
'enableAppScheme': enableAppScheme ?? true,
147153
'userAgent': userAgent,
148154
'withZoom': withZoom ?? false,
155+
'displayZoomControls': displayZoomControls ?? false,
149156
'withLocalStorage': withLocalStorage ?? true,
150157
'withLocalUrl': withLocalUrl ?? false,
151158
'localUrlScope': localUrlScope,
@@ -156,6 +163,7 @@ class FlutterWebviewPlugin {
156163
'useWideViewPort': useWideViewPort ?? false,
157164
'invalidUrlRegex': invalidUrlRegex,
158165
'geolocationEnabled': geolocationEnabled ?? false,
166+
'withOverviewMode': withOverviewMode ?? false,
159167
'debuggingEnabled': debuggingEnabled ?? false,
160168
};
161169

lib/src/webview_scaffold.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ class WebviewScaffold extends StatefulWidget {
2222
this.persistentFooterButtons,
2323
this.bottomNavigationBar,
2424
this.withZoom,
25+
this.displayZoomControls,
2526
this.withLocalStorage,
2627
this.withLocalUrl,
2728
this.localUrlScope,
29+
this.withOverviewMode,
30+
this.useWideViewPort,
2831
this.scrollBar,
2932
this.supportMultipleWindows,
3033
this.appCacheEnabled,
@@ -49,6 +52,7 @@ class WebviewScaffold extends StatefulWidget {
4952
final List<Widget> persistentFooterButtons;
5053
final Widget bottomNavigationBar;
5154
final bool withZoom;
55+
final bool displayZoomControls;
5256
final bool withLocalStorage;
5357
final bool withLocalUrl;
5458
final String localUrlScope;
@@ -61,6 +65,8 @@ class WebviewScaffold extends StatefulWidget {
6165
final bool resizeToAvoidBottomInset;
6266
final String invalidUrlRegex;
6367
final bool geolocationEnabled;
68+
final bool withOverviewMode;
69+
final bool useWideViewPort;
6470
final bool debuggingEnabled;
6571

6672
@override
@@ -150,9 +156,12 @@ class _WebviewScaffoldState extends State<WebviewScaffold> {
150156
userAgent: widget.userAgent,
151157
rect: _rect,
152158
withZoom: widget.withZoom,
159+
displayZoomControls: widget.displayZoomControls,
153160
withLocalStorage: widget.withLocalStorage,
154161
withLocalUrl: widget.withLocalUrl,
155162
localUrlScope: widget.localUrlScope,
163+
withOverviewMode: widget.withOverviewMode,
164+
useWideViewPort: widget.useWideViewPort,
156165
scrollBar: widget.scrollBar,
157166
supportMultipleWindows: widget.supportMultipleWindows,
158167
appCacheEnabled: widget.appCacheEnabled,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors:
77
- Simon Lightfoot <[email protected]>
88
- Rafal Wachol <[email protected]>
99
homepage: https://github.com/dart-flitter/flutter_webview_plugin
10-
version: 0.3.5
10+
version: 0.3.6
1111
maintainer: Simon Lightfoot (@slightfoot)
1212

1313
environment:

0 commit comments

Comments
 (0)