fixed android zoom, added new ios webview options, added
> onLongPressHitTestResult event, updated test cases, fixed Promise polyfill, fixed android options
This commit is contained in:
parent
7d9f9f56a4
commit
6a7963e4fd
|
@ -1,15 +1,16 @@
|
|||
## 3.0.0
|
||||
|
||||
- Added `Promise` javascript [polyfill](https://github.com/taylorhakes/promise-polyfill/blob/master/src/index.js) for webviews that doesn't support it for `window.flutter_inappwebview.callHandler`
|
||||
- Added `Promise` javascript [polyfill](https://github.com/tildeio/rsvp.js) for webviews that doesn't support it for `window.flutter_inappwebview.callHandler`
|
||||
- Added `getDefaultUserAgent` static method to `InAppWebViewController`
|
||||
- Added `onUpdateVisitedHistory`, `onPrint` event
|
||||
- Added `onGeolocationPermissionsHidePrompt` event for Android
|
||||
- Added `onUpdateVisitedHistory`, `onPrint`, `onLongPressHitTestResult` event
|
||||
- Added `androidOnGeolocationPermissionsHidePrompt` event for Android webview
|
||||
- Added `iosOnWebContentProcessDidTerminate`, `iosOnDidCommit`, `iosOnDidReceiveServerRedirectForProvisionalNavigation` events for iOS webview
|
||||
- Added `supportMultipleWindows` webview option for Android
|
||||
- Added `regexToCancelSubFramesLoading` webview option for Android to cancel subframe requests on `shouldOverrideUrlLoading` event based on a Regular Expression
|
||||
- Added `getContentHeight`, `zoomBy`, `printCurrentPage`, `getScale` methods
|
||||
- Added `getOriginalUrl` webview method for Android
|
||||
- Added `reloadFromOrigin` webview method for iOS
|
||||
- Added `automaticallyAdjustsScrollIndicatorInsets` webview options for iOS
|
||||
- Added `reloadFromOrigin`, `hasOnlySecureContent` webview methods for iOS
|
||||
- Added `automaticallyAdjustsScrollIndicatorInsets`, `accessibilityIgnoresInvertColors`, `decelerationRate`, `alwaysBounceVertical`, `alwaysBounceHorizontal`, `scrollsToTop`, `isPagingEnabled`, `maximumZoomScale`, `minimumZoomScale` webview options for iOS
|
||||
- Added `WebStorageManager` class which manages the web storage used by WebView instances
|
||||
- Added `packageName` [#229](https://github.com/pichillilorenzo/flutter_inappwebview/issues/229) and `keepAliveEnabled` ChromeCustomTab options for Android
|
||||
- Updated for Flutter 1.12 new Java Embedding API (Android)
|
||||
|
@ -17,10 +18,16 @@
|
|||
- Updated default value for `domStorageEnabled` and `databaseEnabled` options to `true` for Android
|
||||
- Merge "Fixes null error when calling getOptions for InAppBrowser class" [#214](https://github.com/pichillilorenzo/flutter_inappwebview/pull/214) (thanks to [panndoraBoo](https://github.com/panndoraBoo))
|
||||
- Merge "Fixes crash onConsoleMessage iOS forced unwrapping" [#228](https://github.com/pichillilorenzo/flutter_inappwebview/pull/228) (thanks to [tokonu](https://github.com/tokonu))
|
||||
- Merge "Fix HTTPCookie.secure" [#311](https://github.com/pichillilorenzo/flutter_inappwebview/pull/311) (thanks to [xtyxtyx](https://github.com/xtyxtyx))
|
||||
- Merge "Fix config options for Android release builds" [#295](https://github.com/pichillilorenzo/flutter_inappwebview/pull/295) (thanks to [wwwdata](https://github.com/wwwdata))
|
||||
- Merge "fix scrollbar on iOS always show if not disable scroll" [#256](https://github.com/pichillilorenzo/flutter_inappwebview/pull/256) (thanks to [phamnhuvu-dev](https://github.com/phamnhuvu-dev))
|
||||
- Merge "Fix crash on nil/invalid URL (iOS)" [#262](https://github.com/pichillilorenzo/flutter_inappwebview/pull/262) (thanks to [AlexVincent525](https://github.com/AlexVincent525))
|
||||
- Merge "Fix crash when `prompt` was called on Android Q." [#262](https://github.com/pichillilorenzo/flutter_inappwebview/pull/263) (thanks to [AlexVincent525](https://github.com/AlexVincent525))
|
||||
- Fix for Android and iOS `InAppBrowser` for some controller methods not exposed.
|
||||
- Fixed "App Crashes after clicking on dropdown (Using inappwebview)" [#182](https://github.com/pichillilorenzo/flutter_inappwebview/issues/182)
|
||||
- Fixed "webview can not be released when in ios" [#225](https://github.com/pichillilorenzo/flutter_inappwebview/issues/225). Now the iOS WebView is released from memory when it is disposed from Flutter.
|
||||
- Fixed "Setting of presentationStyle not working on iOS" [#213](https://github.com/pichillilorenzo/flutter_inappwebview/issues/213)
|
||||
- Fixed "Android zoom issues" [#270](https://github.com/pichillilorenzo/flutter_inappwebview/issues/270)
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ A Flutter plugin that allows you to add an inline webview or open an in-app brow
|
|||
|
||||
### Requirements
|
||||
|
||||
- Dart sdk: ">=2.0.0-dev.68.0 <3.0.0"
|
||||
- Flutter: ">=1.9.1+hotfix.5 <2.0.0"
|
||||
- Dart sdk: ">=2.7.0 <3.0.0"
|
||||
- Flutter: ">=1.12.13+hotfix.5"
|
||||
- Android: `minSdkVersion 17` and add support for `androidx` (see [AndroidX Migration](https://flutter.dev/docs/development/androidx-migration) to migrate an existing app)
|
||||
- iOS: `--ios-language swift`, Xcode version `>= 11`
|
||||
|
||||
|
@ -448,6 +448,15 @@ Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
|
|||
* `selectionGranularity`: The level of granularity with which the user can interactively select content in the web view.
|
||||
* `dataDetectorTypes`: Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value.
|
||||
* `sharedCookiesEnabled`: Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView.
|
||||
* `automaticallyAdjustsScrollIndicatorInsets`: Configures whether the scroll indicator insets are automatically adjusted by the system. The default value is `false`.
|
||||
* `accessibilityIgnoresInvertColors`: A Boolean value indicating whether the view ignores an accessibility request to invert its colors. The default value is `false`.
|
||||
* `decelerationRate`: A `IOSUIScrollViewDecelerationRate` value that determines the rate of deceleration after the user lifts their finger. The default value is `IOSUIScrollViewDecelerationRate.NORMAL`.
|
||||
* `alwaysBounceVertical`: A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content. The default value is `false`.
|
||||
* `alwaysBounceHorizontal`: A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view. The default value is `false`.
|
||||
* `scrollsToTop`: A Boolean value that controls whether the scroll-to-top gesture is enabled. The default value is `true`.
|
||||
* `isPagingEnabled`: A Boolean value that determines whether paging is enabled for the scroll view. The default value is `false`.
|
||||
* `maximumZoomScale`: A floating-point value that specifies the maximum scale factor that can be applied to the scroll view's content. The default value is `1.0`.
|
||||
* `minimumZoomScale`: A floating-point value that specifies the minimum scale factor that can be applied to the scroll view's content. The default value is `1.0`.
|
||||
|
||||
#### `InAppWebView` Events
|
||||
|
||||
|
@ -479,10 +488,14 @@ Event names that starts with `android` or `ios` are events platform-specific.
|
|||
* `onAjaxProgress`: Event fired as an `XMLHttpRequest` progress (to use this event, the `useShouldInterceptAjaxRequest` option must be `true`).
|
||||
* `shouldInterceptFetchRequest`: Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API) (to use this event, the `useShouldInterceptFetchRequest` option must be `true`).
|
||||
* `onPrint`: Event fired when `window.print()` is called from JavaScript side.
|
||||
* `onLongPressHitTestResult`: Event fired when an HTML element of the webview has been clicked and held.
|
||||
* `androidOnSafeBrowsingHit`: Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing (available only on Android).
|
||||
* `androidOnPermissionRequest`: Event fired when the webview is requesting permission to access the specified resources and the permission currently isn't granted or denied (available only on Android).
|
||||
* `androidOnGeolocationPermissionsShowPrompt`: Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin (available only on Android).
|
||||
* `androidOnGeolocationPermissionsHidePrompt`: Notify the host application that a request for Geolocation permissions, made with a previous call to `androidOnGeolocationPermissionsShowPrompt` has been canceled. (available only on Android).
|
||||
* `iosOnWebContentProcessDidTerminate`: Invoked when the web view's web content process is terminated (available only on iOS).
|
||||
* `iosOnDidCommit`: Called when the web view begins to receive web content (available only on iOS).
|
||||
* `iosOnDidReceiveServerRedirectForProvisionalNavigation`: Called when a web view receives a server redirect (available only on iOS).
|
||||
|
||||
### `InAppBrowser` class
|
||||
|
||||
|
@ -553,7 +566,12 @@ class MyInAppBrowser extends InAppBrowser {
|
|||
}
|
||||
}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(
|
||||
new MyApp(),
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
final MyInAppBrowser browser = new MyInAppBrowser();
|
||||
|
@ -707,7 +725,12 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
|
|||
}
|
||||
}
|
||||
|
||||
void main() => runApp(new MyApp());
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(
|
||||
new MyApp(),
|
||||
);
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
final ChromeSafariBrowser browser = new MyChromeSafariBrowser(new MyInAppBrowser());
|
||||
|
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ChromeCustomTabsActivity.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ChromeCustomTabsActivity.java
Normal file → Executable file
54
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ChromeCustomTabsOptions.java
Normal file → Executable file
54
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ChromeCustomTabsOptions.java
Normal file → Executable file
|
@ -2,7 +2,10 @@ package com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs;
|
|||
|
||||
import com.pichillilorenzo.flutter_inappwebview.Options;
|
||||
|
||||
public class ChromeCustomTabsOptions extends Options {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChromeCustomTabsOptions implements Options {
|
||||
|
||||
final static String LOG_TAG = "ChromeCustomTabsOptions";
|
||||
|
||||
|
@ -14,4 +17,53 @@ public class ChromeCustomTabsOptions extends Options {
|
|||
public String packageName;
|
||||
public Boolean keepAliveEnabled = false;
|
||||
|
||||
@Override
|
||||
public ChromeCustomTabsOptions parse(HashMap<String, Object> options) {
|
||||
for (Map.Entry<String, Object> pair : options.entrySet()) {
|
||||
String key = pair.getKey();
|
||||
Object value = pair.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case "addDefaultShareMenuItem":
|
||||
addDefaultShareMenuItem = (boolean) value;
|
||||
break;
|
||||
case "showTitle":
|
||||
showTitle = (boolean) value;
|
||||
break;
|
||||
case "toolbarBackgroundColor":
|
||||
toolbarBackgroundColor = (String) value;
|
||||
break;
|
||||
case "enableUrlBarHiding":
|
||||
enableUrlBarHiding = (boolean) value;
|
||||
break;
|
||||
case "instantAppsEnabled":
|
||||
instantAppsEnabled = (boolean) value;
|
||||
break;
|
||||
case "packageName":
|
||||
packageName = (String) value;
|
||||
break;
|
||||
case "keepAliveEnabled":
|
||||
keepAliveEnabled = (boolean) value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getHashMap() {
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("addDefaultShareMenuItem", addDefaultShareMenuItem);
|
||||
options.put("showTitle", showTitle);
|
||||
options.put("toolbarBackgroundColor", toolbarBackgroundColor);
|
||||
options.put("enableUrlBarHiding", enableUrlBarHiding);
|
||||
options.put("instantAppsEnabled", instantAppsEnabled);
|
||||
options.put("packageName", packageName);
|
||||
options.put("keepAliveEnabled", keepAliveEnabled);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/CustomTabActivityHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/CustomTabActivityHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/CustomTabsHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/CustomTabsHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/KeepAliveService.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/KeepAliveService.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ServiceConnection.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ServiceConnection.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ServiceConnectionCallback.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeCustomTabs/ServiceConnectionCallback.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeSafariBrowserManager.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ChromeSafariBrowserManager.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlocker.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlocker.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerAction.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerAction.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerActionType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerActionType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerTrigger.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerTrigger.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerTriggerResourceType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/ContentBlocker/ContentBlockerTriggerResourceType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/Credential.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/Credential.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialContract.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialContract.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDao.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDao.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDatabase.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDatabase.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDatabaseHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/CredentialDatabaseHelper.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpace.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpace.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpaceContract.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpaceContract.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpaceDao.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabase/ProtectionSpaceDao.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabaseHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/CredentialDatabaseHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/FlutterWebView.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/FlutterWebView.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/FlutterWebViewFactory.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/FlutterWebViewFactory.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserActivity.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserActivity.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserManager.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserManager.java
Normal file → Executable file
59
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserOptions.java
Normal file → Executable file
59
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppBrowserOptions.java
Normal file → Executable file
|
@ -1,6 +1,9 @@
|
|||
package com.pichillilorenzo.flutter_inappwebview;
|
||||
|
||||
public class InAppBrowserOptions extends Options {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InAppBrowserOptions implements Options {
|
||||
|
||||
public static final String LOG_TAG = "InAppBrowserOptions";
|
||||
|
||||
|
@ -13,4 +16,58 @@ public class InAppBrowserOptions extends Options {
|
|||
public Boolean hideTitleBar = false;
|
||||
public Boolean closeOnCannotGoBack = true;
|
||||
public Boolean progressBar = true;
|
||||
|
||||
@Override
|
||||
public InAppBrowserOptions parse(HashMap<String, Object> options) {
|
||||
for (Map.Entry<String, Object> pair : options.entrySet()) {
|
||||
String key = pair.getKey();
|
||||
Object value = pair.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (key) {
|
||||
case "hidden":
|
||||
hidden = (boolean) value;
|
||||
break;
|
||||
case "toolbarTop":
|
||||
toolbarTop = (boolean) value;
|
||||
break;
|
||||
case "toolbarTopBackgroundColor":
|
||||
toolbarTopBackgroundColor = (String) value;
|
||||
break;
|
||||
case "toolbarTopFixedTitle":
|
||||
toolbarTopFixedTitle = (String) value;
|
||||
break;
|
||||
case "hideUrlBar":
|
||||
hideUrlBar = (boolean) value;
|
||||
break;
|
||||
case "hideTitleBar":
|
||||
hideTitleBar = (boolean) value;
|
||||
break;
|
||||
case "closeOnCannotGoBack":
|
||||
closeOnCannotGoBack = (boolean) value;
|
||||
break;
|
||||
case "progressBar":
|
||||
progressBar = (boolean) value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getHashMap() {
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("hidden", hidden);
|
||||
options.put("toolbarTop", toolbarTop);
|
||||
options.put("toolbarTopBackgroundColor", toolbarTopBackgroundColor);
|
||||
options.put("toolbarTopFixedTitle", toolbarTopFixedTitle);
|
||||
options.put("hideUrlBar", hideUrlBar);
|
||||
options.put("hideTitleBar", hideTitleBar);
|
||||
options.put("closeOnCannotGoBack", closeOnCannotGoBack);
|
||||
options.put("progressBar", progressBar);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/DisplayListenerProxy.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/DisplayListenerProxy.java
Normal file → Executable file
125
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebView.java
Normal file → Executable file
125
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebView.java
Normal file → Executable file
|
@ -4,14 +4,20 @@ import android.content.Context;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.print.PrintAttributes;
|
||||
import android.print.PrintDocumentAdapter;
|
||||
import android.print.PrintManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.ValueCallback;
|
||||
|
@ -21,6 +27,10 @@ import android.webkit.WebSettings;
|
|||
import android.webkit.WebStorage;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
|
||||
import android.view.ActionMode;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.pichillilorenzo.flutter_inappwebview.ContentBlocker.ContentBlocker;
|
||||
import com.pichillilorenzo.flutter_inappwebview.ContentBlocker.ContentBlockerAction;
|
||||
|
@ -28,7 +38,6 @@ import com.pichillilorenzo.flutter_inappwebview.ContentBlocker.ContentBlockerHan
|
|||
import com.pichillilorenzo.flutter_inappwebview.ContentBlocker.ContentBlockerTrigger;
|
||||
import com.pichillilorenzo.flutter_inappwebview.FlutterWebView;
|
||||
import com.pichillilorenzo.flutter_inappwebview.InAppBrowserActivity;
|
||||
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
|
||||
import com.pichillilorenzo.flutter_inappwebview.JavaScriptBridgeInterface;
|
||||
import com.pichillilorenzo.flutter_inappwebview.Shared;
|
||||
import com.pichillilorenzo.flutter_inappwebview.Util;
|
||||
|
@ -115,7 +124,7 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
|
||||
static final String interceptAjaxRequestsJS = "(function(ajax) {" +
|
||||
" var send = ajax.prototype.send;" +
|
||||
" var openUrl = ajax.prototype.openUrl;" +
|
||||
" var open = ajax.prototype.open;" +
|
||||
" var setRequestHeader = ajax.prototype.setRequestHeader;" +
|
||||
" ajax.prototype._flutter_inappwebview_url = null;" +
|
||||
" ajax.prototype._flutter_inappwebview_method = null;" +
|
||||
|
@ -148,7 +157,7 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
" }" +
|
||||
" callback(null);" +
|
||||
" };" +
|
||||
" ajax.prototype.openUrl = function(method, url, isAsync, user, password) {" +
|
||||
" ajax.prototype.open = function(method, url, isAsync, user, password) {" +
|
||||
" isAsync = (isAsync != null) ? isAsync : true;" +
|
||||
" this._flutter_inappwebview_url = url;" +
|
||||
" this._flutter_inappwebview_method = method;" +
|
||||
|
@ -156,7 +165,7 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
" this._flutter_inappwebview_user = user;" +
|
||||
" this._flutter_inappwebview_password = password;" +
|
||||
" this._flutter_inappwebview_request_headers = {};" +
|
||||
" openUrl.call(this, method, url, isAsync, user, password);" +
|
||||
" open.call(this, method, url, isAsync, user, password);" +
|
||||
" };" +
|
||||
" ajax.prototype.setRequestHeader = function(header, value) {" +
|
||||
" this._flutter_inappwebview_request_headers[header] = value;" +
|
||||
|
@ -311,7 +320,7 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
" };" +
|
||||
" if ((self._flutter_inappwebview_method != result.method && result.method != null) || (self._flutter_inappwebview_url != result.url && result.url != null)) {" +
|
||||
" self.abort();" +
|
||||
" self.openUrl(result.method, result.url, result.isAsync, result.user, result.password);" +
|
||||
" self.open(result.method, result.url, result.isAsync, result.user, result.password);" +
|
||||
" return;" +
|
||||
" }" +
|
||||
" }" +
|
||||
|
@ -527,6 +536,7 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
this.channel = (this.inAppBrowserActivity != null) ? this.inAppBrowserActivity.channel : this.flutterWebView.channel;
|
||||
this.id = id;
|
||||
this.options = options;
|
||||
//Shared.activity.registerForContextMenu(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -643,16 +653,9 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
settings.setSansSerifFontFamily(options.sansSerifFontFamily);
|
||||
settings.setSerifFontFamily(options.serifFontFamily);
|
||||
settings.setStandardFontFamily(options.standardFontFamily);
|
||||
if (options.preferredContentMode != null) {
|
||||
switch (fromValue(options.preferredContentMode)) {
|
||||
case DESKTOP:
|
||||
if (options.preferredContentMode != null &&
|
||||
options.preferredContentMode == PreferredContentModeOptionType.DESKTOP.toValue()) {
|
||||
setDesktopMode(true);
|
||||
break;
|
||||
case MOBILE:
|
||||
case RECOMMENDED:
|
||||
setDesktopMode(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
settings.setSaveFormData(options.saveFormData);
|
||||
if (options.incognito)
|
||||
|
@ -688,18 +691,13 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
|
||||
setVerticalScrollBarEnabled(!options.disableVerticalScroll);
|
||||
setHorizontalScrollBarEnabled(!options.disableHorizontalScroll);
|
||||
|
||||
setOnTouchListener(new View.OnTouchListener() {
|
||||
float m_downX;
|
||||
float m_downY;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
if (event.getPointerCount() > 1) {
|
||||
//Multi touch detected
|
||||
return true;
|
||||
}
|
||||
|
||||
if (options.disableHorizontalScroll && options.disableVerticalScroll) {
|
||||
return (event.getAction() == MotionEvent.ACTION_MOVE);
|
||||
}
|
||||
|
@ -729,6 +727,31 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
setOnLongClickListener(new OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
HitTestResult hitTestResult = getHitTestResult();
|
||||
Map<String, Object> hitTestResultMap = new HashMap<>();
|
||||
hitTestResultMap.put("type", hitTestResult.getType());
|
||||
hitTestResultMap.put("extra", hitTestResult.getExtra());
|
||||
|
||||
Map<String, Object> obj = new HashMap<>();
|
||||
if (inAppBrowserActivity != null)
|
||||
obj.put("uuid", inAppBrowserActivity.uuid);
|
||||
obj.put("hitTestResult", hitTestResultMap);
|
||||
channel.invokeMethod("onLongPressHitTestResult", obj);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Point lastTouch;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
lastTouch = new Point((int) ev.getX(), (int) ev.getY()) ;
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
public void setIncognito(boolean enabled) {
|
||||
|
@ -1334,7 +1357,69 @@ final public class InAppWebView extends InputAwareWebView {
|
|||
public Float getUpdatedScale() {
|
||||
return scale;
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu) {
|
||||
Log.d(LOG_TAG, getHitTestResult().getType() + "");
|
||||
String extra = getHitTestResult().getExtra();
|
||||
//if (getHitTestResult().getType() == 7 || getHitTestResult().getType() == 5)
|
||||
if (extra != null)
|
||||
Log.d(LOG_TAG, extra);
|
||||
Log.d(LOG_TAG, "\n\nonCreateContextMenu\n\n");
|
||||
|
||||
for(int i = 0; i < menu.size(); i++) {
|
||||
Log.d(LOG_TAG, menu.getItem(i).toString());
|
||||
}
|
||||
}
|
||||
|
||||
private Integer mActionMode;
|
||||
private CustomActionModeCallback mActionModeCallback;
|
||||
|
||||
@Override
|
||||
public ActionMode startActionMode(ActionMode.Callback callback, int mode) {
|
||||
Log.d(LOG_TAG, "startActionMode");
|
||||
ViewParent parent = getParent();
|
||||
if (parent == null || mActionMode != null) {
|
||||
return null;
|
||||
}
|
||||
mActionModeCallback = new CustomActionModeCallback();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mActionMode = ActionMode.TYPE_FLOATING;
|
||||
//return Shared.activity.getWindow().getDecorView().startActionMode(mActionModeCallback, mActionMode);
|
||||
return parent.startActionModeForChild(this, mActionModeCallback, mActionMode);
|
||||
} else {
|
||||
return parent.startActionModeForChild(this, mActionModeCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private class CustomActionModeCallback implements ActionMode.Callback {
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
|
||||
menu.add("ciao");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
mode.finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called when the user exits the action mode
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
clearFocus();
|
||||
}
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewChromeClient.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewClient.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewClient.java
Normal file → Executable file
329
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions.java
Normal file → Executable file
329
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InAppWebViewOptions.java
Normal file → Executable file
|
@ -4,16 +4,18 @@ import android.os.Build;
|
|||
import android.util.Log;
|
||||
import android.webkit.WebSettings;
|
||||
|
||||
import com.pichillilorenzo.flutter_inappwebview.ChromeCustomTabs.ChromeCustomTabsOptions;
|
||||
import com.pichillilorenzo.flutter_inappwebview.Options;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.webkit.WebSettings.LayoutAlgorithm.NORMAL;
|
||||
|
||||
public class InAppWebViewOptions extends Options {
|
||||
public class InAppWebViewOptions implements Options {
|
||||
|
||||
public static final String LOG_TAG = "InAppWebViewOptions";
|
||||
|
||||
|
@ -85,47 +87,316 @@ public class InAppWebViewOptions extends Options {
|
|||
public String regexToCancelSubFramesLoading;
|
||||
|
||||
@Override
|
||||
public Object onParse(Map.Entry<String, Object> pair) {
|
||||
if (pair.getKey().equals("layoutAlgorithm")) {
|
||||
String value = (String) pair.getValue();
|
||||
if (value != null) {
|
||||
switch (value) {
|
||||
case "NORMAL":
|
||||
pair.setValue(NORMAL);
|
||||
return pair;
|
||||
case "TEXT_AUTOSIZING":
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
return pair.setValue(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING);
|
||||
} else {
|
||||
pair.setValue(NORMAL);
|
||||
public InAppWebViewOptions parse(HashMap<String, Object> options) {
|
||||
for (Map.Entry<String, Object> pair : options.entrySet()) {
|
||||
String key = pair.getKey();
|
||||
Object value = pair.getValue();
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
return pair;
|
||||
|
||||
switch (key) {
|
||||
case "useShouldOverrideUrlLoading":
|
||||
useShouldOverrideUrlLoading = (Boolean) value;
|
||||
break;
|
||||
case "useOnLoadResource":
|
||||
useOnLoadResource = (Boolean) value;
|
||||
break;
|
||||
case "useOnDownloadStart":
|
||||
useOnDownloadStart = (Boolean) value;
|
||||
break;
|
||||
case "clearCache":
|
||||
clearCache = (Boolean) value;
|
||||
break;
|
||||
case "userAgent":
|
||||
userAgent = (String) value;
|
||||
break;
|
||||
case "applicationNameForUserAgent":
|
||||
applicationNameForUserAgent = (String) value;
|
||||
break;
|
||||
case "javaScriptEnabled":
|
||||
javaScriptEnabled = (Boolean) value;
|
||||
break;
|
||||
case "debuggingEnabled":
|
||||
debuggingEnabled = (Boolean) value;
|
||||
break;
|
||||
case "javaScriptCanOpenWindowsAutomatically":
|
||||
javaScriptCanOpenWindowsAutomatically = (Boolean) value;
|
||||
break;
|
||||
case "mediaPlaybackRequiresUserGesture":
|
||||
mediaPlaybackRequiresUserGesture = (Boolean) value;
|
||||
break;
|
||||
case "minimumFontSize":
|
||||
minimumFontSize = (Integer) value;
|
||||
break;
|
||||
case "verticalScrollBarEnabled":
|
||||
verticalScrollBarEnabled = (Boolean) value;
|
||||
break;
|
||||
case "horizontalScrollBarEnabled":
|
||||
horizontalScrollBarEnabled = (Boolean) value;
|
||||
break;
|
||||
case "resourceCustomSchemes":
|
||||
resourceCustomSchemes = (List<String>) value;
|
||||
break;
|
||||
case "contentBlockers":
|
||||
contentBlockers = (List<Map<String, Map<String, Object>>>) value;
|
||||
break;
|
||||
case "preferredContentMode":
|
||||
preferredContentMode = (Integer) value;
|
||||
break;
|
||||
case "useShouldInterceptAjaxRequest":
|
||||
useShouldInterceptAjaxRequest = (Boolean) value;
|
||||
break;
|
||||
case "useShouldInterceptFetchRequest":
|
||||
useShouldInterceptFetchRequest = (Boolean) value;
|
||||
break;
|
||||
case "incognito":
|
||||
incognito = (Boolean) value;
|
||||
break;
|
||||
case "cacheEnabled":
|
||||
cacheEnabled = (Boolean) value;
|
||||
break;
|
||||
case "transparentBackground":
|
||||
transparentBackground = (Boolean) value;
|
||||
break;
|
||||
case "disableVerticalScroll":
|
||||
disableVerticalScroll = (Boolean) value;
|
||||
break;
|
||||
case "disableHorizontalScroll":
|
||||
disableHorizontalScroll = (Boolean) value;
|
||||
break;
|
||||
case "textZoom":
|
||||
textZoom = (Integer) value;
|
||||
break;
|
||||
case "clearSessionCache":
|
||||
clearSessionCache = (Boolean) value;
|
||||
break;
|
||||
case "builtInZoomControls":
|
||||
builtInZoomControls = (Boolean) value;
|
||||
break;
|
||||
case "displayZoomControls":
|
||||
displayZoomControls = (Boolean) value;
|
||||
break;
|
||||
case "supportZoom":
|
||||
supportZoom = (Boolean) value;
|
||||
break;
|
||||
case "databaseEnabled":
|
||||
databaseEnabled = (Boolean) value;
|
||||
break;
|
||||
case "domStorageEnabled":
|
||||
domStorageEnabled = (Boolean) value;
|
||||
break;
|
||||
case "useWideViewPort":
|
||||
useWideViewPort = (Boolean) value;
|
||||
break;
|
||||
case "safeBrowsingEnabled":
|
||||
safeBrowsingEnabled = (Boolean) value;
|
||||
break;
|
||||
case "mixedContentMode":
|
||||
mixedContentMode = (Integer) value;
|
||||
break;
|
||||
case "allowContentAccess":
|
||||
allowContentAccess = (Boolean) value;
|
||||
break;
|
||||
case "allowFileAccess":
|
||||
allowFileAccess = (Boolean) value;
|
||||
break;
|
||||
case "allowFileAccessFromFileURLs":
|
||||
allowFileAccessFromFileURLs = (Boolean) value;
|
||||
break;
|
||||
case "allowUniversalAccessFromFileURLs":
|
||||
allowUniversalAccessFromFileURLs = (Boolean) value;
|
||||
break;
|
||||
case "appCachePath":
|
||||
appCachePath = (String) value;
|
||||
break;
|
||||
case "blockNetworkImage":
|
||||
blockNetworkImage = (Boolean) value;
|
||||
break;
|
||||
case "blockNetworkLoads":
|
||||
blockNetworkLoads = (Boolean) value;
|
||||
break;
|
||||
case "cacheMode":
|
||||
cacheMode = (Integer) value;
|
||||
break;
|
||||
case "cursiveFontFamily":
|
||||
cursiveFontFamily = (String) value;
|
||||
break;
|
||||
case "defaultFixedFontSize":
|
||||
defaultFixedFontSize = (Integer) value;
|
||||
break;
|
||||
case "defaultFontSize":
|
||||
defaultFontSize = (Integer) value;
|
||||
break;
|
||||
case "defaultTextEncodingName":
|
||||
defaultTextEncodingName = (String) value;
|
||||
break;
|
||||
case "disabledActionModeMenuItems":
|
||||
disabledActionModeMenuItems = (Integer) value;
|
||||
break;
|
||||
case "fantasyFontFamily":
|
||||
fantasyFontFamily = (String) value;
|
||||
break;
|
||||
case "fixedFontFamily":
|
||||
fixedFontFamily = (String) value;
|
||||
break;
|
||||
case "forceDark":
|
||||
forceDark = (Integer) value;
|
||||
break;
|
||||
case "geolocationEnabled":
|
||||
geolocationEnabled = (Boolean) value;
|
||||
break;
|
||||
case "layoutAlgorithm":
|
||||
setLayoutAlgorithm((String) value);
|
||||
break;
|
||||
case "loadWithOverviewMode":
|
||||
loadWithOverviewMode = (Boolean) value;
|
||||
break;
|
||||
case "loadsImagesAutomatically":
|
||||
loadsImagesAutomatically = (Boolean) value;
|
||||
break;
|
||||
case "minimumLogicalFontSize":
|
||||
minimumLogicalFontSize = (Integer) value;
|
||||
break;
|
||||
case "initialScale":
|
||||
initialScale = (Integer) value;
|
||||
break;
|
||||
case "needInitialFocus":
|
||||
needInitialFocus = (Boolean) value;
|
||||
break;
|
||||
case "offscreenPreRaster":
|
||||
offscreenPreRaster = (Boolean) value;
|
||||
break;
|
||||
case "sansSerifFontFamily":
|
||||
sansSerifFontFamily = (String) value;
|
||||
break;
|
||||
case "serifFontFamily":
|
||||
serifFontFamily = (String) value;
|
||||
break;
|
||||
case "standardFontFamily":
|
||||
standardFontFamily = (String) value;
|
||||
break;
|
||||
case "saveFormData":
|
||||
saveFormData = (Boolean) value;
|
||||
break;
|
||||
case "thirdPartyCookiesEnabled":
|
||||
thirdPartyCookiesEnabled = (Boolean) value;
|
||||
break;
|
||||
case "hardwareAcceleration":
|
||||
hardwareAcceleration = (Boolean) value;
|
||||
break;
|
||||
case "supportMultipleWindows":
|
||||
supportMultipleWindows = (Boolean) value;
|
||||
break;
|
||||
case "regexToCancelSubFramesLoading":
|
||||
regexToCancelSubFramesLoading = (String) value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onParse(pair);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object onGetHashMap(Field field) {
|
||||
if (field.getName().equals("layoutAlgorithm")) {
|
||||
try {
|
||||
WebSettings.LayoutAlgorithm value = (WebSettings.LayoutAlgorithm) field.get(this);
|
||||
public HashMap<String, Object> getHashMap() {
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("useShouldOverrideUrlLoading", useShouldOverrideUrlLoading);
|
||||
options.put("useOnLoadResource", useOnLoadResource);
|
||||
options.put("useOnDownloadStart", useOnDownloadStart);
|
||||
options.put("clearCache", clearCache);
|
||||
options.put("userAgent", userAgent);
|
||||
options.put("applicationNameForUserAgent", applicationNameForUserAgent);
|
||||
options.put("javaScriptEnabled", javaScriptEnabled);
|
||||
options.put("debuggingEnabled", debuggingEnabled);
|
||||
options.put("javaScriptCanOpenWindowsAutomatically", javaScriptCanOpenWindowsAutomatically);
|
||||
options.put("mediaPlaybackRequiresUserGesture", mediaPlaybackRequiresUserGesture);
|
||||
options.put("minimumFontSize", minimumFontSize);
|
||||
options.put("verticalScrollBarEnabled", verticalScrollBarEnabled);
|
||||
options.put("horizontalScrollBarEnabled", horizontalScrollBarEnabled);
|
||||
options.put("resourceCustomSchemes", resourceCustomSchemes);
|
||||
options.put("contentBlockers", contentBlockers);
|
||||
options.put("preferredContentMode", preferredContentMode);
|
||||
options.put("useShouldInterceptAjaxRequest", useShouldInterceptAjaxRequest);
|
||||
options.put("useShouldInterceptFetchRequest", useShouldInterceptFetchRequest);
|
||||
options.put("incognito", incognito);
|
||||
options.put("cacheEnabled", cacheEnabled);
|
||||
options.put("transparentBackground", transparentBackground);
|
||||
options.put("disableVerticalScroll", disableVerticalScroll);
|
||||
options.put("disableHorizontalScroll", disableHorizontalScroll);
|
||||
options.put("textZoom", textZoom);
|
||||
options.put("clearSessionCache", clearSessionCache);
|
||||
options.put("builtInZoomControls", builtInZoomControls);
|
||||
options.put("displayZoomControls", displayZoomControls);
|
||||
options.put("supportZoom", supportZoom);
|
||||
options.put("databaseEnabled", databaseEnabled);
|
||||
options.put("domStorageEnabled", domStorageEnabled);
|
||||
options.put("useWideViewPort", useWideViewPort);
|
||||
options.put("safeBrowsingEnabled", safeBrowsingEnabled);
|
||||
options.put("mixedContentMode", mixedContentMode);
|
||||
options.put("allowContentAccess", allowContentAccess);
|
||||
options.put("allowFileAccess", allowFileAccess);
|
||||
options.put("allowFileAccessFromFileURLs", allowFileAccessFromFileURLs);
|
||||
options.put("allowUniversalAccessFromFileURLs", allowUniversalAccessFromFileURLs);
|
||||
options.put("appCachePath", appCachePath);
|
||||
options.put("blockNetworkImage", blockNetworkImage);
|
||||
options.put("blockNetworkLoads", blockNetworkLoads);
|
||||
options.put("cacheMode", cacheMode);
|
||||
options.put("cursiveFontFamily", cursiveFontFamily);
|
||||
options.put("defaultFixedFontSize", defaultFixedFontSize);
|
||||
options.put("defaultFontSize", defaultFontSize);
|
||||
options.put("defaultTextEncodingName", defaultTextEncodingName);
|
||||
options.put("disabledActionModeMenuItems", disabledActionModeMenuItems);
|
||||
options.put("fantasyFontFamily", fantasyFontFamily);
|
||||
options.put("fixedFontFamily", fixedFontFamily);
|
||||
options.put("forceDark", forceDark);
|
||||
options.put("geolocationEnabled", geolocationEnabled);
|
||||
options.put("layoutAlgorithm", getLayoutAlgorithm());
|
||||
options.put("loadWithOverviewMode", loadWithOverviewMode);
|
||||
options.put("loadsImagesAutomatically", loadsImagesAutomatically);
|
||||
options.put("minimumLogicalFontSize", minimumLogicalFontSize);
|
||||
options.put("initialScale", initialScale);
|
||||
options.put("needInitialFocus", needInitialFocus);
|
||||
options.put("offscreenPreRaster", offscreenPreRaster);
|
||||
options.put("sansSerifFontFamily", sansSerifFontFamily);
|
||||
options.put("serifFontFamily", serifFontFamily);
|
||||
options.put("standardFontFamily", standardFontFamily);
|
||||
options.put("saveFormData", saveFormData);
|
||||
options.put("thirdPartyCookiesEnabled", thirdPartyCookiesEnabled);
|
||||
options.put("hardwareAcceleration", hardwareAcceleration);
|
||||
options.put("supportMultipleWindows", supportMultipleWindows);
|
||||
options.put("regexToCancelSubFramesLoading", regexToCancelSubFramesLoading);
|
||||
return options;
|
||||
}
|
||||
|
||||
private void setLayoutAlgorithm(String value) {
|
||||
if (value != null) {
|
||||
switch (value) {
|
||||
case "NORMAL":
|
||||
layoutAlgorithm = NORMAL;
|
||||
case "TEXT_AUTOSIZING":
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING;
|
||||
} else {
|
||||
layoutAlgorithm = NORMAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getLayoutAlgorithm() {
|
||||
if (layoutAlgorithm != null) {
|
||||
switch (layoutAlgorithm) {
|
||||
case NORMAL:
|
||||
return "NORMAL";
|
||||
default:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && value.equals(WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING)) {
|
||||
case TEXT_AUTOSIZING:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
return "TEXT_AUTOSIZING";
|
||||
}
|
||||
} else {
|
||||
return "NORMAL";
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
return super.onGetHashMap(field);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
48
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InputAwareWebView.java
Normal file → Executable file
48
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/InputAwareWebView.java
Normal file → Executable file
|
@ -3,11 +3,14 @@ package com.pichillilorenzo.flutter_inappwebview.InAppWebView;
|
|||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ListPopupWindow;
|
||||
|
||||
/**
|
||||
* A WebView subclass that mirrors the same implementation hacks that the system WebView does in
|
||||
|
@ -190,8 +193,53 @@ public class InputAwareWebView extends WebView {
|
|||
// onCreateInputConnection() on targetView on the same thread as
|
||||
// targetView.getHandler(). It will also call subsequent InputConnection methods on this
|
||||
// thread. This is the IME thread in cases where targetView is our proxyAdapterView.
|
||||
|
||||
// TODO (ALexVincent525): Currently only prompt has been tested, still needs more test cases.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||
imm.isActive(containerView);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
|
||||
// This works around a crash when old (<67.0.3367.0) Chromium versions are used.
|
||||
|
||||
// Prior to Chromium 67.0.3367 the following sequence happens when a select drop down is shown
|
||||
// on tablets:
|
||||
//
|
||||
// - WebView is calling ListPopupWindow#show
|
||||
// - buildDropDown is invoked, which sets mDropDownList to a DropDownListView.
|
||||
// - showAsDropDown is invoked - resulting in mDropDownList being added to the window and is
|
||||
// also synchronously performing the following sequence:
|
||||
// - WebView's focus change listener is loosing focus (as mDropDownList got it)
|
||||
// - WebView is hiding all popups (as it lost focus)
|
||||
// - WebView's SelectPopupDropDown#hide is invoked.
|
||||
// - DropDownPopupWindow#dismiss is invoked setting mDropDownList to null.
|
||||
// - mDropDownList#setSelection is invoked and is throwing a NullPointerException (as we just set mDropDownList to null).
|
||||
//
|
||||
// To workaround this, we drop the problematic focus lost call.
|
||||
// See more details on: https://github.com/flutter/flutter/issues/54164
|
||||
//
|
||||
// We don't do this after Android P as it shipped with a new enough WebView version, and it's
|
||||
// better to not do this on all future Android versions in case DropDownListView's code changes.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P
|
||||
&& isCalledFromListPopupWindowShow()
|
||||
&& !focused) {
|
||||
return;
|
||||
}
|
||||
super.onFocusChanged(focused, direction, previouslyFocusedRect);
|
||||
}
|
||||
|
||||
private boolean isCalledFromListPopupWindowShow() {
|
||||
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
|
||||
for (int i = 0; i < stackTraceElements.length; i++) {
|
||||
if (stackTraceElements[i].getClassName().equals(ListPopupWindow.class.getCanonicalName())
|
||||
&& stackTraceElements[i].getMethodName().equals("show")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/PreferredContentModeOptionType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/PreferredContentModeOptionType.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/ThreadedInputConnectionProxyAdapterView.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebView/ThreadedInputConnectionProxyAdapterView.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewFlutterPlugin.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewStatic.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/InAppWebViewStatic.java
Normal file → Executable file
214
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/JavaScriptBridgeInterface.java
Normal file → Executable file
214
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/JavaScriptBridgeInterface.java
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyCookieManager.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/MyWebStorage.java
Normal file → Executable file
48
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Options.java
Normal file → Executable file
48
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Options.java
Normal file → Executable file
|
@ -1,51 +1,9 @@
|
|||
package com.pichillilorenzo.flutter_inappwebview;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Options {
|
||||
|
||||
public interface Options {
|
||||
static String LOG_TAG = "Options";
|
||||
|
||||
public Options parse(HashMap<String, Object> options) {
|
||||
Iterator it = options.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, Object> pair = (Map.Entry<String, Object>) it.next();
|
||||
Object value = this.onParse(pair);
|
||||
try {
|
||||
this.getClass().getDeclaredField(pair.getKey()).set(this, value);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object onParse(Map.Entry<String, Object> pair) {
|
||||
return pair.getValue();
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getHashMap() {
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
for (Field field : this.getClass().getDeclaredFields()) {
|
||||
options.put(field.getName(), onGetHashMap(field));
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
public Object onGetHashMap(Field field) {
|
||||
try {
|
||||
return field.get(this);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.d(LOG_TAG, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Options parse(HashMap<String, Object> options);
|
||||
public HashMap<String, Object> getHashMap();
|
||||
}
|
||||
|
|
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/RequestPermissionHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/RequestPermissionHandler.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Shared.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Shared.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java
Normal file → Executable file
0
android/src/main/java/com/pichillilorenzo/flutter_inappwebview/Util.java
Normal file → Executable file
|
@ -1 +1 @@
|
|||
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"connectivity","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]}]}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity-0.4.8+5/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.7/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-3.3.0/","dependencies":[]}],"android":[{"name":"connectivity","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity-0.4.8+5/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.4.4/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.7/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-3.3.0/","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_macos-0.1.0+3/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos"]},{"name":"connectivity_macos","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-05-09 04:31:57.281568","version":"1.17.0"}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue