Skip to content

Commit

Permalink
Fix rebase conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Sep 19, 2023
1 parent 227f9f1 commit d0747f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean shouldOverrideUrlLoading (WebView subview, String url) {

((RNCWebView) view).dispatchEvent(
view,
new TopOpenWindowEvent(view.getId(), event)
new TopOpenWindowEvent(RNCWebViewWrapper.getReactTagFromWebView(view), event)
);

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
package com.reactnativecommunity.webview;

import androidx.annotation.Nullable;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;

import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -21,33 +14,28 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.annotation.Nullable;

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerHelper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.ContentSizeChangeEvent;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.views.scroll.OnScrollDispatchHelper;
import com.facebook.react.views.scroll.ScrollEvent;
import com.facebook.react.views.scroll.ScrollEventType;
import com.reactnativecommunity.webview.events.TopCustomMenuSelectionEvent;
import com.reactnativecommunity.webview.events.TopLoadingProgressEvent;
import com.reactnativecommunity.webview.events.TopMessageEvent;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -194,7 +182,7 @@ public void onReceiveValue(String selectionJson) {
selectionText = new JSONObject(selectionJson).getString("selection");
} catch (JSONException ignored) {}
wMap.putString("selectedText", selectionText);
dispatchEvent(RNCWebView.this, new TopCustomMenuSelectionEvent(RNCWebView.this.getId(), wMap));
dispatchEvent(RNCWebView.this, new TopCustomMenuSelectionEvent(RNCWebViewWrapper.getReactTagFromWebView(RNCWebView.this), wMap));
mode.finish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void doUpdateVisitedHistory (WebView webView, String url, boolean isReloa
((RNCWebView) webView).dispatchEvent(
webView,
new TopLoadingStartEvent(
webView.getId(),
RNCWebViewWrapper.getReactTagFromWebView(webView),
createWebViewEvent(webView, url)));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.reactnativecommunity.webview

import android.app.DownloadManager
import android.content.Context
import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.graphics.Color
Expand All @@ -16,7 +15,6 @@ import android.webkit.CookieManager
import android.webkit.DownloadListener
import android.webkit.WebSettings
import android.webkit.WebView
import android.widget.FrameLayout
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import com.facebook.react.bridge.ReadableArray
Expand All @@ -29,7 +27,7 @@ import org.json.JSONObject
import java.io.UnsupportedEncodingException
import java.net.MalformedURLException
import java.net.URL
import java.util.*
import java.util.Locale

val invalidCharRegex = "[\\\\/%\"]".toRegex()

Expand Down Expand Up @@ -500,12 +498,12 @@ class RNCWebViewManagerImpl {
view.injectedJavaScriptBeforeContentLoadedForMainFrameOnly = value
}

fun setInjectedJavaScriptObject(view: RNCWebView, value: String?) {
fun setInjectedJavaScriptObject(viewWrapper: RNCWebViewWrapper, value: String?) {
val view = viewWrapper.webView
view.setInjectedJavaScriptObject(value)
}

fun setJavaScriptCanOpenWindowsAutomatically(view: RNCWebView, value: Boolean) {
fun setJavaScriptCanOpenWindowsAutomatically(viewWrapper: RNCWebViewWrapper, value: Boolean) {
val view = viewWrapper.webView
view.settings.javaScriptCanOpenWindowsAutomatically = value
}
Expand Down Expand Up @@ -619,13 +617,13 @@ class RNCWebViewManagerImpl {
mLackPermissionToDownloadMessage = value
}

fun setHasOnOpenWindowEvent(view: RNCWebView, value: Boolean) {
fun setHasOnOpenWindowEvent(viewWrapper: RNCWebViewWrapper, value: Boolean) {
val view = viewWrapper.webView
mHasOnOpenWindowEvent = value
setupWebChromeClient(view)
}

fun setMinimumFontSize(view: RNCWebView, value: Int) {
fun setMinimumFontSize(viewWrapper: RNCWebViewWrapper, value: Int) {
val view = viewWrapper.webView
view.settings.minimumFontSize = value
}
Expand All @@ -644,12 +642,12 @@ class RNCWebViewManagerImpl {
}
}

fun setMenuCustomItems(view: RNCWebView, value: ReadableArray) {
fun setMenuCustomItems(viewWrapper: RNCWebViewWrapper, value: ReadableArray) {
val view = viewWrapper.webView
view.setMenuCustomItems(value.toArrayList() as List<Map<String, String>>)
}

fun setNestedScrollEnabled(view: RNCWebView, value: Boolean) {
fun setNestedScrollEnabled(viewWrapper: RNCWebViewWrapper, value: Boolean) {
val view = viewWrapper.webView
view.nestedScrollEnabled = value
}
Expand Down Expand Up @@ -701,7 +699,7 @@ class RNCWebViewManagerImpl {
CookieManager.getInstance().setAcceptThirdPartyCookies(view, enabled)
}

fun setWebviewDebuggingEnabled(view: RNCWebView, enabled: Boolean) {
fun setWebviewDebuggingEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
RNCWebView.setWebContentsDebuggingEnabled(enabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(RNCWebViewW
}

@ReactProp(name = "injectedJavaScriptObject")
public void setInjectedJavaScriptObject(RNCWebView view, @Nullable String value) {
public void setInjectedJavaScriptObject(RNCWebViewWrapper view, @Nullable String value) {
mRNCWebViewManagerImpl.setInjectedJavaScriptObject(view, value);
}

Expand All @@ -209,7 +209,7 @@ public void setLackPermissionToDownloadMessage(RNCWebViewWrapper view, @Nullable

@Override
@ReactProp(name = "hasOnOpenWindowEvent")
public void setHasOnOpenWindowEvent(RNCWebView view, boolean hasEvent) {
public void setHasOnOpenWindowEvent(RNCWebViewWrapper view, boolean hasEvent) {
mRNCWebViewManagerImpl.setHasOnOpenWindowEvent(view, hasEvent);
}

Expand All @@ -221,13 +221,13 @@ public void setMediaPlaybackRequiresUserAction(RNCWebViewWrapper view, boolean v

@Override
@ReactProp(name = "menuItems")
public void setMenuItems(RNCWebView view, @Nullable ReadableArray items) {
public void setMenuItems(RNCWebViewWrapper view, @Nullable ReadableArray items) {
mRNCWebViewManagerImpl.setMenuCustomItems(view, items);
}

@Override
@ReactProp(name = "suppressMenuItems ")
public void setSuppressMenuItems(RNCWebView view, @Nullable ReadableArray items) {}
public void setSuppressMenuItems(RNCWebViewWrapper view, @Nullable ReadableArray items) {}

@Override
@ReactProp(name = "messagingEnabled")
Expand Down Expand Up @@ -327,7 +327,7 @@ public void setThirdPartyCookiesEnabled(RNCWebViewWrapper view, boolean value) {

@Override
@ReactProp(name = "webviewDebuggingEnabled")
public void setWebviewDebuggingEnabled(RNCWebView view, boolean value) {
public void setWebviewDebuggingEnabled(RNCWebViewWrapper view, boolean value) {
mRNCWebViewManagerImpl.setWebviewDebuggingEnabled(view, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public RNCWebViewWrapper createViewInstance(ThemedReactContext context) {
return mRNCWebViewManagerImpl.createViewInstance(context);
}

public RNCWebViewWrapper createViewInstance(ThemedReactContext context, RNCWebView webView) {
return mRNCWebViewManagerImpl.createViewInstance(context, webView);
public RNCWebViewWrapper createViewInstance(ThemedReactContext context, RNCWebViewWrapper view) {
return mRNCWebViewManagerImpl.createViewInstance(context, view.getWebView());
}

@ReactProp(name = "allowFileAccess")
Expand Down Expand Up @@ -149,7 +149,7 @@ public void setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(RNCWebViewW
}

@ReactProp(name = "injectedJavaScriptObject")
public void setInjectedJavaScriptObject(RNCWebView view, @Nullable String value) {
public void setInjectedJavaScriptObject(RNCWebViewWrapper view, @Nullable String value) {
mRNCWebViewManagerImpl.setInjectedJavaScriptObject(view, value);
}

Expand All @@ -169,7 +169,7 @@ public void setLackPermissionToDownloadMessage(RNCWebViewWrapper view, @Nullable
}

@ReactProp(name = "hasOnOpenWindowEvent")
public void setHasOnOpenWindowEvent(RNCWebView view, boolean hasEvent) {
public void setHasOnOpenWindowEvent(RNCWebViewWrapper view, boolean hasEvent) {
mRNCWebViewManagerImpl.setHasOnOpenWindowEvent(view, hasEvent);
}

Expand All @@ -184,7 +184,7 @@ public void setMessagingEnabled(RNCWebViewWrapper view, boolean value) {
}

@ReactProp(name = "menuItems")
public void setMenuCustomItems(RNCWebView view, @Nullable ReadableArray items) {
public void setMenuCustomItems(RNCWebViewWrapper view, @Nullable ReadableArray items) {
mRNCWebViewManagerImpl.setMenuCustomItems(view, items);
}

Expand Down Expand Up @@ -264,7 +264,7 @@ public void setThirdPartyCookiesEnabled(RNCWebViewWrapper view, boolean value) {
}

@ReactProp(name = "webviewDebuggingEnabled")
public void setWebviewDebuggingEnabled(RNCWebView view, boolean value) {
public void setWebviewDebuggingEnabled(RNCWebViewWrapper view, boolean value) {
mRNCWebViewManagerImpl.setWebviewDebuggingEnabled(view, value);
}

Expand Down

0 comments on commit d0747f9

Please sign in to comment.