Browse Source

WIP: Android

Jamon Holmgren 6 years ago
parent
commit
d1f442cc51

+ 5
- 5
android/build.gradle View File

@@ -1,14 +1,14 @@
1 1
 apply plugin: 'com.android.library'
2 2
 
3 3
 android {
4
-    compileSdkVersion 23
5
-    buildToolsVersion "25.0.0"
4
+    compileSdkVersion 26
5
+    buildToolsVersion '26.0.3'
6 6
 
7 7
     defaultConfig {
8 8
         minSdkVersion 16
9
-        targetSdkVersion 22
10
-        versionCode 19
11
-        versionName "1.1.17"
9
+        targetSdkVersion 26
10
+        versionCode 1
11
+        versionName "1.0"
12 12
     }
13 13
 }
14 14
 

+ 22
- 0
android/src/main/java/com/infinitered/webview/ReactWebViewModule.java View File

@@ -0,0 +1,22 @@
1
+
2
+package com.infinitered.webview;
3
+
4
+import com.facebook.react.bridge.ReactApplicationContext;
5
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
6
+import com.facebook.react.bridge.ReactMethod;
7
+import com.facebook.react.bridge.Callback;
8
+
9
+public class ReactWebViewModule extends ReactContextBaseJavaModule {
10
+
11
+  private final ReactApplicationContext reactContext;
12
+
13
+  public ReactWebViewModule(ReactApplicationContext reactContext) {
14
+    super(reactContext);
15
+    this.reactContext = reactContext;
16
+  }
17
+
18
+  @Override
19
+  public String getName() {
20
+    return "RNCWebView";
21
+  }
22
+}

+ 29
- 0
android/src/main/java/com/infinitered/webview/ReactWebViewPackage.java View File

@@ -0,0 +1,29 @@
1
+
2
+package com.infinitered.webview;
3
+
4
+import java.util.Arrays;
5
+import java.util.Collections;
6
+import java.util.List;
7
+
8
+import com.facebook.react.ReactPackage;
9
+import com.facebook.react.bridge.NativeModule;
10
+import com.facebook.react.bridge.ReactApplicationContext;
11
+import com.facebook.react.uimanager.ViewManager;
12
+import com.facebook.react.bridge.JavaScriptModule;
13
+public class ReactWebViewPackage implements ReactPackage {
14
+    @Override
15
+    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16
+      return Arrays.<NativeModule>asList(new ReactWebViewModule(reactContext));
17
+    }
18
+
19
+    // Deprecated from RN 0.47
20
+    public List<Class<? extends JavaScriptModule>> createJSModules() {
21
+      return Collections.emptyList();
22
+    }
23
+
24
+    @Override
25
+    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
26
+        ReactWebViewManager viewManager = new ReactWebViewManager();
27
+        return Arrays.<ViewManager>asList(viewManager);
28
+    }
29
+}

+ 1
- 1
android/src/main/java/com/infinitered/webview/events/TopLoadingErrorEvent.java View File

@@ -5,7 +5,7 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-package com.facebook.react.views.webview.events;
8
+package com.infinitered.webview.events;
9 9
 
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.facebook.react.uimanager.events.Event;

+ 1
- 1
android/src/main/java/com/infinitered/webview/events/TopLoadingFinishEvent.java View File

@@ -5,7 +5,7 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-package com.facebook.react.views.webview.events;
8
+package com.infinitered.webview.events;
9 9
 
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.facebook.react.uimanager.events.Event;

+ 1
- 1
android/src/main/java/com/infinitered/webview/events/TopLoadingStartEvent.java View File

@@ -5,7 +5,7 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-package com.facebook.react.views.webview.events;
8
+package com.infinitered.webview.events;
9 9
 
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.facebook.react.uimanager.events.Event;

+ 1
- 1
android/src/main/java/com/infinitered/webview/events/TopMessageEvent.java View File

@@ -5,7 +5,7 @@
5 5
  * LICENSE file in the root directory of this source tree.
6 6
  */
7 7
 
8
-package com.facebook.react.views.webview.events;
8
+package com.infinitered.webview.events;
9 9
 
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.facebook.react.bridge.Arguments;

+ 8
- 6
js/WebView.android.js View File

@@ -9,7 +9,7 @@
9 9
 
10 10
 'use strict';
11 11
 
12
-import React from 'React';
12
+import React from 'react';
13 13
 import PropTypes from 'prop-types';
14 14
 
15 15
 import ReactNative from 'react-native';
@@ -20,8 +20,8 @@ import {
20 20
   UIManager,
21 21
   View,
22 22
   ViewPropTypes,
23
-  requireNativeComponent,
24
-  resolveAssetSource
23
+  Image,
24
+  requireNativeComponent
25 25
 } from 'react-native';
26 26
 
27 27
 import deprecatedPropType from 'deprecated-prop-type';
@@ -29,7 +29,9 @@ import keyMirror from 'fbjs/lib/keyMirror';
29 29
 
30 30
 import WebViewShared from './WebViewShared';
31 31
 
32
-const RCT_WEBVIEW_REF = 'webview';
32
+const resolveAssetSource = Image.resolveAssetSource;
33
+
34
+const RNC_WEBVIEW_REF = 'webview';
33 35
 
34 36
 const WebViewState = keyMirror({
35 37
   IDLE: null,
@@ -310,7 +312,7 @@ class WebView extends React.Component {
310 312
 
311 313
     const webView = (
312 314
       <NativeWebView
313
-        ref={RCT_WEBVIEW_REF}
315
+        ref={RNC_WEBVIEW_REF}
314 316
         key="webViewKey"
315 317
         style={webViewStyles}
316 318
         source={resolveAssetSource(source)}
@@ -422,7 +424,7 @@ class WebView extends React.Component {
422 424
   };
423 425
 
424 426
   getWebViewHandle = () => {
425
-    return ReactNative.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
427
+    return ReactNative.findNodeHandle(this.refs[RNC_WEBVIEW_REF]);
426 428
   };
427 429
 
428 430
   onLoadingStart = event => {

+ 0
- 1
js/WebView.ios.js View File

@@ -18,7 +18,6 @@ import {
18 18
   ActivityIndicator,
19 19
   EdgeInsetsPropType,
20 20
   Linking,
21
-  ScrollView,
22 21
   StyleSheet,
23 22
   Text,
24 23
   UIManager,