diff --git a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java rename to android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java index 84d1141..39770b8 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java @@ -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 { +@ReactModule(name = RNCWebViewManager.REACT_CLASS) +public class RNCWebViewManager extends SimpleViewManager { - 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 { 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 { 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 { * 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 { * 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 { @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 { 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 { } } - 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 { 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 { @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 { 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 { public void setOriginWhitelist( WebView view, @Nullable ReadableArray originWhitelist) { - RCTWebViewClient client = ((RCTWebView) view).getRCTWebViewClient(); + RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient(); if (client != null && originWhitelist != null) { List whiteList = new LinkedList<>(); for (int i = 0 ; i < originWhitelist.size() ; i++) { @@ -620,7 +620,7 @@ public class RCTWebViewManager extends SimpleViewManager { @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 { 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 { } 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 { @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() { diff --git a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewModule.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java similarity index 73% rename from android/src/main/java/com/reactnativecommunity/webview/RCTWebViewModule.java rename to android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java index a3eeb6b..b93d992 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewModule.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java @@ -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"; } } \ No newline at end of file diff --git a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewPackage.java b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java similarity index 81% rename from android/src/main/java/com/reactnativecommunity/webview/RCTWebViewPackage.java rename to android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java index 6dee338..60ee9f6 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RCTWebViewPackage.java +++ b/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java @@ -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 createNativeModules(ReactApplicationContext reactContext) { - return Arrays.asList(new RCTWebViewModule(reactContext)); + return Arrays.asList(new RNCWebViewModule(reactContext)); } // Deprecated from RN 0.47 @@ -23,7 +23,7 @@ public class RCTWebViewPackage implements ReactPackage { @Override public List createViewManagers(ReactApplicationContext reactContext) { - RCTWebViewManager viewManager = new RCTWebViewManager(); + RNCWebViewManager viewManager = new RNCWebViewManager(); return Arrays.asList(viewManager); } } \ No newline at end of file diff --git a/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java b/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java index 67e6fc9..ac917db 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java +++ b/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java @@ -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 { diff --git a/js/WebView.android.js b/js/WebView.android.js index 2e38c1b..8ae324a 100644 --- a/js/WebView.android.js +++ b/js/WebView.android.js @@ -101,7 +101,7 @@ class WebView extends React.Component { ); } 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 { WebViewShared.originWhitelistToRegex, ); - let NativeWebView = nativeConfig.component || RCTWebView; + let NativeWebView = nativeConfig.component || RNCWebView; const webView = ( { goForward = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RCTWebView.Commands.goForward, + UIManager.RNCWebView.Commands.goForward, null, ); }; @@ -195,7 +195,7 @@ class WebView extends React.Component { goBack = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RCTWebView.Commands.goBack, + UIManager.RNCWebView.Commands.goBack, null, ); }; @@ -206,7 +206,7 @@ class WebView extends React.Component { }); UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RCTWebView.Commands.reload, + UIManager.RNCWebView.Commands.reload, null, ); }; @@ -214,7 +214,7 @@ class WebView extends React.Component { stopLoading = () => { UIManager.dispatchViewManagerCommand( this.getWebViewHandle(), - UIManager.RCTWebView.Commands.stopLoading, + UIManager.RNCWebView.Commands.stopLoading, null, ); }; @@ -222,7 +222,7 @@ class WebView extends React.Component { 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 { 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 { }; } -const RCTWebView = requireNativeComponent('RCTWebView'); +const RNCWebView = requireNativeComponent('RNCWebView'); const styles = StyleSheet.create({ container: {