Browse Source

Merge branch 'master' into android-permissions

Jamon Holmgren 4 years ago
parent
commit
b533f44ba9
No account linked to committer's email address

+ 15
- 14
android/build.gradle View File

@@ -1,21 +1,22 @@
1 1
 buildscript {
2
-  //Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
-  def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeWebView_kotlinVersion']
4
-
5
-  repositories {
6
-    google()
7
-    jcenter()
2
+  ext.getExtOrDefault = {name ->
3
+    return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeWebView_' + name]
8 4
   }
9 5
 
10
-  dependencies {
11
-    classpath 'com.android.tools.build:gradle:3.2.1'
12
-    //noinspection DifferentKotlinGradleVersion
13
-    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
-  }
15
-}
6
+  // The Android Gradle plugin is only required when opening the android folder stand-alone.
7
+  // This avoids unnecessary downloads and potential conflicts when the library is included as a
8
+  // module dependency in an application project.
9
+  if (project == rootProject) {
10
+    repositories {
11
+      google()
12
+      jcenter()
13
+    }
16 14
 
17
-def getExtOrDefault(name) {
18
-  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeWebView_' + name]
15
+    dependencies {
16
+      classpath("com.android.tools.build:gradle:3.6.0")
17
+      classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}")
18
+    }
19
+  }
19 20
 }
20 21
 
21 22
 def getExtOrIntegerDefault(name) {

+ 6
- 2
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java View File

@@ -335,7 +335,11 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
335 335
       // convert file extensions to mime types
336 336
       if (t.matches("\\.\\w+")) {
337 337
         String mimeType = getMimeTypeFromExtension(t.replace(".", ""));
338
-        mimeTypes[i] = mimeType;
338
+        if(mimeType != null) {
339
+          mimeTypes[i] = mimeType;
340
+        } else {
341
+          mimeTypes[i] = t;
342
+        }
339 343
       } else {
340 344
         mimeTypes[i] = t;
341 345
       }
@@ -404,7 +408,7 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
404 408
     // when our array returned from getAcceptTypes() has no values set from the webview
405 409
     // i.e. <input type="file" />, without any "accept" attr
406 410
     // will be an array with one empty string element, afaik
407
-    return arr.length == 0 || (arr.length == 1 && arr[0].length() == 0);
411
+    return arr.length == 0 || (arr.length == 1 && arr[0] != null && arr[0].length() == 0);
408 412
   }
409 413
 
410 414
   private PermissionAwareActivity getPermissionAwareActivity() {

+ 17
- 13
apple/RNCWebView.m View File

@@ -146,7 +146,7 @@ static NSDictionary* customCertificatesForHost;
146 146
     selector:@selector(appDidBecomeActive)
147 147
         name:UIApplicationDidBecomeActiveNotification
148 148
       object:nil];
149
-    
149
+
150 150
     [[NSNotificationCenter defaultCenter]addObserver:self
151 151
     selector:@selector(appWillResignActive)
152 152
         name:UIApplicationWillResignActiveNotification
@@ -174,7 +174,7 @@ static NSDictionary* customCertificatesForHost;
174 174
                                                selector:@selector(hideFullScreenVideoStatusBars)
175 175
                                                    name:UIWindowDidBecomeHiddenNotification
176 176
                                                  object:nil];
177
-      
177
+
178 178
   }
179 179
 #endif // !TARGET_OS_OSX
180 180
   return self;
@@ -242,7 +242,7 @@ static NSDictionary* customCertificatesForHost;
242 242
   if (_applicationNameForUserAgent) {
243 243
       wkWebViewConfig.applicationNameForUserAgent = [NSString stringWithFormat:@"%@ %@", wkWebViewConfig.applicationNameForUserAgent, _applicationNameForUserAgent];
244 244
   }
245
-  
245
+
246 246
   return wkWebViewConfig;
247 247
 }
248 248
 
@@ -307,6 +307,10 @@ static NSDictionary* customCertificatesForHost;
307 307
         _webView.scrollView.delegate = nil;
308 308
 #endif // !TARGET_OS_OSX
309 309
         _webView = nil;
310
+        if (_onContentProcessDidTerminate) {
311
+          NSMutableDictionary<NSString *, id> *event = [self baseEvent];
312
+          _onContentProcessDidTerminate(event);
313
+        }
310 314
     }
311 315
 
312 316
     [super removeFromSuperview];
@@ -1102,7 +1106,7 @@ static NSDictionary* customCertificatesForHost;
1102 1106
   if (_ignoreSilentHardwareSwitch) {
1103 1107
     [self forceIgnoreSilentHardwareSwitch:true];
1104 1108
   }
