Use community WebView

Signed-off-by: Vitaliy Vlasov <siphiuel@gmail.com>
This commit is contained in:
Vitaliy Vlasov 2020-02-12 15:09:45 +02:00
parent 86d85df5d3
commit 85d0022b26
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
23 changed files with 73 additions and 101 deletions

View File

@ -284,6 +284,7 @@ android {
} }
dependencies { dependencies {
implementation project(':react-native-webview')
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules implementation "com.facebook.react:react-native:+" // From node_modules
@ -307,7 +308,6 @@ dependencies {
// NOTE: Uncomment if building RN from a fork // NOTE: Uncomment if building RN from a fork
//compile ("com.facebook.react:react-native:0.55.4") { force = true } // From node_modules //compile ("com.facebook.react:react-native:0.55.4") { force = true } // From node_modules
implementation project(':react-native-status') implementation project(':react-native-status')
implementation project(':react-native-webview-bridge')
implementation project(':react-native-status-keycard') implementation project(':react-native-status-keycard')
implementation 'com.github.status-im:function:0.0.1' implementation 'com.github.status-im:function:0.0.1'
implementation 'com.facebook.fresco:fresco:2.0.0' implementation 'com.facebook.fresco:fresco:2.0.0'

View File

@ -230,10 +230,6 @@ public class MainActivity extends ReactFragmentActivity
if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) { if (mPermissionListener != null && mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
mPermissionListener = null; mPermissionListener = null;
} }
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Permission has been granted. Start camera preview Activity.
com.github.alinz.reactnativewebviewbridge.WebViewBridgeManager.grantAccess(requestCode);
}
} }
@Override @Override

View File

@ -8,10 +8,10 @@ import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.aakashns.reactnativedialogs.ReactNativeDialogsPackage; import com.aakashns.reactnativedialogs.ReactNativeDialogsPackage;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage; import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import com.github.alinz.reactnativewebviewbridge.WebViewBridgePackage;
import java.util.List; import java.util.List;
@ -33,7 +33,6 @@ public class MainApplication extends MultiDexApplication implements ReactApplica
packages.add(statusPackage); packages.add(statusPackage);
packages.add(new ReactNativeDialogsPackage()); packages.add(new ReactNativeDialogsPackage());
packages.add(new RNStatusKeycardPackage()); packages.add(new RNStatusKeycardPackage());
packages.add(new WebViewBridgePackage(BuildConfig.DEBUG_WEBVIEW == "1"));
return packages; return packages;
} }

View File

@ -21,6 +21,7 @@
# $keytool -genkey -v -keystore ./status-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias status # $keytool -genkey -v -keystore ./status-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias status
# Version requirements used throughout the Gradle scripts # Version requirements used throughout the Gradle scripts
kotlinVersion=1.3.11
minSdkVersion=23 minSdkVersion=23
compileSdkVersion=29 compileSdkVersion=29
targetSdkVersion=29 targetSdkVersion=29

View File

