From 5e2b479ce0c643d543a42cb0487a9d234c051d7b Mon Sep 17 00:00:00 2001 From: luancurti Date: Tue, 21 Jan 2020 15:04:04 -0300 Subject: [PATCH] chore: rename package --- android/src/main/AndroidManifest.xml | 4 +- .../RNCWKWebViewFileProvider.java} | 4 +- .../RNCWKWebViewManager.java} | 94 +++++++++---------- .../RNCWKWebViewModule.java} | 14 +-- .../RNCWKWebViewPackage.java} | 13 +-- .../{webview => wkwebview}/WebViewConfig.java | 4 +- .../events/TopHttpErrorEvent.kt | 2 +- .../events/TopLoadingErrorEvent.kt | 2 +- .../events/TopLoadingFinishEvent.kt | 2 +- .../events/TopLoadingProgressEvent.kt | 2 +- .../events/TopLoadingStartEvent.kt | 2 +- .../events/TopMessageEvent.kt | 2 +- .../TopShouldStartLoadWithRequestEvent.kt | 2 +- src/WebView.android.tsx | 16 ++-- src/WebView.ios.tsx | 18 ++-- src/WebViewTypes.ts | 6 +- 16 files changed, 91 insertions(+), 96 deletions(-) rename android/src/main/java/com/reactnativecommunity/{webview/RNCWebViewFileProvider.java => wkwebview/RNCWKWebViewFileProvider.java} (73%) rename android/src/main/java/com/reactnativecommunity/{webview/RNCWebViewManager.java => wkwebview/RNCWKWebViewManager.java} (93%) rename android/src/main/java/com/reactnativecommunity/{webview/RNCWebViewModule.java => wkwebview/RNCWKWebViewModule.java} (96%) rename android/src/main/java/com/reactnativecommunity/{webview/RNCWebViewPackage.java => wkwebview/RNCWKWebViewPackage.java} (57%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/WebViewConfig.java (77%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopHttpErrorEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopLoadingErrorEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopLoadingFinishEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopLoadingProgressEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopLoadingStartEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopMessageEvent.kt (93%) rename android/src/main/java/com/reactnativecommunity/{webview => wkwebview}/events/TopShouldStartLoadWithRequestEvent.kt (93%) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index b8f945d14..5e344052b 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,9 +1,9 @@ + package="com.reactnativecommunity.wkwebview"> diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewFileProvider.java similarity index 73% rename from android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java rename to android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewFileProvider.java index cadd8ed50..ad1443885 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewFileProvider.java +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewFileProvider.java @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview; +package com.reactnativecommunity.wkwebview; import androidx.core.content.FileProvider; @@ -7,7 +7,7 @@ *

* See https://developer.android.com/guide/topics/manifest/provider-element.html for details. */ -public class RNCWebViewFileProvider extends FileProvider { +public class RNCWKWebViewFileProvider extends FileProvider { // This class intentionally left blank. diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewManager.java similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java rename to android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewManager.java index 56a058620..08f8cbd43 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewManager.java @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview; +package com.reactnativecommunity.wkwebview; import android.annotation.SuppressLint; import android.annotation.TargetApi; @@ -57,13 +57,13 @@ import com.facebook.react.uimanager.events.ContentSizeChangeEvent; import com.facebook.react.uimanager.events.Event; import com.facebook.react.uimanager.events.EventDispatcher; -import com.reactnativecommunity.webview.events.TopLoadingErrorEvent; -import com.reactnativecommunity.webview.events.TopHttpErrorEvent; -import com.reactnativecommunity.webview.events.TopLoadingFinishEvent; -import com.reactnativecommunity.webview.events.TopLoadingProgressEvent; -import com.reactnativecommunity.webview.events.TopLoadingStartEvent; -import com.reactnativecommunity.webview.events.TopMessageEvent; -import com.reactnativecommunity.webview.events.TopShouldStartLoadWithRequestEvent; +import com.reactnativecommunity.wkwebview.events.TopLoadingErrorEvent; +import com.reactnativecommunity.wkwebview.events.TopHttpErrorEvent; +import com.reactnativecommunity.wkwebview.events.TopLoadingFinishEvent; +import com.reactnativecommunity.wkwebview.events.TopLoadingProgressEvent; +import com.reactnativecommunity.wkwebview.events.TopLoadingStartEvent; +import com.reactnativecommunity.wkwebview.events.TopMessageEvent; +import com.reactnativecommunity.wkwebview.events.TopShouldStartLoadWithRequestEvent; import org.json.JSONException; import org.json.JSONObject; @@ -103,8 +103,8 @@ * - 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 = RNCWebViewManager.REACT_CLASS) -public class RNCWebViewManager extends SimpleViewManager { +@ReactModule(name = RNCWKWebViewManager.REACT_CLASS) +public class RNCWKWebViewManager extends SimpleViewManager { public static String activeUrl = null; public static final int COMMAND_GO_BACK = 1; @@ -121,7 +121,7 @@ public class RNCWebViewManager extends SimpleViewManager { public static final int COMMAND_CLEAR_CACHE = 1001; public static final int COMMAND_CLEAR_HISTORY = 1002; - protected static final String REACT_CLASS = "RNCWebView"; + protected static final String REACT_CLASS = "RNCWKWebView"; protected static final String HTML_ENCODING = "UTF-8"; protected static final String HTML_MIME_TYPE = "text/html"; protected static final String JAVASCRIPT_INTERFACE = "ReactNativeWebView"; @@ -136,14 +136,14 @@ public class RNCWebViewManager extends SimpleViewManager { protected @Nullable String mUserAgent = null; protected @Nullable String mUserAgentWithApplicationName = null; - public RNCWebViewManager() { + public RNCWKWebViewManager() { mWebViewConfig = new WebViewConfig() { public void configWebView(WebView webView) { } }; } - public RNCWebViewManager(WebViewConfig webViewConfig) { + public RNCWKWebViewManager(WebViewConfig webViewConfig) { mWebViewConfig = webViewConfig; } @@ -159,14 +159,14 @@ public String getName() { return REACT_CLASS; } - protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) { - return new RNCWebView(reactContext); + protected RNCWKWebview createRNCWKWebviewInstance(ThemedReactContext reactContext) { + return new RNCWKWebview(reactContext); } @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected WebView createViewInstance(ThemedReactContext reactContext) { - RNCWebView webView = createRNCWebViewInstance(reactContext); + RNCWKWebview webView = createRNCWKWebviewInstance(reactContext); setupWebChromeClient(reactContext, webView); reactContext.addLifecycleEventListener(webView); mWebViewConfig.configWebView(webView); @@ -194,7 +194,7 @@ protected WebView createViewInstance(ThemedReactContext reactContext) { webView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { - RNCWebViewModule module = getModule(reactContext); + RNCWKWebViewModule module = getModule(reactContext); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); @@ -389,12 +389,12 @@ public void setSaveFormDataDisabled(WebView view, boolean disable) { @ReactProp(name = "injectedJavaScript") public void setInjectedJavaScript(WebView view, @Nullable String injectedJavaScript) { - ((RNCWebView) view).setInjectedJavaScript(injectedJavaScript); + ((RNCWKWebview) view).setInjectedJavaScript(injectedJavaScript); } @ReactProp(name = "messagingEnabled") public void setMessagingEnabled(WebView view, boolean enabled) { - ((RNCWebView) view).setMessagingEnabled(enabled); + ((RNCWKWebview) view).setMessagingEnabled(enabled); } @ReactProp(name = "incognito") @@ -476,7 +476,7 @@ public void setSource(WebView view, @Nullable ReadableMap source) { @ReactProp(name = "onContentSizeChange") public void setOnContentSizeChange(WebView view, boolean sendContentSizeChangeEvents) { - ((RNCWebView) view).setSendContentSizeChangeEvents(sendContentSizeChangeEvents); + ((RNCWKWebview) view).setSendContentSizeChangeEvents(sendContentSizeChangeEvents); } @ReactProp(name = "mixedContentMode") @@ -496,7 +496,7 @@ public void setMixedContentMode(WebView view, @Nullable String mixedContentMode) public void setUrlPrefixesForDefaultIntent( WebView view, @Nullable ReadableArray urlPrefixesForDefaultIntent) { - RNCWebViewClient client = ((RNCWebView) view).getRNCWebViewClient(); + RNCWKWebviewClient client = ((RNCWKWebview) view).getRNCWKWebviewClient(); if (client != null && urlPrefixesForDefaultIntent != null) { client.setUrlPrefixesForDefaultIntent(urlPrefixesForDefaultIntent); } @@ -526,13 +526,13 @@ public void setGeolocationEnabled( @ReactProp(name = "onScroll") public void setOnScroll(WebView view, boolean hasScrollEvent) { - ((RNCWebView) view).setHasScrollEvent(hasScrollEvent); + ((RNCWKWebview) view).setHasScrollEvent(hasScrollEvent); } @Override protected void addEventEmitters(ThemedReactContext reactContext, WebView view) { // Do not register default touch emitter and let WebView implementation handle touches - view.setWebViewClient(new RNCWebViewClient()); + view.setWebViewClient(new RNCWKWebviewClient()); } @Override @@ -583,7 +583,7 @@ public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray break; case COMMAND_POST_MESSAGE: try { - RNCWebView reactWebView = (RNCWebView) root; + RNCWKWebview reactWebView = (RNCWKWebview) root; JSONObject eventInitDict = new JSONObject(); eventInitDict.put("data", args.getString(0)); reactWebView.evaluateJavascriptWithFallback("(function () {" + @@ -602,7 +602,7 @@ public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray } break; case COMMAND_INJECT_JAVASCRIPT: - RNCWebView reactWebView = (RNCWebView) root; + RNCWKWebview reactWebView = (RNCWKWebview) root; reactWebView.evaluateJavascriptWithFallback(args.getString(0)); break; case COMMAND_LOAD_URL: @@ -630,12 +630,12 @@ public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray @Override public void onDropViewInstance(WebView webView) { super.onDropViewInstance(webView); - ((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RNCWebView) webView); - ((RNCWebView) webView).cleanupCallbacksAndDestroy(); + ((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RNCWKWebview) webView); + ((RNCWKWebview) webView).cleanupCallbacksAndDestroy(); } - public static RNCWebViewModule getModule(ReactContext reactContext) { - return reactContext.getNativeModule(RNCWebViewModule.class); + public static RNCWKWebViewModule getModule(ReactContext reactContext) { + return reactContext.getNativeModule(RNCWKWebViewModule.class); } protected void setupWebChromeClient(ReactContext reactContext, WebView webView) { @@ -709,7 +709,7 @@ public Bitmap getDefaultVideoPoster() { } } - protected static class RNCWebViewClient extends WebViewClient { + protected static class RNCWKWebviewClient extends WebViewClient { protected boolean mLastLoadFailed = false; protected @Nullable @@ -720,7 +720,7 @@ public void onPageFinished(WebView webView, String url) { super.onPageFinished(webView, url); if (!mLastLoadFailed) { - RNCWebView reactWebView = (RNCWebView) webView; + RNCWKWebview reactWebView = (RNCWKWebview) webView; reactWebView.callInjectedJavaScript(); @@ -968,12 +968,12 @@ protected ViewGroup getRootView() { * 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 RNCWebView extends WebView implements LifecycleEventListener { + protected static class RNCWKWebview extends WebView implements LifecycleEventListener { protected @Nullable String injectedJS; protected boolean messagingEnabled = false; protected @Nullable - RNCWebViewClient mRNCWebViewClient; + RNCWKWebviewClient mRNCWKWebviewClient; protected boolean sendContentSizeChangeEvents = false; private OnScrollDispatchHelper mOnScrollDispatchHelper; protected boolean hasScrollEvent = false; @@ -984,7 +984,7 @@ protected static class RNCWebView extends WebView implements LifecycleEventListe * Activity Context is required for creation of dialogs internally by WebView * Reactive Native needed for access to ReactNative internal system functionality */ - public RNCWebView(ThemedReactContext reactContext) { + public RNCWKWebview(ThemedReactContext reactContext) { super(reactContext); } @@ -1030,22 +1030,22 @@ protected void onSizeChanged(int w, int h, int ow, int oh) { @Override public void setWebViewClient(WebViewClient client) { super.setWebViewClient(client); - if (client instanceof RNCWebViewClient) { - mRNCWebViewClient = (RNCWebViewClient) client; + if (client instanceof RNCWKWebviewClient) { + mRNCWKWebviewClient = (RNCWKWebviewClient) client; } } public @Nullable - RNCWebViewClient getRNCWebViewClient() { - return mRNCWebViewClient; + RNCWKWebviewClient getRNCWKWebviewClient() { + return mRNCWKWebviewClient; } public void setInjectedJavaScript(@Nullable String js) { injectedJS = js; } - protected RNCWebViewBridge createRNCWebViewBridge(RNCWebView webView) { - return new RNCWebViewBridge(webView); + protected RNCWKWebviewBridge createRNCWKWebviewBridge(RNCWKWebview webView) { + return new RNCWKWebviewBridge(webView); } @SuppressLint("AddJavascriptInterface") @@ -1057,7 +1057,7 @@ public void setMessagingEnabled(boolean enabled) { messagingEnabled = enabled; if (enabled) { - addJavascriptInterface(createRNCWebViewBridge(this), JAVASCRIPT_INTERFACE); + addJavascriptInterface(createRNCWKWebviewBridge(this), JAVASCRIPT_INTERFACE); } else { removeJavascriptInterface(JAVASCRIPT_INTERFACE); } @@ -1086,15 +1086,15 @@ public void callInjectedJavaScript() { } public void onMessage(String message) { - if (mRNCWebViewClient != null) { + if (mRNCWKWebviewClient != null) { WebView webView = this; webView.post(new Runnable() { @Override public void run() { - if (mRNCWebViewClient == null) { + if (mRNCWKWebviewClient == null) { return; } - WritableMap data = mRNCWebViewClient.createWebViewEvent(webView, webView.getUrl()); + WritableMap data = mRNCWKWebviewClient.createWebViewEvent(webView, webView.getUrl()); data.putString("data", message); dispatchEvent(webView, new TopMessageEvent(webView.getId(), data)); } @@ -1139,10 +1139,10 @@ protected void cleanupCallbacksAndDestroy() { destroy(); } - protected class RNCWebViewBridge { - RNCWebView mContext; + protected class RNCWKWebviewBridge { + RNCWKWebview mContext; - RNCWebViewBridge(RNCWebView c) { + RNCWKWebviewBridge(RNCWKWebview c) { mContext = c; } diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewModule.java similarity index 96% rename from android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java rename to android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewModule.java index b730535b9..6cbed3d10 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewModule.java @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview; +package com.reactnativecommunity.wkwebview; import android.Manifest; import android.app.Activity; @@ -35,9 +35,9 @@ import static android.app.Activity.RESULT_OK; -@ReactModule(name = RNCWebViewModule.MODULE_NAME) -public class RNCWebViewModule extends ReactContextBaseJavaModule implements ActivityEventListener { - public static final String MODULE_NAME = "RNCWebView"; +@ReactModule(name = RNCWKWebViewModule.MODULE_NAME) +public class RNCWKWebViewModule extends ReactContextBaseJavaModule implements ActivityEventListener { + public static final String MODULE_NAME = "RNCWKWebView"; private static final int PICKER = 1; private static final int PICKER_LEGACY = 3; private static final int FILE_DOWNLOAD_PERMISSION_REQUEST = 1; @@ -66,7 +66,7 @@ public boolean onRequestPermissionsResult(int requestCode, String[] permissions, } }; - public RNCWebViewModule(ReactApplicationContext reactContext) { + public RNCWKWebViewModule(ReactApplicationContext reactContext) { super(reactContext); reactContext.addActivityEventListener(this); } @@ -171,7 +171,7 @@ public void startPhotoPickerIntent(ValueCallback filePathCallback, String a if (chooserIntent.resolveActivity(getCurrentActivity().getPackageManager()) != null) { getCurrentActivity().startActivityForResult(chooserIntent, PICKER_LEGACY); } else { - Log.w("RNCWebViewModule", "there is no Activity to handle this Intent"); + Log.w("RNCWKWebViewModule", "there is no Activity to handle this Intent"); } } @@ -196,7 +196,7 @@ public boolean startPhotoPickerIntent(final ValueCallback callback, final if (chooserIntent.resolveActivity(getCurrentActivity().getPackageManager()) != null) { getCurrentActivity().startActivityForResult(chooserIntent, PICKER); } else { - Log.w("RNCWebViewModule", "there is no Activity to handle this Intent"); + Log.w("RNCWKWebViewModule", "there is no Activity to handle this Intent"); } return true; diff --git a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewPackage.java similarity index 57% rename from android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java rename to android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewPackage.java index e75edf40d..ffde70b34 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewPackage.java +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/RNCWKWebViewPackage.java @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview; +package com.reactnativecommunity.wkwebview; import com.facebook.react.ReactPackage; import com.facebook.react.bridge.JavaScriptModule; @@ -9,19 +9,14 @@ import java.util.Collections; import java.util.List; -public class RNCWebViewPackage implements ReactPackage { +public class RNCWKWebViewPackage implements ReactPackage { @Override public List createNativeModules(ReactApplicationContext reactContext) { - return Collections.singletonList(new RNCWebViewModule(reactContext)); - } - - // Deprecated from RN 0.47 - public List> createJSModules() { - return Collections.emptyList(); + return Collections.singletonList(new RNCWKWebViewModule(reactContext)); } @Override public List createViewManagers(ReactApplicationContext reactContext) { - return Collections.singletonList(new RNCWebViewManager()); + return Collections.singletonList(new RNCWKWebViewManager()); } } diff --git a/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java b/android/src/main/java/com/reactnativecommunity/wkwebview/WebViewConfig.java similarity index 77% rename from android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java rename to android/src/main/java/com/reactnativecommunity/wkwebview/WebViewConfig.java index ac917db26..61a667371 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/WebViewConfig.java +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/WebViewConfig.java @@ -1,10 +1,10 @@ -package com.reactnativecommunity.webview; +package com.reactnativecommunity.wkwebview; 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 RNCWebViewManager}. + * implementation will have to be given as a constructor argument to {@link RNCWKWebViewManager}. */ public interface WebViewConfig { diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopHttpErrorEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopHttpErrorEvent.kt index 15aa08945..ef483830c 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopHttpErrorEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopHttpErrorEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingErrorEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingErrorEvent.kt index 7f5096db1..6f66d8978 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingErrorEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingErrorEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingFinishEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingFinishEvent.kt index 20da841d6..866f11641 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingFinishEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingFinishEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingProgressEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingProgressEvent.kt index 0d46970a1..8f926179a 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingProgressEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingProgressEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingStartEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingStartEvent.kt index cac21a22d..1dc34265d 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopLoadingStartEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopLoadingStartEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopMessageEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopMessageEvent.kt index c53837dcb..ab49f6532 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopMessageEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopMessageEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopShouldStartLoadWithRequestEvent.kt similarity index 93% rename from android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt rename to android/src/main/java/com/reactnativecommunity/wkwebview/events/TopShouldStartLoadWithRequestEvent.kt index 0f80cedfc..f4360a672 100644 --- a/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.kt +++ b/android/src/main/java/com/reactnativecommunity/wkwebview/events/TopShouldStartLoadWithRequestEvent.kt @@ -1,4 +1,4 @@ -package com.reactnativecommunity.webview.events +package com.reactnativecommunity.wkwebview.events import com.facebook.react.bridge.WritableMap import com.facebook.react.uimanager.events.Event diff --git a/src/WebView.android.tsx b/src/WebView.android.tsx index 4a06cdb48..6f3e3dd29 100644 --- a/src/WebView.android.tsx +++ b/src/WebView.android.tsx @@ -27,15 +27,15 @@ import { AndroidWebViewProps, NativeWebViewAndroid, State, - RNCWebViewUIManagerAndroid, + RNCWKWebViewUIManagerAndroid, } from './WebViewTypes'; import styles from './WebView.styles'; -const UIManager = NotTypedUIManager as RNCWebViewUIManagerAndroid; +const UIManager = NotTypedUIManager as RNCWKWebViewUIManagerAndroid; -const RNCWebView = requireNativeComponent( - 'RNCWebView', +const RNCWKWebView = requireNativeComponent( + 'RNCWKWebView', ) as typeof NativeWebViewAndroid; const { resolveAssetSource } = Image; @@ -58,7 +58,7 @@ class WebView extends React.Component { static isFileUploadSupported = async () => { // native implementation should return "true" only for Android 5+ - return NativeModules.RNCWebView.isFileUploadSupported(); + return NativeModules.RNCWKWebView.isFileUploadSupported(); }; startUrl: string | null = null; @@ -70,7 +70,7 @@ class WebView extends React.Component { webViewRef = React.createRef(); - getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands; + getCommands = () => UIManager.getViewManagerConfig('RNCWKWebView').Commands; goForward = () => { UIManager.dispatchViewManagerCommand( @@ -295,7 +295,7 @@ class WebView extends React.Component { ); } else if (this.state.viewState !== 'IDLE') { console.error( - `RNCWebView invalid state encountered: ${this.state.viewState}`, + `RNCWKWebView invalid state encountered: ${this.state.viewState}`, ); } @@ -313,7 +313,7 @@ class WebView extends React.Component { } const NativeWebView - = (nativeConfig.component as typeof NativeWebViewAndroid) || RNCWebView; + = (nativeConfig.component as typeof NativeWebViewAndroid) || RNCWKWebView; const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest( this.onShouldStartLoadWithRequestCallback, diff --git a/src/WebView.ios.tsx b/src/WebView.ios.tsx index 243f81585..4642d4d02 100644 --- a/src/WebView.ios.tsx +++ b/src/WebView.ios.tsx @@ -28,12 +28,12 @@ import { NativeWebViewIOS, ViewManager, State, - RNCWebViewUIManagerIOS, + RNCWKWebViewUIManagerIOS, } from './WebViewTypes'; import styles from './WebView.styles'; -const UIManager = NotTypedUIManager as RNCWebViewUIManagerIOS; +const UIManager = NotTypedUIManager as RNCWKWebViewUIManagerIOS; const { resolveAssetSource } = Image; const processDecelerationRate = ( @@ -48,10 +48,10 @@ const processDecelerationRate = ( return newDecelerationRate; }; -const RNCWebViewManager = NativeModules.RNCWebViewManager as ViewManager; +const RNCWKWebViewManager = NativeModules.RNCWKWebViewManager as ViewManager; -const RNCWebView: typeof NativeWebViewIOS = requireNativeComponent( - 'RNCWebView', +const RNCWKWebView: typeof NativeWebViewIOS = requireNativeComponent( + 'RNCWKWebView', ); class WebView extends React.Component { @@ -75,7 +75,7 @@ class WebView extends React.Component { webViewRef = React.createRef(); // eslint-disable-next-line react/sort-comp - getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands; + getCommands = () => UIManager.getViewManagerConfig('RNCWKWebView').Commands; /** * Go forward one page in the web view's history. @@ -251,7 +251,7 @@ class WebView extends React.Component { ) => { const viewManager = (this.props.nativeConfig && this.props.nativeConfig.viewManager) - || RNCWebViewManager; + || RNCWKWebViewManager; viewManager.startLoadWithResult(!!shouldStart, lockIdentifier); }; @@ -309,7 +309,7 @@ class WebView extends React.Component { ); } else if (this.state.viewState !== 'IDLE') { console.error( - `RNCWebView invalid state encountered: ${this.state.viewState}`, + `RNCWKWebView invalid state encountered: ${this.state.viewState}`, ); } @@ -327,7 +327,7 @@ class WebView extends React.Component { const NativeWebView = (nativeConfig.component as typeof NativeWebViewIOS | undefined) - || RNCWebView; + || RNCWKWebView; const webView = ( extends UIManagerStatic { +interface RNCWKWebViewUIManager extends UIManagerStatic { getViewManagerConfig: ( name: string, ) => { @@ -26,8 +26,8 @@ interface RNCWebViewUIManager extends UIManagerStatic { }; } -export type RNCWebViewUIManagerAndroid = RNCWebViewUIManager -export type RNCWebViewUIManagerIOS = RNCWebViewUIManager +export type RNCWKWebViewUIManagerAndroid = RNCWKWebViewUIManager +export type RNCWKWebViewUIManagerIOS = RNCWKWebViewUIManager