From 710fc1e02156c76163217d2c5bf9a2e10f74e722 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 15 Apr 2022 23:18:54 +0200 Subject: [PATCH] Added singleInstance option for Android ChromeSafariBrowser implementation, updated android compileSdkVersion to 31 --- .fvm/flutter_sdk | 1 + .fvm/fvm_config.json | 4 +++ CHANGELOG.md | 5 +++ android/build.gradle | 2 +- android/src/main/AndroidManifest.xml | 4 +++ .../flutter_inappwebview/Util.java | 4 +++ ...hromeCustomTabsActivitySingleInstance.java | 7 ++++ .../ChromeSafariBrowserManager.java | 4 ++- example/.flutter-plugins-dependencies | 2 +- example/android/app/build.gradle | 4 +-- .../android/app/src/main/AndroidManifest.xml | 33 +++++++++---------- .../ios/Flutter/flutter_export_environment.sh | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 4 +-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../chrome_safari_browser_example.screen.dart | 1 + example/lib/in_app_webiew_example.screen.dart | 2 +- flutter_inappwebview.iml | 6 ++++ .../android/chrome_custom_tabs_options.dart | 10 ++++-- lib/src/types.dart | 8 +---- 19 files changed, 69 insertions(+), 36 deletions(-) create mode 120000 .fvm/flutter_sdk create mode 100644 .fvm/fvm_config.json create mode 100755 android/src/main/java/com/pichillilorenzo/flutter_inappwebview/chrome_custom_tabs/ChromeCustomTabsActivitySingleInstance.java diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk new file mode 120000 index 000000000..c6e3b15b3 --- /dev/null +++ b/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/lorenzopichilli/fvm/versions/2.10.4 \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 000000000..d2faf4977 --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "2.10.4", + "flavors": {} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c2d8c81ba..c49890d4f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ ## 5.3.3 - `getOriginalUrl` method is cross-platform now +- Updated Android `compileSdkVersion` to 31 +- Added `singleInstance` option for Android `ChromeSafariBrowser` implementation - Fixed `requestImageRef` method always `null` on iOS +- Fixed "applicationNameForUserAgent is not work in ios" [#525](https://github.com/pichillilorenzo/flutter_inappwebview/issues/525) +- Merge "Fix parsing crash on null value." [#828](https://github.com/pichillilorenzo/flutter_inappwebview/pull/828) (thanks to [ItsCalebJones](https://github.com/ItsCalebJones)) +- Merge "fix: ApplicationNameForUserAgent is not working in iOS" [#1095](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1095) (thanks to [sunalwaysknows](https://github.com/sunalwaysknows)) ## 5.3.2 diff --git a/android/build.gradle b/android/build.gradle index a5e831c42..443ec1477 100755 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,7 +22,7 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 30 + compileSdkVersion 31 defaultConfig { minSdkVersion 17 diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 40dc12679..c6ffe08eb 100755 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -9,6 +9,10 @@ + @@ -36,22 +35,22 @@ - - - - + + + + + + + + + + + + + + + + { InAppWebViewGroupOptions options = InAppWebViewGroupOptions( crossPlatform: InAppWebViewOptions( useShouldOverrideUrlLoading: true, - mediaPlaybackRequiresUserGesture: false, + mediaPlaybackRequiresUserGesture: false ), android: AndroidInAppWebViewOptions( useHybridComposition: true, diff --git a/flutter_inappwebview.iml b/flutter_inappwebview.iml index 0adae5aa8..4f3a5faa8 100755 --- a/flutter_inappwebview.iml +++ b/flutter_inappwebview.iml @@ -5,6 +5,12 @@ + + + + + + diff --git a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart index d6901bb8b..1fb973652 100755 --- a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart +++ b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart @@ -35,6 +35,9 @@ class AndroidChromeCustomTabsOptions ///Set to `true` to enable Keep Alive. The default value is `false`. bool keepAliveEnabled; + ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. + bool singleInstance; + AndroidChromeCustomTabsOptions( {this.addDefaultShareMenuItem = true, this.showTitle = true, @@ -42,7 +45,8 @@ class AndroidChromeCustomTabsOptions this.enableUrlBarHiding = false, this.instantAppsEnabled = false, this.packageName, - this.keepAliveEnabled = false}); + this.keepAliveEnabled = false, + this.singleInstance = false}); @override Map toMap() { @@ -53,7 +57,8 @@ class AndroidChromeCustomTabsOptions "enableUrlBarHiding": enableUrlBarHiding, "instantAppsEnabled": instantAppsEnabled, "packageName": packageName, - "keepAliveEnabled": keepAliveEnabled + "keepAliveEnabled": keepAliveEnabled, + "singleInstance": singleInstance }; } @@ -68,6 +73,7 @@ class AndroidChromeCustomTabsOptions options.instantAppsEnabled = map["instantAppsEnabled"]; options.packageName = map["packageName"]; options.keepAliveEnabled = map["keepAliveEnabled"]; + options.singleInstance = map["singleInstance"]; return options; } diff --git a/lib/src/types.dart b/lib/src/types.dart index 12ecc54df..96bf9d7ea 100755 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -6858,8 +6858,7 @@ class WebViewImplementation { const WebViewImplementation._internal(this._value); static final Set values = [ - WebViewImplementation.NATIVE, - WebViewImplementation.GECKO, + WebViewImplementation.NATIVE ].toSet(); static WebViewImplementation? fromValue(int? value) { @@ -6879,8 +6878,6 @@ class WebViewImplementation { @override String toString() { switch (_value) { - case 1: - return "GECKO"; case 0: default: return "NATIVE"; @@ -6890,9 +6887,6 @@ class WebViewImplementation { ///Default native implementation, such as `WKWebView` for iOS and `android.webkit.WebView` for Android. static const NATIVE = const WebViewImplementation._internal(0); - ///Android-only WebView implementation using the Mozilla's Gecko browser engine. - static const GECKO = const WebViewImplementation._internal(1); - bool operator ==(value) => value == _value; @override