@ -1,4 +1,6 @@
pluginManagement { pluginManagement {
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
repositories { repositories {
mavenLocal() // Let's prioritize local Maven repos so that Nix can provide them offline mavenLocal() // Let's prioritize local Maven repos so that Nix can provide them offline
gradlePluginPortal() gradlePluginPortal()
@ -16,5 +18,3 @@ include ':react-native-status'
project(':react-native-status').projectDir = new File(rootProject.projectDir, '../modules/react-native-status/android') project(':react-native-status').projectDir = new File(rootProject.projectDir, '../modules/react-native-status/android')
include ':react-native-status-keycard' include ':react-native-status-keycard'
project(':react-native-status-keycard').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-status-keycard/android') project(':react-native-status-keycard').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-status-keycard/android')
include ':react-native-webview-bridge'
project(':react-native-webview-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-bridge/android')

View File

@ -18,7 +18,7 @@
"react-native-image-resizer" "react-native-image-resizer"
"react-native-image-crop-picker" "react-native-image-crop-picker"
"react-native-svg" "react-native-svg"
"react-native-webview-bridge" "react-native-webview"
"react-native-touch-id" "react-native-touch-id"
"web3-utils" "web3-utils"
"chance" "chance"

View File

@ -563,7 +563,6 @@ var TopLevel = {
"FlatList" : function () {}, "FlatList" : function () {},
"warn" : function () {}, "warn" : function () {},
"WebView" : function () {}, "WebView" : function () {},
"WebViewBridgeModule" : function () {},
"width" : function () {}, "width" : function () {},
"window" : function () {}, "window" : function () {},
"writeCopyTo" : function () {}, "writeCopyTo" : function () {},

View File

@ -20,7 +20,6 @@
:DeviceEventEmitter #js {:addListener (fn [])} :DeviceEventEmitter #js {:addListener (fn [])}
:Dimensions #js {:get (fn [])}}) :Dimensions #js {:get (fn [])}})
(def vector-icons (fn [] #js {:default #js {}})) (def vector-icons (fn [] #js {:default #js {}}))
(def webview-bridge (fn [] #js {:default #js {}}))
(def webview (fn [] #js {:WebView #js {}})) (def webview (fn [] #js {:WebView #js {}}))
(def touchid (fn [] #js {})) (def touchid (fn [] #js {}))
(def svg (fn [] #js {:default #js {}})) (def svg (fn [] #js {:default #js {}}))

View File

@ -45,6 +45,8 @@ target 'StatusIm' do
pod 'SQLCipher', '~>3.0' pod 'SQLCipher', '~>3.0'
pod 'SSZipArchive' pod 'SSZipArchive'
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
target 'StatusImTests' do target 'StatusImTests' do
inherit! :search_paths inherit! :search_paths
# Pods for testing # Pods for testing

View File

@ -205,9 +205,7 @@ PODS:
- React - React
- react-native-splash-screen (3.2.0): - react-native-splash-screen (3.2.0):
- React - React
- react-native-webview (6.11.1): - react-native-webview (8.0.6):
- React
- react-native-webview-bridge (0.33.17):
- React - React
- React-RCTActionSheet (0.61.5): - React-RCTActionSheet (0.61.5):
- React-Core/RCTActionSheetHeaders (= 0.61.5) - React-Core/RCTActionSheetHeaders (= 0.61.5)
@ -302,7 +300,6 @@ DEPENDENCIES:
- react-native-shake (from `../node_modules/react-native-shake`) - react-native-shake (from `../node_modules/react-native-shake`)
- react-native-splash-screen (from `../node_modules/react-native-splash-screen`) - react-native-splash-screen (from `../node_modules/react-native-splash-screen`)
- react-native-webview (from `../node_modules/react-native-webview`) - react-native-webview (from `../node_modules/react-native-webview`)
- react-native-webview-bridge (from `../node_modules/react-native-webview-bridge`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
@ -383,8 +380,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-splash-screen" :path: "../node_modules/react-native-splash-screen"
react-native-webview: react-native-webview:
:path: "../node_modules/react-native-webview" :path: "../node_modules/react-native-webview"
react-native-webview-bridge:
:path: "../node_modules/react-native-webview-bridge"
React-RCTActionSheet: React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS" :path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation: React-RCTAnimation:
@ -434,7 +429,7 @@ SPEC CHECKSUMS:
FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f FBLazyVector: aaeaf388755e4f29cd74acbc9e3b8da6d807c37f
FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75 FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51 Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 353a32027a69db3807b94c7cbc2900fc4370098c glog: 1f3da668190260b06b429bb211bfbee5cd790c28
QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022 QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022
RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1 RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1
RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320 RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320
@ -453,8 +448,7 @@ SPEC CHECKSUMS:
react-native-safe-area-context: e200d4433aba6b7e60b52da5f37af11f7a0b0392 react-native-safe-area-context: e200d4433aba6b7e60b52da5f37af11f7a0b0392
react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865 react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
react-native-webview: 0658813bcc4b6c22f3cbb035a2227aa896a8cbc0 react-native-webview: e32e5ced4c99d7240362690a65e3467d7ef535ef
react-native-webview-bridge: 3023f6b0e84cdf8e4a96511d2b04e73b038f95f0
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76 React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360 React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72 React-RCTBlob: d89293cc0236d9cb0933d85e430b0bbe81ad1d72
@ -480,6 +474,6 @@ SPEC CHECKSUMS:
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4 TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
PODFILE CHECKSUM: 0483a7693bfa7c6ef9f214cdc7f614f67dec7448 PODFILE CHECKSUM: 6133ef51e21994956d642302ee6b9f5a96c6dcd5
COCOAPODS: 1.8.4 COCOAPODS: 1.8.4

View File

@ -647,6 +647,7 @@
"$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer", "$(SRCROOT)/../node_modules/react-native-image-resizer/ios/RCTImageResizer",
"$(SRCROOT)/../node_modules/react-native-splash-screen/ios", "$(SRCROOT)/../node_modules/react-native-splash-screen/ios",
"$(SRCROOT)/../node_modules/react-native-config/ios/**", "$(SRCROOT)/../node_modules/react-native-config/ios/**",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS", "$(SRCROOT)/../node_modules/react-native/Libraries/LinkingIOS",
); );
INFOPLIST_FILE = StatusIm/Info.plist; INFOPLIST_FILE = StatusIm/Info.plist;
@ -696,6 +697,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios", "$(SRCROOT)/../node_modules/react-native-camera/ios",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-fs/**", "$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-languages/RNLanguages", "$(SRCROOT)/../node_modules/react-native-languages/RNLanguages",
"$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**", "$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**",
@ -782,6 +784,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios", "$(SRCROOT)/../node_modules/react-native-camera/ios",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-fs/**", "$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-languages/RNLanguages", "$(SRCROOT)/../node_modules/react-native-languages/RNLanguages",
"$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**", "$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**",
@ -845,6 +848,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**", "$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-camera/ios", "$(SRCROOT)/../node_modules/react-native-camera/ios",
"$(SRCROOT)/../node_modules/react-native-webview/ios",
"$(SRCROOT)/../node_modules/react-native-fs/**", "$(SRCROOT)/../node_modules/react-native-fs/**",
"$(SRCROOT)/../node_modules/react-native-languages/RNLanguages", "$(SRCROOT)/../node_modules/react-native-languages/RNLanguages",
"$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**", "$(SRCROOT)/../modules/react-native-status/ios/RCTStatus/**",

View File

@ -152,7 +152,7 @@ TODO: updating requires a pod update on iOS
used for touch-id identification used for touch-id identification
## "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/classnames-colision" ## "react-native-webview": "git+https://github.com/status-im/react-native-webview.git#v8.0.7_3"
used for browser used for browser

View File

@ -46,8 +46,7 @@
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.20", "react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.20",
"react-native-svg": "^9.8.4", "react-native-svg": "^9.8.4",
"react-native-touch-id": "^4.4.1", "react-native-touch-id": "^4.4.1",
"react-native-webview": "^6.11.1", "react-native-webview": "git+https://github.com/status-im/react-native-webview#v8.0.7_3",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/community-webview",
"web3-utils": "^1.2.1" "web3-utils": "^1.2.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -2247,7 +2247,12 @@ escape-html@~1.0.3:
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.5: escape-string-regexp@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344"
integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==
escape-string-regexp@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
@ -2986,13 +2991,6 @@ inquirer@^3.0.6:
strip-ansi "^4.0.0" strip-ansi "^4.0.0"
through "^2.3.6" through "^2.3.6"
invariant@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.0.tgz#c8d7e847366a49cc18b622f058a689d481e895f2"
integrity sha1-yNfoRzZqScwYtiLwWKaJ1IHolfI=
dependencies:
loose-envify "^1.0.0"
invariant@2.2.4, invariant@^2.2.2, invariant@^2.2.4, invariant@^2.2.x: invariant@2.2.4, invariant@^2.2.2, invariant@^2.2.4, invariant@^2.2.x:
version "2.2.4" version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
@ -3471,11 +3469,6 @@ jsx-ast-utils@^1.4.0:
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1"
integrity sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE= integrity sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=
keymirror@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35"
integrity sha1-kYiJ6hP40KQufFVyUO7nE63JXDU=
kind-of@^1.1.0: kind-of@^1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-1.1.0.tgz#140a3d2d41a36d2efcfa9377b62c24f8495a5c44"
@ -4962,20 +4955,11 @@ react-native-touch-id@^4.4.1:
resolved "https://registry.yarnpkg.com/react-native-touch-id/-/react-native-touch-id-4.4.1.tgz#8b1bb2d04c30bac36bb9696d2d723e719c4a8b08" resolved "https://registry.yarnpkg.com/react-native-touch-id/-/react-native-touch-id-4.4.1.tgz#8b1bb2d04c30bac36bb9696d2d723e719c4a8b08"
integrity sha512-1jTl8fC+0fxvqegy/XXTyo6vMvPhjzkoDdaqoYZx0OH8AT250NuXnNPyKktvigIcys3+2acciqOeaCall7lrvg== integrity sha512-1jTl8fC+0fxvqegy/XXTyo6vMvPhjzkoDdaqoYZx0OH8AT250NuXnNPyKktvigIcys3+2acciqOeaCall7lrvg==
"react-native-webview-bridge@git+https://github.com/status-im/react-native-webview-bridge.git#fix/community-webview": "react-native-webview@git+https://github.com/status-im/react-native-webview#v8.0.7_3":
version "0.33.17" version "8.0.7"
resolved "git+https://github.com/status-im/react-native-webview-bridge.git#55acc0cb683dc239673bbe5a94b1f13e7b90e1f7" resolved "git+https://github.com/status-im/react-native-webview#fb3f4d616381a3c201272c32ced44ab1fc2d16be"
dependencies: dependencies:
invariant "2.2.0" escape-string-regexp "2.0.0"
keymirror "0.1.1"
react-native-webview "^6.11.1"
react-native-webview@^6.11.1:
version "6.11.1"
resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-6.11.1.tgz#51fab0838ef9bdf3efd0d3f27147dddda5119f94"
integrity sha512-0OaNCEzdyywJZ70y6Z4fmmuAd2AHYq2AEByIr15z3YetpMXhm9lXUe2V/8BXQIZXeC9FJosj2DAKu48lpZ0nEg==
dependencies:
escape-string-regexp "1.0.5"
invariant "2.2.4" invariant "2.2.4"
react-native@0.61.5: react-native@0.61.5:

View File

@ -22,10 +22,5 @@ module.exports = {
ios: null, ios: null,
}, },
}, },
'react-native-webview-bridge': {
platforms: {
android: null,
},
},
}, },
}; };

View File

@ -7,10 +7,9 @@
(def react (js/require "react")) (def react (js/require "react"))
(def react-native (js/require "react-native")) (def react-native (js/require "react-native"))
(def status-keycard (js/require "react-native-status-keycard")) (def status-keycard (js/require "react-native-status-keycard"))
(def webview-bridge (js/require "react-native-webview-bridge")) (def webview (js/require "react-native-webview"))
(def touchid-class (js/require "react-native-touch-id")) (def touchid-class (js/require "react-native-touch-id"))
(def touchid (.-default touchid-class)) (def touchid (.-default touchid-class))
;(defn webview [] (js/require "react-native-webview"))
(def EventEmmiter (js/require "react-native/Libraries/vendor/emitter/EventEmitter")) (def EventEmmiter (js/require "react-native/Libraries/vendor/emitter/EventEmitter"))
(def fetch-polyfill (js/require "react-native-fetch-polyfill")) (def fetch-polyfill (js/require "react-native-fetch-polyfill"))
(def fetch (.-default fetch-polyfill)) (def fetch (.-default fetch-polyfill))

View File

@ -1,10 +1,9 @@
if(typeof EthereumProvider === "undefined"){ if(typeof EthereumProvider === "undefined"){
var callbackId = 0; var callbackId = 0;
var callbacks = {}; var callbacks = {};
var currentAccountAddress;
function bridgeSend(data){ bridgeSend = function (data) {
WebViewBridge.send(JSON.stringify(data)); ReactNativeWebView.postMessage(JSON.stringify(data));
} }
function sendAPIrequest(permission, params) { function sendAPIrequest(permission, params) {
@ -58,7 +57,7 @@ function UserRejectedRequest() {
} }
UserRejectedRequest.prototype = Object.create(Error.prototype); UserRejectedRequest.prototype = Object.create(Error.prototype);
WebViewBridge.onMessage = function (message) ReactNativeWebView.onMessage = function (message)
{ {
data = JSON.parse(message); data = JSON.parse(message);
var id = data.messageId; var id = data.messageId;
@ -117,9 +116,9 @@ function web3Response (payload, result){
} }
function getSyncResponse (payload) { function getSyncResponse (payload) {
if (payload.method == "eth_accounts" && currentAccountAddress){ if (payload.method == "eth_accounts" && (typeof currentAccountAddress !== "undefined")) {
return web3Response(payload, [currentAccountAddress]) return web3Response(payload, [currentAccountAddress])
} else if (payload.method == "eth_coinbase" && currentAccountAddress){ } else if (payload.method == "eth_coinbase" && (typeof currentAccountAddress !== "undefined")) {
return web3Response(payload, currentAccountAddress) return web3Response(payload, currentAccountAddress)
} else if (payload.method == "net_version" || payload.method == "eth_chainId"){ } else if (payload.method == "net_version" || payload.method == "eth_chainId"){
return web3Response(payload, networkId) return web3Response(payload, networkId)

View File

@ -378,7 +378,6 @@
dapp-name (if dapp? name (http/url-host url-original))] dapp-name (if dapp? name (http/url-host url-original))]
(cond (cond
(and (= type constants/history-state-changed) (and (= type constants/history-state-changed)
platform/ios?
(not= "about:blank" url)) (not= "about:blank" url))
(fx/merge cofx (fx/merge cofx
(update-browser-history browser url) (update-browser-history browser url)
@ -417,9 +416,12 @@
(re-frame/reg-fx (re-frame/reg-fx
:browser/send-to-bridge :browser/send-to-bridge
(fn [message] (fn [message]
(let [webview @webview-ref/webview-ref] (let [webview @webview-ref/webview-ref
msg (str "ReactNativeWebView.onMessage('"
(types/clj->json message)
"');")]
(when (and message webview) (when (and message webview)
(.sendToBridge webview (types/clj->json message)))))) (.injectJavaScript webview msg)))))
(re-frame/reg-fx (re-frame/reg-fx
:browser/call-rpc :browser/call-rpc

View File

@ -3,7 +3,7 @@
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.utils.http :as http] [status-im.utils.http :as http]
[status-im.ui.components.webview-bridge :as components.webview-bridge])) [status-im.ui.components.webview :as components.webview]))
(defn html [uri width height] (defn html [uri width height]
(str (str
@ -46,7 +46,7 @@
(fn [] (fn []
[react/view {:style style [react/view {:style style
:on-layout #(reset! width (-> % .-nativeEvent .-layout .-width))} :on-layout #(reset! width (-> % .-nativeEvent .-layout .-width))}
[components.webview-bridge/webview-bridge [components.webview/webview
{:java-script-enabled false {:java-script-enabled false
:third-party-cookies-enabled false :third-party-cookies-enabled false
:scroll-enabled false :scroll-enabled false

View File

@ -1,18 +1,18 @@
(ns status-im.ui.components.webview-bridge (ns status-im.ui.components.webview
(:require [reagent.core :as reagent] (:require [reagent.core :as reagent]
[status-im.react-native.js-dependencies :as js-dependencies] [status-im.react-native.js-dependencies :as js-dependencies]
[reagent.core :as reagent.core] [reagent.core :as reagent.core]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.utils.config :as config])) [status-im.utils.config :as config]))
(def webview-bridge-class (def webview-class
(memoize (memoize
(fn [] (fn []
(reagent/adapt-react-class (.-default js-dependencies/webview-bridge))))) (reagent/adapt-react-class (.-default js-dependencies/webview)))))
(defn module [] (.-WebViewBridgeModule (.-NativeModules js-dependencies/react-native))) (defn module [] (.-WebViewModule (.-NativeModules js-dependencies/react-native)))
(defn webview-bridge [{:keys [dapp? dapp-name] :as opts}] (defn webview [{:keys [dapp? dapp-name] :as opts}]
(if (and config/cached-webviews-enabled? platform/android? dapp?) (if (and config/cached-webviews-enabled? platform/android? dapp?)
(reagent.core/create-class (reagent.core/create-class
(let [dapp-name-sent? (reagent.core/atom false)] (let [dapp-name-sent? (reagent.core/atom false)]
@ -21,10 +21,10 @@
;; unfortunately it's impossible to pass some initial params ;; unfortunately it's impossible to pass some initial params
;; to view, that's why we have to pass dapp-name to the module ;; to view, that's why we have to pass dapp-name to the module
;; before showing webview ;; before showing webview
(.setCurrentDapp (module) dapp-name #_(.setCurrentDapp (module) dapp-name
(fn [] (reset! dapp-name-sent? true)))) (fn [] (reset! dapp-name-sent? true))))
:reagent-render :reagent-render
(fn [opts] (fn [opts]
(when @dapp-name-sent? (when @dapp-name-sent?
[(webview-bridge-class) opts]))})) [(webview-class) opts]))}))
[(webview-bridge-class) opts])) [(webview-class) opts]))

View File

@ -13,7 +13,7 @@
[status-im.ui.components.toolbar.actions :as actions] [status-im.ui.components.toolbar.actions :as actions]
[status-im.ui.components.toolbar.view :as toolbar.view] [status-im.ui.components.toolbar.view :as toolbar.view]
[status-im.ui.components.tooltip.views :as tooltip] [status-im.ui.components.tooltip.views :as tooltip]
[status-im.ui.components.webview-bridge :as components.webview-bridge] [status-im.ui.components.webview :as components.webview]
[status-im.ui.screens.browser.permissions.views :as permissions.views] [status-im.ui.screens.browser.permissions.views :as permissions.views]
[status-im.ui.screens.browser.site-blocked.views :as site-blocked.views] [status-im.ui.screens.browser.site-blocked.views :as site-blocked.views]
[status-im.ui.screens.browser.styles :as styles] [status-im.ui.screens.browser.styles :as styles]
@ -118,7 +118,7 @@
(if unsafe? (if unsafe?
[site-blocked.views/view {:can-go-back? can-go-back? [site-blocked.views/view {:can-go-back? can-go-back?
:site browser-id}] :site browser-id}]
[components.webview-bridge/webview-bridge [components.webview/webview
{:dapp? dapp? {:dapp? dapp?
:dapp-name name :dapp-name name
:ref #(reset! webview-ref/webview-ref %) :ref #(reset! webview-ref/webview-ref %)
@ -132,10 +132,12 @@
(debounce/debounce-and-dispatch (debounce/debounce-and-dispatch
[:browser/navigation-state-changed % error?] [:browser/navigation-state-changed % error?]
500)) 500))
:on-bridge-message #(re-frame/dispatch [:browser/bridge-message-received %]) ;; Extract event data here due to
;; https://reactjs.org/docs/events.html#event-pooling
:on-message #(re-frame/dispatch [:browser/bridge-message-received (.. % -nativeEvent -data)])
:on-load #(re-frame/dispatch [:browser/loading-started]) :on-load #(re-frame/dispatch [:browser/loading-started])
:on-error #(re-frame/dispatch [:browser/error-occured]) :on-error #(re-frame/dispatch [:browser/error-occured])
:injected-on-start-loading-java-script (js-res/ethereum-provider (str network-id)) :injected-java-script-before-content-loaded (js-res/ethereum-provider (str network-id))
:injected-java-script (js-res/webview-js)}])] :injected-java-script (js-res/webview-js)}])]
[navigation url-original can-go-back? can-go-forward? dapps-account] [navigation url-original can-go-back? can-go-forward? dapps-account]
[permissions.views/permissions-panel [(:dapp? browser) (:dapp browser) dapps-account] show-permission] [permissions.views/permissions-panel [(:dapp? browser) (:dapp browser) dapps-account] show-permission]

View File

@ -67,7 +67,6 @@
;;object? doesn't work ;;object? doesn't work
(spec/def ::web3 (spec/nilable any?)) (spec/def ::web3 (spec/nilable any?))
(spec/def ::web3-node-version (spec/nilable string?)) (spec/def ::web3-node-version (spec/nilable string?))
;;object?
;;height of native keyboard if shown ;;height of native keyboard if shown
(spec/def ::keyboard-height (spec/nilable number?)) (spec/def ::keyboard-height (spec/nilable number?))

View File

@ -26,7 +26,6 @@
(set! js/ReactNative react-native) (set! js/ReactNative react-native)
(def vector-icons #js {:default #js {}}) (def vector-icons #js {:default #js {}})
(def webview-bridge #js {:default #js {}})
(def webview #js {:WebView #js {}}) (def webview #js {:WebView #js {}})
(def status-keycard #js {:default #js {}}) (def status-keycard #js {:default #js {}})