Rename ReactWebView to RNCWebView, remove more infinitered references

This commit is contained in:
Jamon Holmgren 2018-08-15 20:30:06 -07:00
parent bc3be5ecaa
commit f9b9d3c092
14 changed files with 117 additions and 51 deletions

View File

@ -137,6 +137,7 @@ android {
}
dependencies {
compile project(':react-native-webview')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.facebook.react:react-native:+" // From node_modules

View File

@ -3,6 +3,7 @@ package com.webtest;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
@ -22,7 +23,8 @@ public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
new MainReactPackage(),
new RNCWebViewPackage()
);
}

View File

@ -1,3 +1,5 @@
rootProject.name = 'WebTest'
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':app'

View File

@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -38,6 +37,7 @@
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
0DEB930C40564C6EA64B2F22 /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 694F766453F2454298825A66 /* libRNCWebView.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -343,6 +343,8 @@
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
145424F98F774DD4816B6AB1 /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; name = "RNCWebView.xcodeproj"; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
694F766453F2454298825A66 /* libRNCWebView.a */ = {isa = PBXFileReference; name = "libRNCWebView.a"; path = "libRNCWebView.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -371,6 +373,7 @@
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
0DEB930C40564C6EA64B2F22 /* libRNCWebView.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -557,6 +560,7 @@
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
145424F98F774DD4816B6AB1 /* RNCWebView.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
@ -685,7 +689,7 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
LastUpgradeCheck = 610;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
@ -1181,6 +1185,14 @@
);
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebTest.app/WebTest";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Debug;
};
@ -1198,6 +1210,14 @@
);
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebTest.app/WebTest";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Release;
};
@ -1216,6 +1236,10 @@
);
PRODUCT_NAME = WebTest;
VERSIONING_SYSTEM = "apple-generic";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Debug;
};
@ -1233,6 +1257,10 @@
);
PRODUCT_NAME = WebTest;
VERSIONING_SYSTEM = "apple-generic";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Release;
};
@ -1259,6 +1287,14 @@
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.2;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Debug;
};
@ -1285,6 +1321,14 @@
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.2;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Release;
};
@ -1310,6 +1354,14 @@
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebTest-tvOS.app/WebTest-tvOS";
TVOS_DEPLOYMENT_TARGET = 10.1;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Debug;
};
@ -1335,6 +1387,14 @@
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WebTest-tvOS.app/WebTest-tvOS";
TVOS_DEPLOYMENT_TARGET = 10.1;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-webview/ios/**",
);
};
name = Release;
};

View File

@ -8,7 +8,8 @@
},
"dependencies": {
"react": "16.4.1",
"react-native": "0.56.0"
"react-native": "0.56.0",
"react-native-webview": "../"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta",

View File

@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.infinitered.webview">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reactnativecommunity.webview">
</manifest>

View File

@ -1,4 +1,4 @@
package com.infinitered.webview;
package com.reactnativecommunity.webview;
import android.annotation.TargetApi;
import android.content.Context;
@ -49,10 +49,10 @@ import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.ContentSizeChangeEvent;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.infinitered.webview.events.TopLoadingErrorEvent;
import com.infinitered.webview.events.TopLoadingFinishEvent;
import com.infinitered.webview.events.TopLoadingStartEvent;
import com.infinitered.webview.events.TopMessageEvent;
import com.reactnativecommunity.webview.events.TopLoadingErrorEvent;
import com.reactnativecommunity.webview.events.TopLoadingFinishEvent;
import com.reactnativecommunity.webview.events.TopLoadingStartEvent;
import com.reactnativecommunity.webview.events.TopMessageEvent;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
@ -83,8 +83,8 @@ import org.json.JSONObject;
* - canGoBack - boolean, whether there is anything on a history stack to go back
* - canGoForward - boolean, whether it is possible to request GO_FORWARD command
*/
@ReactModule(name = ReactWebViewManager.REACT_CLASS)
public class ReactWebViewManager extends SimpleViewManager<WebView> {
@ReactModule(name = RNCWebViewManager.REACT_CLASS)
public class RNCWebViewManager extends SimpleViewManager<WebView> {
protected static final String REACT_CLASS = "RNCWebView";
@ -108,7 +108,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
protected WebViewConfig mWebViewConfig;
protected @Nullable WebView.PictureListener mPictureListener;
protected static class ReactWebViewClient extends WebViewClient {
protected static class RNCWebViewClient extends WebViewClient {
protected boolean mLastLoadFailed = false;
protected @Nullable ReadableArray mUrlPrefixesForDefaultIntent;
@ -119,7 +119,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
super.onPageFinished(webView, url);
if (!mLastLoadFailed) {
ReactWebView reactWebView = (ReactWebView) webView;
RNCWebView reactWebView = (RNCWebView) webView;
reactWebView.callInjectedJavaScript();
reactWebView.linkBridge();
emitFinishEvent(webView, url);
@ -242,15 +242,15 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
* Subclass of {@link WebView} that implements {@link LifecycleEventListener} interface in order
* to call {@link WebView#destroy} on activity destroy event and also to clear the client
*/
protected static class ReactWebView extends WebView implements LifecycleEventListener {
protected static class RNCWebView extends WebView implements LifecycleEventListener {
protected @Nullable String injectedJS;
protected boolean messagingEnabled = false;
protected @Nullable ReactWebViewClient mReactWebViewClient;
protected @Nullable RNCWebViewClient mRNCWebViewClient;
protected class ReactWebViewBridge {
ReactWebView mContext;
protected class RNCWebViewBridge {
RNCWebView mContext;
ReactWebViewBridge(ReactWebView c) {
RNCWebViewBridge(RNCWebView c) {
mContext = c;
}
@ -267,7 +267,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
* Reactive Native needed for access to ReactNative internal system functionality
*
*/
public ReactWebView(ThemedReactContext reactContext) {
public RNCWebView(ThemedReactContext reactContext) {
super(reactContext);
}
@ -289,19 +289,19 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
@Override
public void setWebViewClient(WebViewClient client) {
super.setWebViewClient(client);
mReactWebViewClient = (ReactWebViewClient)client;
mRNCWebViewClient = (RNCWebViewClient)client;
}
public @Nullable ReactWebViewClient getReactWebViewClient() {
return mReactWebViewClient;
public @Nullable RNCWebViewClient getRNCWebViewClient() {
return mRNCWebViewClient;
}
public void setInjectedJavaScript(@Nullable String js) {
injectedJS = js;
}
protected ReactWebViewBridge createReactWebViewBridge(ReactWebView webView) {
return new ReactWebViewBridge(webView);
protected RNCWebViewBridge createRNCWebViewBridge(RNCWebView webView) {
return new RNCWebViewBridge(webView);
}
public void setMessagingEnabled(boolean enabled) {
@ -311,7 +311,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
messagingEnabled = enabled;
if (enabled) {
addJavascriptInterface(createReactWebViewBridge(this), BRIDGE_NAME);
addJavascriptInterface(createRNCWebViewBridge(this), BRIDGE_NAME);
linkBridge();
} else {
removeJavascriptInterface(BRIDGE_NAME);
@ -360,14 +360,14 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
}
}
public ReactWebViewManager() {
public RNCWebViewManager() {
mWebViewConfig = new WebViewConfig() {
public void configWebView(WebView webView) {
}
};
}
public ReactWebViewManager(WebViewConfig webViewConfig) {
public RNCWebViewManager(WebViewConfig webViewConfig) {
mWebViewConfig = webViewConfig;
}
@ -376,14 +376,14 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
return REACT_CLASS;
}
protected ReactWebView createReactWebViewInstance(ThemedReactContext reactContext) {
return new ReactWebView(reactContext);
protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) {
return new RNCWebView(reactContext);
}
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected WebView createViewInstance(ThemedReactContext reactContext) {
ReactWebView webView = createReactWebViewInstance(reactContext);
RNCWebView webView = createRNCWebViewInstance(reactContext);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage message) {
@ -474,12 +474,12 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
@ReactProp(name = "injectedJavaScript")
public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) {
((ReactWebView) view).setInjectedJavaScript(injectedJavaScript);
((RNCWebView) view).setInjectedJavaScript(injectedJavaScript);
}
@ReactProp(name = "messagingEnabled")
public void setMessagingEnabled(WebView view, boolean enabled) {
((ReactWebView) view).setMessagingEnabled(enabled);
((RNCWebView) view).setMessagingEnabled(enabled);
}
@ReactProp(name = "source")
@ -568,7 +568,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
public void setUrlPrefixesForDefaultIntent(
WebView view,
@Nullable ReadableArray urlPrefixesForDefaultIntent) {
ReactWebViewClient client = ((ReactWebView) view).getReactWebViewClient();
RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient();
if (client != null && urlPrefixesForDefaultIntent != null) {
client.setUrlPrefixesForDefaultIntent(urlPrefixesForDefaultIntent);
}
@ -585,7 +585,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
public void setOriginWhitelist(
WebView view,
@Nullable ReadableArray originWhitelist) {
ReactWebViewClient client = ((ReactWebView) view).getReactWebViewClient();
RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient();
if (client != null && originWhitelist != null) {
List<Pattern> whiteList = new LinkedList<>();
for (int i = 0 ; i < originWhitelist.size() ; i++) {
@ -598,7 +598,7 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
// Do not register default touch emitter and let WebView implementation handle touches
view.setWebViewClient(new ReactWebViewClient());
view.setWebViewClient(new RNCWebViewClient());
}
@Override
@ -656,8 +656,8 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
@Override
public void onDropViewInstance(WebView webView) {
super.onDropViewInstance(webView);
((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((ReactWebView) webView);
((ReactWebView) webView).cleanupCallbacksAndDestroy();
((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RNCWebView) webView);
((RNCWebView) webView).cleanupCallbacksAndDestroy();
}
protected WebView.PictureListener getPictureListener() {

View File

@ -1,16 +1,16 @@
package com.infinitered.webview;
package com.reactnativecommunity.webview;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
public class ReactWebViewModule extends ReactContextBaseJavaModule {
public class RNCWebViewModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext reactContext;
public ReactWebViewModule(ReactApplicationContext reactContext) {
public RNCWebViewModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}

View File

@ -1,5 +1,5 @@
package com.infinitered.webview;
package com.reactnativecommunity.webview;
import java.util.Arrays;
import java.util.Collections;
@ -10,10 +10,10 @@ import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.facebook.react.bridge.JavaScriptModule;
public class ReactWebViewPackage implements ReactPackage {
public class RNCWebViewPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new ReactWebViewModule(reactContext));
return Arrays.<NativeModule>asList(new RNCWebViewModule(reactContext));
}
// Deprecated from RN 0.47
@ -23,7 +23,7 @@ public class ReactWebViewPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
ReactWebViewManager viewManager = new ReactWebViewManager();
RNCWebViewManager viewManager = new RNCWebViewManager();
return Arrays.<ViewManager>asList(viewManager);
}
}

View File

@ -1,10 +1,10 @@
package com.infinitered.webview;
package com.reactnativecommunity.webview;
import android.webkit.WebView;
/**
* Implement this interface in order to config your {@link WebView}. An instance of that
* implementation will have to be given as a constructor argument to {@link ReactWebViewManager}.
* implementation will have to be given as a constructor argument to {@link RNCWebViewManager}.
*/
public interface WebViewConfig {

View File

@ -1,4 +1,4 @@
package com.infinitered.webview.events;
package com.reactnativecommunity.webview.events;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,4 +1,4 @@
package com.infinitered.webview.events;
package com.reactnativecommunity.webview.events;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,4 +1,4 @@
package com.infinitered.webview.events;
package com.reactnativecommunity.webview.events;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;

View File

@ -1,4 +1,4 @@
package com.infinitered.webview.events;
package com.reactnativecommunity.webview.events;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.Arguments;