Renamed RNC on android too to stay consistent with iOS

This commit is contained in:
Thibault Malbranche 2018-09-19 01:19:06 +02:00
parent 68ca85141a
commit fcc35cec09
5 changed files with 47 additions and 47 deletions

View File

@ -84,10 +84,10 @@ 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 = RCTWebViewManager.REACT_CLASS)
public class RCTWebViewManager extends SimpleViewManager<WebView> {
@ReactModule(name = RNCWebViewManager.REACT_CLASS)
public class RNCWebViewManager extends SimpleViewManager<WebView> {
protected static final String REACT_CLASS = "RCTWebView";
protected static final String REACT_CLASS = "RNCWebView";
protected static final String HTML_ENCODING = "UTF-8";
protected static final String HTML_MIME_TYPE = "text/html";
@ -109,7 +109,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
protected WebViewConfig mWebViewConfig;
protected @Nullable WebView.PictureListener mPictureListener;
protected static class RCTWebViewClient extends WebViewClient {
protected static class RNCWebViewClient extends WebViewClient {
protected boolean mLastLoadFailed = false;
protected @Nullable ReadableArray mUrlPrefixesForDefaultIntent;
@ -120,7 +120,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
super.onPageFinished(webView, url);
if (!mLastLoadFailed) {
RCTWebView reactWebView = (RCTWebView) webView;
RNCWebView reactWebView = (RNCWebView) webView;
reactWebView.callInjectedJavaScript();
reactWebView.linkBridge();
emitFinishEvent(webView, url);
@ -243,15 +243,15 @@ public class RCTWebViewManager 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 RCTWebView extends WebView implements LifecycleEventListener {
protected static class RNCWebView extends WebView implements LifecycleEventListener {
protected @Nullable String injectedJS;
protected boolean messagingEnabled = false;
protected @Nullable RCTWebViewClient mRCTWebViewClient;
protected @Nullable RNCWebViewClient mRNCWebViewClient;
protected class RCTWebViewBridge {
RCTWebView mContext;
protected class RNCWebViewBridge {
RNCWebView mContext;
RCTWebViewBridge(RCTWebView c) {
RNCWebViewBridge(RNCWebView c) {
mContext = c;
}
@ -268,7 +268,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
* Reactive Native needed for access to ReactNative internal system functionality
*
*/
public RCTWebView(ThemedReactContext reactContext) {
public RNCWebView(ThemedReactContext reactContext) {
super(reactContext);
}
@ -290,19 +290,19 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
@Override
public void setWebViewClient(WebViewClient client) {
super.setWebViewClient(client);
mRCTWebViewClient = (RCTWebViewClient)client;
mRNCWebViewClient = (RNCWebViewClient)client;
}
public @Nullable RCTWebViewClient getRCTWebViewClient() {
return mRCTWebViewClient;
public @Nullable RNCWebViewClient getRNCWebViewClient() {
return mRNCWebViewClient;
}
public void setInjectedJavaScript(@Nullable String js) {
injectedJS = js;
}
protected RCTWebViewBridge createRCTWebViewBridge(RCTWebView webView) {
return new RCTWebViewBridge(webView);
protected RNCWebViewBridge createRNCWebViewBridge(RNCWebView webView) {
return new RNCWebViewBridge(webView);
}
public void setMessagingEnabled(boolean enabled) {
@ -312,7 +312,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
messagingEnabled = enabled;
if (enabled) {
addJavascriptInterface(createRCTWebViewBridge(this), BRIDGE_NAME);
addJavascriptInterface(createRNCWebViewBridge(this), BRIDGE_NAME);
linkBridge();
} else {
removeJavascriptInterface(BRIDGE_NAME);
@ -375,14 +375,14 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
}
}
public RCTWebViewManager() {
public RNCWebViewManager() {
mWebViewConfig = new WebViewConfig() {
public void configWebView(WebView webView) {
}
};
}
public RCTWebViewManager(WebViewConfig webViewConfig) {
public RNCWebViewManager(WebViewConfig webViewConfig) {
mWebViewConfig = webViewConfig;
}
@ -391,14 +391,14 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
return REACT_CLASS;
}
protected RCTWebView createRCTWebViewInstance(ThemedReactContext reactContext) {
return new RCTWebView(reactContext);
protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) {
return new RNCWebView(reactContext);
}
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected WebView createViewInstance(ThemedReactContext reactContext) {
RCTWebView webView = createRCTWebViewInstance(reactContext);
RNCWebView webView = createRNCWebViewInstance(reactContext);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage message) {
@ -489,12 +489,12 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
@ReactProp(name = "injectedJavaScript")
public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) {
((RCTWebView) view).setInjectedJavaScript(injectedJavaScript);
((RNCWebView) view).setInjectedJavaScript(injectedJavaScript);
}
@ReactProp(name = "messagingEnabled")
public void setMessagingEnabled(WebView view, boolean enabled) {
((RCTWebView) view).setMessagingEnabled(enabled);
((RNCWebView) view).setMessagingEnabled(enabled);
}
@ReactProp(name = "source")
@ -583,7 +583,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
public void setUrlPrefixesForDefaultIntent(
WebView view,
@Nullable ReadableArray urlPrefixesForDefaultIntent) {
RCTWebViewClient client = ((RCTWebView) view).getRCTWebViewClient();
RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient();
if (client != null && urlPrefixesForDefaultIntent != null) {
client.setUrlPrefixesForDefaultIntent(urlPrefixesForDefaultIntent);
}
@ -607,7 +607,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
public void setOriginWhitelist(
WebView view,
@Nullable ReadableArray originWhitelist) {
RCTWebViewClient client = ((RCTWebView) view).getRCTWebViewClient();
RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient();
if (client != null && originWhitelist != null) {
List<Pattern> whiteList = new LinkedList<>();
for (int i = 0 ; i < originWhitelist.size() ; i++) {
@ -620,7 +620,7 @@ public class RCTWebViewManager 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 RCTWebViewClient());
view.setWebViewClient(new RNCWebViewClient());
}
@Override
@ -652,7 +652,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
break;
case COMMAND_POST_MESSAGE:
try {
RCTWebView reactWebView = (RCTWebView) root;
RNCWebView reactWebView = (RNCWebView) root;
JSONObject eventInitDict = new JSONObject();
eventInitDict.put("data", args.getString(0));
reactWebView.evaluateJavascriptWithFallback("(function () {" +
@ -671,7 +671,7 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
}
break;
case COMMAND_INJECT_JAVASCRIPT:
RCTWebView reactWebView = (RCTWebView) root;
RNCWebView reactWebView = (RNCWebView) root;
reactWebView.evaluateJavascriptWithFallback(args.getString(0));
break;
}
@ -680,8 +680,8 @@ public class RCTWebViewManager extends SimpleViewManager<WebView> {
@Override
public void onDropViewInstance(WebView webView) {
super.onDropViewInstance(webView);
((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RCTWebView) webView);
((RCTWebView) webView).cleanupCallbacksAndDestroy();
((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RNCWebView) webView);
((RNCWebView) webView).cleanupCallbacksAndDestroy();
}
protected WebView.PictureListener getPictureListener() {

View File

@ -6,17 +6,17 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
public class RCTWebViewModule extends ReactContextBaseJavaModule {
public class RNCWebViewModule extends ReactContextBaseJavaModule {
private final ReactApplicationContext reactContext;
public RCTWebViewModule(ReactApplicationContext reactContext) {
public RNCWebViewModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}
@Override
public String getName() {
return "RCTWebView";
return "RNCWebView";
}
}

View File

@ -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 RCTWebViewPackage implements ReactPackage {
public class RNCWebViewPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RCTWebViewModule(reactContext));
return Arrays.<NativeModule>asList(new RNCWebViewModule(reactContext));
}
// Deprecated from RN 0.47
@ -23,7 +23,7 @@ public class RCTWebViewPackage implements ReactPackage {
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
RCTWebViewManager viewManager = new RCTWebViewManager();
RNCWebViewManager viewManager = new RNCWebViewManager();
return Arrays.<ViewManager>asList(viewManager);
}
}

View File

@ -4,7 +4,7 @@ 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 RCTWebViewManager}.
* implementation will have to be given as a constructor argument to {@link RNCWebViewManager}.
*/
public interface WebViewConfig {

View File

@ -101,7 +101,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
);
} else if (this.state.viewState !== WebViewState.IDLE) {
console.error(
'RCTWebView invalid state encountered: ' + this.state.viewState,
'RNCWebView invalid state encountered: ' + this.state.viewState,
);
}
@ -135,7 +135,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
WebViewShared.originWhitelistToRegex,
);
let NativeWebView = nativeConfig.component || RCTWebView;
let NativeWebView = nativeConfig.component || RNCWebView;
const webView = (
<NativeWebView
@ -187,7 +187,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
goForward = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.goForward,
UIManager.RNCWebView.Commands.goForward,
null,
);
};
@ -195,7 +195,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
goBack = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.goBack,
UIManager.RNCWebView.Commands.goBack,
null,
);
};
@ -206,7 +206,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
});
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.reload,
UIManager.RNCWebView.Commands.reload,
null,
);
};
@ -214,7 +214,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
stopLoading = () => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.stopLoading,
UIManager.RNCWebView.Commands.stopLoading,
null,
);
};
@ -222,7 +222,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
postMessage = (data: string) => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.postMessage,
UIManager.RNCWebView.Commands.postMessage,
[String(data)],
);
};
@ -236,7 +236,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
injectJavaScript = (data: string) => {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.injectJavaScript,
UIManager.RNCWebView.Commands.injectJavaScript,
[data],
);
};
@ -290,7 +290,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
};
}
const RCTWebView = requireNativeComponent('RCTWebView');
const RNCWebView = requireNativeComponent('RNCWebView');
const styles = StyleSheet.create({
container: {