Browse Source

Merge branch 'master' into dependencies-update

Thibault Malbranche 5 years ago
parent
commit
7eb979b69c
No account linked to committer's email address

+ 19
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java View File

16
 import androidx.annotation.RequiresApi;
16
 import androidx.annotation.RequiresApi;
17
 import androidx.core.content.ContextCompat;
17
 import androidx.core.content.ContextCompat;
18
 import android.text.TextUtils;
18
 import android.text.TextUtils;
19
+import android.view.MotionEvent;
19
 import android.view.Gravity;
20
 import android.view.Gravity;
20
 import android.view.View;
21
 import android.view.View;
21
 import android.view.ViewGroup;
22
 import android.view.ViewGroup;
363
   public void setMessagingEnabled(WebView view, boolean enabled) {
364
   public void setMessagingEnabled(WebView view, boolean enabled) {
364
     ((RNCWebView) view).setMessagingEnabled(enabled);
365
     ((RNCWebView) view).setMessagingEnabled(enabled);
365
   }
366
   }
366
-   
367
+
367
   @ReactProp(name = "incognito")
368
   @ReactProp(name = "incognito")
368
   public void setIncognito(WebView view, boolean enabled) {
369
   public void setIncognito(WebView view, boolean enabled) {
369
     // Remove all previous cookies
370
     // Remove all previous cookies
910
       this.hasScrollEvent = hasScrollEvent;
911
       this.hasScrollEvent = hasScrollEvent;
911
     }
912
     }
912
 
913
 
914
+    @Override
915
+    public boolean onTouchEvent(MotionEvent event){
916
+
917
+      // Allow scrolling inside ScrollView
918
+      if (event.findPointerIndex(0) == -1) {
919
+        return super.onTouchEvent(event);
920
+      }
921
+
922
+      if (event.getPointerCount() >= 1) {
923
+        requestDisallowInterceptTouchEvent(true);
924
+      } else {
925
+        requestDisallowInterceptTouchEvent(false);
926
+      }
927
+
928
+      return super.onTouchEvent(event);
929
+    }
930
+
913
     @Override
931
     @Override
914
     public void onHostResume() {
932
     public void onHostResume() {
915
       // do nothing
933
       // do nothing

+ 1
- 1
docs/Reference.md View File

90
 _Note that using static HTML requires the WebView property [originWhiteList](Reference.md#originWhiteList) to `['*']`. For some content, such as video embeds (e.g. Twitter or Facebook posts with video), the baseUrl needs to be set for the video playback to work_
90
 _Note that using static HTML requires the WebView property [originWhiteList](Reference.md#originWhiteList) to `['*']`. For some content, such as video embeds (e.g. Twitter or Facebook posts with video), the baseUrl needs to be set for the video playback to work_
91
 
91
 
92
 - `html` (string) - A static HTML page to display in the WebView.
92
 - `html` (string) - A static HTML page to display in the WebView.
93
-- `baseUrl` (string) - The base URL to be used for any relative links in the HTML.
93
+- `baseUrl` (string) - The base URL to be used for any relative links in the HTML. This is also used for the origin header with CORS requests made from the WebView. See [Android WebView Docs](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL)
94
 
94
 
95
 | Type   | Required |
95
 | Type   | Required |
96
 | ------ | -------- |
96
 | ------ | -------- |

+ 2
- 0
index.d.ts View File

2
 // eslint-disable-next-line
2
 // eslint-disable-next-line
3
 import { IOSWebViewProps, AndroidWebViewProps } from './lib/WebViewTypes';
3
 import { IOSWebViewProps, AndroidWebViewProps } from './lib/WebViewTypes';
4
 
4
 
5
+export { WebViewMessageEvent, WebViewNavigation } from "./lib/WebViewTypes";
6
+
5
 export type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
7
 export type WebViewProps = IOSWebViewProps & AndroidWebViewProps;
6
 
8
 
7
 declare class WebView extends Component<WebViewProps> {
9
 declare class WebView extends Component<WebViewProps> {

+ 1
- 1
ios/RNCWebView.m View File

438
         [_webView loadRequest:request];
438
         [_webView loadRequest:request];
439
     }
439
     }
440
     else {
440
     else {
441
-        NSURL* readAccessUrl = _allowingReadAccessToURL ? [NSURL URLWithString:_allowingReadAccessToURL] : request.URL;
441
+        NSURL* readAccessUrl = _allowingReadAccessToURL ? [RCTConvert NSURL:_allowingReadAccessToURL] : request.URL;
442
         [_webView loadFileURL:request.URL allowingReadAccessToURL:readAccessUrl];
442
         [_webView loadFileURL:request.URL allowingReadAccessToURL:readAccessUrl];
443
     }
443
     }
444
 }
444
 }

+ 5
- 1
package.json View File

8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
9
   ],
9
   ],
10
   "license": "MIT",
10
   "license": "MIT",
11
-  "version": "7.0.3",
11
+  "version": "7.0.6",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13
   "scripts": {
13
   "scripts": {
14
     "ci": "CI=true && yarn lint && yarn test",
14
     "ci": "CI=true && yarn lint && yarn test",
18
     "prepare": "yarn build",
18
     "prepare": "yarn build",
19
     "test": "yarn jest"
19
     "test": "yarn jest"
20
   },
20
   },
21
+  "rn-docs": {
22
+    "title": "Webview",
23
+    "type": "Component"
24
+  },
21
   "peerDependencies": {
25
   "peerDependencies": {
22
     "react": "^16.0",
26
     "react": "^16.0",
23
     "react-native": ">=0.60 <0.62"
27
     "react-native": ">=0.60 <0.62"