1105
-    
1109
+
1106 1110
   if (_onLoadingFinish) {
1107 1111
     _onLoadingFinish([self baseEvent]);
1108 1112
   }
@@ -1155,11 +1159,11 @@ static NSDictionary* customCertificatesForHost;
1155 1159
 
1156 1160
 - (void)setInjectedJavaScript:(NSString *)source {
1157 1161
   _injectedJavaScript = source;
1158
-  
1162
+
1159 1163
   self.atEndScript = source == nil ? nil : [[WKUserScript alloc] initWithSource:source
1160 1164
       injectionTime:WKUserScriptInjectionTimeAtDocumentEnd
1161 1165
     forMainFrameOnly:_injectedJavaScriptForMainFrameOnly];
1162
-  
1166
+
1163 1167
   if(_webView != nil){
1164 1168
     [self resetupScripts:_webView.configuration];
1165 1169
   }
@@ -1167,11 +1171,11 @@ static NSDictionary* customCertificatesForHost;
1167 1171
 
1168 1172
 - (void)setInjectedJavaScriptBeforeContentLoaded:(NSString *)source {
1169 1173
   _injectedJavaScriptBeforeContentLoaded = source;
1170
-  
1174
+
1171 1175
   self.atStartScript = source == nil ? nil : [[WKUserScript alloc] initWithSource:source
1172 1176
        injectionTime:WKUserScriptInjectionTimeAtDocumentStart
1173 1177
     forMainFrameOnly:_injectedJavaScriptBeforeContentLoadedForMainFrameOnly];
1174
-  
1178
+
1175 1179
   if(_webView != nil){
1176 1180
     [self resetupScripts:_webView.configuration];
1177 1181
   }
@@ -1189,7 +1193,7 @@ static NSDictionary* customCertificatesForHost;
1189 1193
 
1190 1194
 - (void)setMessagingEnabled:(BOOL)messagingEnabled {
1191 1195
   _messagingEnabled = messagingEnabled;
1192
-  
1196
+
1193 1197
   self.postMessageScript = _messagingEnabled ?
1194 1198
   [
1195 1199
    [WKUserScript alloc]
@@ -1209,7 +1213,7 @@ static NSDictionary* customCertificatesForHost;
1209 1213
    forMainFrameOnly:YES
1210 1214
    ] :
1211 1215
   nil;
1212
-  
1216
+
1213 1217
   if(_webView != nil){
1214 1218
     [self resetupScripts:_webView.configuration];
1215 1219
   }
@@ -1218,7 +1222,7 @@ static NSDictionary* customCertificatesForHost;
1218 1222
 - (void)resetupScripts:(WKWebViewConfiguration *)wkWebViewConfig {
1219 1223
   [wkWebViewConfig.userContentController removeAllUserScripts];
1220 1224
   [wkWebViewConfig.userContentController removeScriptMessageHandlerForName:MessageHandlerName];
1221
-  
1225
+
1222 1226
   NSString *html5HistoryAPIShimSource = [NSString stringWithFormat:
1223 1227
     @"(function(history) {\n"
1224 1228
     "  function notify(type) {\n"
@@ -1241,7 +1245,7 @@ static NSDictionary* customCertificatesForHost;
1241 1245
   ];
1242 1246
   WKUserScript *script = [[WKUserScript alloc] initWithSource:html5HistoryAPIShimSource injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
1243 1247
   [wkWebViewConfig.userContentController addUserScript:script];
1244
-  
1248
+
1245 1249
   if(_sharedCookiesEnabled) {
1246 1250
     // More info to sending cookies with WKWebView
1247 1251
     // https://stackoverflow.com/questions/26573137/can-i-set-the-cookies-to-be-used-by-a-wkwebview/26577303#26577303
@@ -1303,7 +1307,7 @@ static NSDictionary* customCertificatesForHost;
1303 1307
       [wkWebViewConfig.userContentController addUserScript:cookieInScript];
1304 1308
     }
1305 1309
   }
1306
-  
1310
+
1307 1311
   if(_messagingEnabled){
1308 1312
     if (self.postMessageScript){
1309 1313
       [wkWebViewConfig.userContentController addScriptMessageHandler:[[RNCWeakScriptMessageDelegate alloc] initWithDelegate:self]

+ 1
- 1
package.json View File

@@ -8,7 +8,7 @@
8 8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
9 9
   ],
10 10
   "license": "MIT",
11
-  "version": "9.4.0",
11
+  "version": "10.0.0",
12 12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13 13
   "scripts": {
14 14
     "start": "node node_modules/react-native/local-cli/cli.js start",