Browse Source

Merge branch 'tomun/example' into tomun/macos

Tom Underhill 4 years ago
parent
commit
dc3445d236
35 changed files with 899 additions and 0 deletions
  1. 55
    0
      example/android/app/BUCK
  2. 190
    0
      example/android/app/build.gradle
  3. 19
    0
      example/android/app/build_defs.bzl
  4. BIN
      example/android/app/exampleAsyncStorage.keystore
  5. 17
    0
      example/android/app/proguard-rules.pro
  6. 25
    0
      example/android/app/scripts/CI.gradle
  7. 24
    0
      example/android/app/src/androidTest/java/com/webviewexample/DetoxTest.java
  8. 9
    0
      example/android/app/src/debug/AndroidManifest.xml
  9. 26
    0
      example/android/app/src/main/AndroidManifest.xml
  10. 15
    0
      example/android/app/src/main/java/com/webviewexample/MainActivity.java
  11. 47
    0
      example/android/app/src/main/java/com/webviewexample/MainApplication.java
  12. BIN
      example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
  13. BIN
      example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
  14. BIN
      example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
  15. BIN
      example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
  16. BIN
      example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
  17. BIN
      example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
  18. BIN
      example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  19. BIN
      example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
  20. BIN
      example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  21. BIN
      example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
  22. 3
    0
      example/android/app/src/main/res/values/strings.xml
  23. 8
    0
      example/android/app/src/main/res/values/styles.xml
  24. 38
    0
      example/android/build.gradle
  25. 27
    0
      example/android/gradle.properties
  26. BIN
      example/android/gradle/wrapper/gradle-wrapper.jar
  27. 6
    0
      example/android/gradle/wrapper/gradle-wrapper.properties
  28. 172
    0
      example/android/gradlew
  29. 84
    0
      example/android/gradlew.bat
  30. 8
    0
      example/android/keystores/BUCK
  31. 4
    0
      example/android/keystores/debug.keystore.properties
  32. 7
    0
      example/android/settings.gradle
  33. 19
    0
      example/ios/RNCWebViewExample.xcodeproj/project.pbxproj
  34. 92
    0
      example/ios/RNCWebViewExample.xcodeproj/xcshareddata/xcschemes/RNCWebViewExample.xcscheme
  35. 4
    0
      package.json

+ 55
- 0
example/android/app/BUCK View File

@@ -0,0 +1,55 @@
1
+# To learn about Buck see [Docs](https://buckbuild.com/).
2
+# To run your application with Buck:
3
+# - install Buck
4
+# - `npm start` - to start the packager
5
+# - `cd android`
6
+# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7
+# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8
+# - `buck install -r android/app` - compile, install and run application
9
+#
10
+
11
+load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12
+
13
+lib_deps = []
14
+
15
+create_aar_targets(glob(["libs/*.aar"]))
16
+
17
+create_jar_targets(glob(["libs/*.jar"]))
18
+
19
+android_library(
20
+    name = "all-libs",
21
+    exported_deps = lib_deps,
22
+)
23
+
24
+android_library(
25
+    name = "app-code",
26
+    srcs = glob([
27
+        "src/main/java/**/*.java",
28
+    ]),
29
+    deps = [
30
+        ":all-libs",
31
+        ":build_config",
32
+        ":res",
33
+    ],
34
+)
35
+
36
+android_build_config(
37
+    name = "build_config",
38
+    package = "com.webviewexample",
39
+)
40
+
41
+android_resource(
42
+    name = "res",
43
+    package = "com.webviewexample",
44
+    res = "src/main/res",
45
+)
46
+
47
+android_binary(
48
+    name = "app",
49
+    keystore = "//android/keystores:debug",
50
+    manifest = "src/main/AndroidManifest.xml",
51
+    package_type = "debug",
52
+    deps = [
53
+        ":app-code",
54
+    ],
55
+)

+ 190
- 0
example/android/app/build.gradle View File

@@ -0,0 +1,190 @@
1
+apply plugin: "com.android.application"
2
+
3
+import com.android.build.OutputFile
4
+
5
+/**
6
+ * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7
+ * and bundleReleaseJsAndAssets).
8
+ * These basically call `react-native bundle` with the correct arguments during the Android build
9
+ * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10
+ * bundle directly from the development server. Below you can see all the possible configurations
11
+ * and their defaults. If you decide to add a configuration block, make sure to add it before the
12
+ * `apply from: "../../node_modules/react-native/react.gradle"` line.
13
+ *
14
+ * project.ext.react = [
15
+ *   // the name of the generated asset file containing your JS bundle
16
+ *   bundleAssetName: "index.android.bundle",
17
+ *
18
+ *   // the entry file for bundle generation
19
+ *   entryFile: "index.android.js",
20
+ *
21
+ *   // whether to bundle JS and assets in debug mode
22
+ *   bundleInDebug: false,
23
+ *
24
+ *   // whether to bundle JS and assets in release mode
25
+ *   bundleInRelease: true,
26
+ *
27
+ *   // whether to bundle JS and assets in another build variant (if configured).
28
+ *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29
+ *   // The configuration property can be in the following formats
30
+ *   //         'bundleIn${productFlavor}${buildType}'
31
+ *   //         'bundleIn${buildType}'
32
+ *   // bundleInFreeDebug: true,
33
+ *   // bundleInPaidRelease: true,
34
+ *   // bundleInBeta: true,
35
+ *
36
+ *   // whether to disable dev mode in custom build variants (by default only disabled in release)
37
+ *   // for example: to disable dev mode in the staging build type (if configured)
38
+ *   devDisabledInStaging: true,
39
+ *   // The configuration property can be in the following formats
40
+ *   //         'devDisabledIn${productFlavor}${buildType}'
41
+ *   //         'devDisabledIn${buildType}'
42
+ *
43
+ *   // the root of your project, i.e. where "package.json" lives
44
+ *   root: "../../",
45
+ *
46
+ *   // where to put the JS bundle asset in debug mode
47
+ *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
48
+ *
49
+ *   // where to put the JS bundle asset in release mode
50
+ *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
51
+ *
52
+ *   // where to put drawable resources / React Native assets, e.g. the ones you use via
53
+ *   // require('./image.png')), in debug mode
54
+ *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
55
+ *
56
+ *   // where to put drawable resources / React Native assets, e.g. the ones you use via
57
+ *   // require('./image.png')), in release mode
58
+ *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
59
+ *
60
+ *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
61
+ *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
62
+ *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
63
+ *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
64
+ *   // for example, you might want to remove it from here.
65
+ *   inputExcludes: ["android/**", "ios/**"],
66
+ *
67
+ *   // override which node gets called and with what additional arguments
68
+ *   nodeExecutableAndArgs: ["node"],
69
+ *
70
+ *   // supply additional arguments to the packager
71
+ *   extraPackagerArgs: []
72
+ * ]
73
+ */
74
+
75
+
76
+project.ext.react = [
77
+        cliPath: "./node_modules/react-native/local-cli/cli.js",
78
+        enableHermes: false,
79
+        entryFile: "./example/index.js",
80
+        root: "../../../"
81
+]
82
+
83
+
84
+apply from: "./scripts/CI.gradle"
85
+apply from: "../../../node_modules/react-native/react.gradle"
86
+
87
+/**
88
+ * Set this to true to create two separate APKs instead of one:
89
+ *   - An APK that only works on ARM devices
90
+ *   - An APK that only works on x86 devices
91
+ * The advantage is the size of the APK is reduced by about 4MB.
92
+ * Upload all the APKs to the Play Store and people will download
93
+ * the correct one based on the CPU architecture of their device.
94
+ */
95
+def enableSeparateBuildPerCPUArchitecture = false
96
+
97
+/**
98
+ * Run Proguard to shrink the Java bytecode in release builds.
99
+ */
100
+def enableProguardInReleaseBuilds = false
101
+
102
+android {
103
+    compileSdkVersion rootProject.ext.compileSdkVersion
104
+
105
+    compileOptions {
106
+        sourceCompatibility JavaVersion.VERSION_1_8
107
+        targetCompatibility JavaVersion.VERSION_1_8
108
+    }
109
+
110
+    signingConfigs {
111
+        release {
112
+            storeFile file("exampleWebView.keystore")
113
+            keyAlias "webview"
114
+            keyPassword "webview"
115
+            storePassword "webview"
116
+        }
117
+    }
118
+
119
+    defaultConfig {
120
+        applicationId "com.webviewexample"
121
+        minSdkVersion rootProject.ext.minSdkVersion
122
+        targetSdkVersion rootProject.ext.targetSdkVersion
123
+        versionCode 1
124
+        versionName "1.0"
125
+        testBuildType System.getProperty('testBuildType', 'debug')
126
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
127
+    }
128
+    splits {
129
+        abi {
130
+            reset()
131
+            enable enableSeparateBuildPerCPUArchitecture
132
+            universalApk false  // If true, also generate a universal APK
133
+            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
134
+        }
135
+    }
136
+    buildTypes {
137
+        release {
138
+            minifyEnabled enableProguardInReleaseBuilds
139
+            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
140
+            proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
141
+            signingConfig signingConfigs.release
142
+            matchingFallbacks = ['release']
143
+        }
144
+    }
145
+    // applicationVariants are e.g. debug, release
146
+    applicationVariants.all { variant ->
147
+        variant.outputs.each { output ->
148
+            // For each separate APK per architecture, set a unique version code as described here:
149
+            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
150
+            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
151
+            def abi = output.getFilter(OutputFile.ABI)
152
+            if (abi != null) {  // null for the universal-debug, universal-release variants
153
+                output.versionCodeOverride =
154
+                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
155
+            }
156
+        }
157
+    }
158
+}
159
+
160
+def jscFlavor = 'org.webkit:android-jsc:+'
161
+
162
+def enableHermes = project.ext.react.get("enableHermes", false);
163
+
164
+dependencies {
165
+    implementation project(':ReactNativeWebView')
166
+    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
167
+    implementation fileTree(dir: "libs", include: ["*.jar"])
168
+    implementation "com.facebook.react:react-native:+"  // From node_modules
169
+
170
+    // tests
171
+    androidTestImplementation ('com.wix:detox:+') { transitive = true }
172
+    androidTestImplementation 'junit:junit:4.12'
173
+
174
+    if (enableHermes) {
175
+        // For RN 0.60.x
176
+        def hermesPath = "${rootProject.projectDir}/../node_modules/hermesvm/android/"
177
+
178
+        debugImplementation files(hermesPath + "hermes-debug.aar")
179
+        releaseImplementation files(hermesPath + "hermes-release.aar")
180
+    } else {
181
+        implementation jscFlavor
182
+    }
183
+}
184
+
185
+// Run this once to be able to run the application with BUCK
186
+// puts all compile dependencies into folder libs for BUCK to use
187
+task copyDownloadableDepsToLibs(type: Copy) {
188
+    from configurations.compile
189
+    into 'libs'
190
+}

+ 19
- 0
example/android/app/build_defs.bzl View File

@@ -0,0 +1,19 @@
1
+"""Helper definitions to glob .aar and .jar targets"""
2
+
3
+def create_aar_targets(aarfiles):
4
+    for aarfile in aarfiles:
5
+        name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6
+        lib_deps.append(":" + name)
7
+        android_prebuilt_aar(
8
+            name = name,
9
+            aar = aarfile,
10
+        )
11
+
12
+def create_jar_targets(jarfiles):
13
+    for jarfile in jarfiles:
14
+        name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15
+        lib_deps.append(":" + name)
16
+        prebuilt_jar(
17
+            name = name,
18
+            binary_jar = jarfile,
19
+        )

BIN
example/android/app/exampleAsyncStorage.keystore View File


+ 17
- 0
example/android/app/proguard-rules.pro View File

@@ -0,0 +1,17 @@
1
+# Add project specific ProGuard rules here.
2
+# By default, the flags in this file are appended to flags specified
3
+# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4
+# You can edit the include path and order by changing the proguardFiles
5
+# directive in build.gradle.
6
+#
7
+# For more details, see
8
+#   http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+# Add any project specific keep options here:
11
+
12
+# If your project uses WebView with JS, uncomment the following
13
+# and specify the fully qualified class name to the JavaScript interface
14
+# class:
15
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16
+#   public *;
17
+#}

+ 25
- 0
example/android/app/scripts/CI.gradle View File

@@ -0,0 +1,25 @@
1
+// Fetch all dependencies upfront
2
+task fetchDependencies() {
3
+    description 'Download all dependencies to the Gradle cache'
4
+    group 'android'
5
+    doLast {
6
+        project.rootProject.allprojects.each { subProject ->
7
+            subProject.buildscript.configurations.each {config ->
8
+                if(config.canBeResolved) {
9
+                    config.files
10
+                }
11
+            }
12
+            subProject.configurations.each {config ->
13
+                if(config.canBeResolved) {
14
+                    // DefaultLenientConfiguration$ArtifactResolveException
15
+                    try {
16
+                        config.files
17
+                    } catch(e) {
18
+                        println e
19
+                    }
20
+
21
+                }
22
+            }
23
+        }
24
+    }
25
+}

+ 24
- 0
example/android/app/src/androidTest/java/com/webviewexample/DetoxTest.java View File

@@ -0,0 +1,24 @@
1
+package com.webviewexample;
2
+
3
+import androidx.test.filters.LargeTest;
4
+import androidx.test.rule.ActivityTestRule;
5
+import androidx.test.runner.AndroidJUnit4;
6
+
7
+import com.wix.detox.Detox;
8
+
9
+import org.junit.Rule;
10
+import org.junit.Test;
11
+import org.junit.runner.RunWith;
12
+
13
+@RunWith(AndroidJUnit4.class)
14
+@LargeTest
15
+public class DetoxTest {
16
+
17
+    @Rule
18
+    public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19
+
20
+    @Test
21
+    public void runDetoxTests() throws InterruptedException {
22
+        Detox.runTests(mActivityRule);
23
+    }
24
+}

+ 9
- 0
example/android/app/src/debug/AndroidManifest.xml View File

@@ -0,0 +1,9 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+          xmlns:tools="http://schemas.android.com/tools">
4
+    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5
+    <application
6
+    	android:usesCleartextTraffic="true"
7
+    	tools:targetApi="28"
8
+    	tools:ignore="GoogleAppIndexingWarning"/>
9
+</manifest>

+ 26
- 0
example/android/app/src/main/AndroidManifest.xml View File

@@ -0,0 +1,26 @@
1
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+    package="com.webviewexample">
3
+
4
+    <uses-permission android:name="android.permission.INTERNET" />
5
+
6
+    <application
7
+      android:name=".MainApplication"
8
+      android:label="@string/app_name"
9
+      android:icon="@mipmap/ic_launcher"
10
+      android:roundIcon="@mipmap/ic_launcher_round"
11
+      android:allowBackup="false"
12
+      android:theme="@style/AppTheme">
13
+      <activity
14
+        android:name=".MainActivity"
15
+        android:label="@string/app_name"
16
+        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
17
+        android:windowSoftInputMode="adjustResize">
18
+        <intent-filter>
19
+            <action android:name="android.intent.action.MAIN" />
20
+            <category android:name="android.intent.category.LAUNCHER" />
21
+        </intent-filter>
22
+      </activity>
23
+      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
24
+    </application>
25
+
26
+</manifest>

+ 15
- 0
example/android/app/src/main/java/com/webviewexample/MainActivity.java View File

@@ -0,0 +1,15 @@
1
+package com.webviewexample;
2
+
3
+import com.facebook.react.ReactActivity;
4
+
5
+public class MainActivity extends ReactActivity {
6
+
7
+    /**
8
+     * Returns the name of the main component registered from JavaScript.
9
+     * This is used to schedule rendering of the component.
10
+     */
11
+    @Override
12
+    protected String getMainComponentName() {
13
+        return "RNCWebViewExample";
14
+    }
15
+}

+ 47
- 0
example/android/app/src/main/java/com/webviewexample/MainApplication.java View File

@@ -0,0 +1,47 @@
1
+package com.webviewexample;
2
+
3
+import android.app.Application;
4
+
5
+import com.facebook.react.ReactApplication;
6
+import com.facebook.react.ReactNativeHost;
7
+import com.facebook.react.ReactPackage;
8
+import com.facebook.react.shell.MainReactPackage;
9
+import com.facebook.soloader.SoLoader;
10
+import com.reactnativecommunity.webview.RNCWebViewPackage;
11
+
12
+import java.util.Arrays;
13
+import java.util.List;
14
+
15
+public class MainApplication extends Application implements ReactApplication {
16
+
17
+    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
18
+        @Override
19
+        public boolean getUseDeveloperSupport() {
20
+            return BuildConfig.DEBUG;
21
+        }
22
+
23
+        @Override
24
+        protected List<ReactPackage> getPackages() {
25
+            return Arrays.<ReactPackage>asList(
26
+                    new MainReactPackage(),
27
+                    new RNCWebViewPackage()
28
+            );
29
+        }
30
+
31
+        @Override
32
+        protected String getJSMainModuleName() {
33
+            return "example/index";
34
+        }
35
+    };
36
+
37
+    @Override
38
+    public ReactNativeHost getReactNativeHost() {
39
+        return mReactNativeHost;
40
+    }
41
+
42
+    @Override
43
+    public void onCreate() {
44
+        super.onCreate();
45
+        SoLoader.init(this, /* native exopackage */ false);
46
+    }
47
+}

BIN
example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png View File


BIN
example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png View File


BIN
example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png View File


BIN
example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png View File


BIN
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png View File


BIN
example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png View File


BIN
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png View File


BIN
example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png View File


BIN
example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png View File


BIN
example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png View File


+ 3
- 0
example/android/app/src/main/res/values/strings.xml View File

@@ -0,0 +1,3 @@
1
+<resources>
2
+    <string name="app_name">WebViewExample</string>
3
+</resources>

+ 8
- 0
example/android/app/src/main/res/values/styles.xml View File

@@ -0,0 +1,8 @@
1
+<resources>
2
+
3
+    <!-- Base application theme. -->
4
+    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5
+        <!-- Customize your theme here. -->
6
+    </style>
7
+
8
+</resources>

+ 38
- 0
example/android/build.gradle View File

@@ -0,0 +1,38 @@
1
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+
3
+buildscript {
4
+    ext {
5
+        kotlinVersion = '1.3.10'
6
+        buildToolsVersion = "28.0.3"
7
+        minSdkVersion = 19
8
+        compileSdkVersion = 28
9
+        targetSdkVersion = 28
10
+        supportLibVersion = "28.0.0"
11
+        detoxKotlinVersion = kotlinVersion
12
+    }
13
+    repositories {
14
+        google()
15
+        jcenter()
16
+    }
17
+    dependencies {
18
+        classpath 'com.android.tools.build:gradle:3.4.1'
19
+        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
20
+    }
21
+}
22
+
23
+allprojects {
24
+    repositories {
25
+        mavenLocal()
26
+        google()
27
+        jcenter()
28
+        maven {
29
+            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
30
+            url "$rootDir/../../node_modules/react-native/android"
31
+            }
32
+        maven {
33
+            // Android JSC is installed from npm
34
+            url "$rootDir/../../node_modules/jsc-android/dist"
35
+        }
36
+        maven { url "$rootDir/../../node_modules/detox/Detox-android" }
37
+    }
38
+}

+ 27
- 0
example/android/gradle.properties View File

@@ -0,0 +1,27 @@
1
+# Project-wide Gradle settings.
2
+
3
+# IDE (e.g. Android Studio) users:
4
+# Gradle settings configured through the IDE *will override*
5
+# any settings specified in this file.
6
+
7
+# For more details on how to configure your build environment visit
8
+# http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+# Specifies the JVM arguments used for the daemon process.
11
+# The setting is particularly useful for tweaking memory settings.
12
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
13
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14
+
15
+# When configured, Gradle will run in incubating parallel mode.
16
+# This option should only be used with decoupled projects. More details, visit
17
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18
+# org.gradle.parallel=true
19
+
20
+# This is an example of how you can change default DB size (6MB) to 10MB
21
+# WebView_db_size_in_MB=10
22
+
23
+# Enable dedicated thread pool executor
24
+WebView_dedicatedExecutor=true
25
+android.useAndroidX=true
26
+android.enableJetifier=true
27
+

BIN
example/android/gradle/wrapper/gradle-wrapper.jar View File


+ 6
- 0
example/android/gradle/wrapper/gradle-wrapper.properties View File

@@ -0,0 +1,6 @@
1
+distributionBase=GRADLE_USER_HOME
2
+distributionPath=wrapper/dists
3
+zipStoreBase=GRADLE_USER_HOME
4
+zipStorePath=wrapper/dists
5
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6
+

+ 172
- 0
example/android/gradlew View File

@@ -0,0 +1,172 @@
1
+#!/usr/bin/env sh
2
+
3
+##############################################################################
4
+##
5
+##  Gradle start up script for UN*X
6
+##
7
+##############################################################################
8
+
9
+# Attempt to set APP_HOME
10
+# Resolve links: $0 may be a link
11
+PRG="$0"
12
+# Need this for relative symlinks.
13
+while [ -h "$PRG" ] ; do
14
+    ls=`ls -ld "$PRG"`
15
+    link=`expr "$ls" : '.*-> \(.*\)$'`
16
+    if expr "$link" : '/.*' > /dev/null; then
17
+        PRG="$link"
18
+    else
19
+        PRG=`dirname "$PRG"`"/$link"
20
+    fi
21
+done
22
+SAVED="`pwd`"
23
+cd "`dirname \"$PRG\"`/" >/dev/null
24
+APP_HOME="`pwd -P`"
25
+cd "$SAVED" >/dev/null
26
+
27
+APP_NAME="Gradle"
28
+APP_BASE_NAME=`basename "$0"`
29
+
30
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
+DEFAULT_JVM_OPTS=""
32
+
33
+# Use the maximum available, or set MAX_FD != -1 to use that value.
34
+MAX_FD="maximum"
35
+
36
+warn () {
37
+    echo "$*"
38
+}
39
+
40
+die () {
41
+    echo
42
+    echo "$*"
43
+    echo
44
+    exit 1
45
+}
46
+
47
+# OS specific support (must be 'true' or 'false').
48
+cygwin=false
49
+msys=false
50
+darwin=false
51
+nonstop=false
52
+case "`uname`" in
53
+  CYGWIN* )
54
+    cygwin=true
55
+    ;;
56
+  Darwin* )
57
+    darwin=true
58
+    ;;
59
+  MINGW* )
60
+    msys=true
61
+    ;;
62
+  NONSTOP* )
63
+    nonstop=true
64
+    ;;
65
+esac
66
+
67
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
+
69
+# Determine the Java command to use to start the JVM.
70
+if [ -n "$JAVA_HOME" ] ; then
71
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72
+        # IBM's JDK on AIX uses strange locations for the executables
73
+        JAVACMD="$JAVA_HOME/jre/sh/java"
74
+    else
75
+        JAVACMD="$JAVA_HOME/bin/java"
76
+    fi
77
+    if [ ! -x "$JAVACMD" ] ; then
78
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
+
80
+Please set the JAVA_HOME variable in your environment to match the
81
+location of your Java installation."
82
+    fi
83
+else
84
+    JAVACMD="java"
85
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
+
87
+Please set the JAVA_HOME variable in your environment to match the
88
+location of your Java installation."
89
+fi
90
+
91
+# Increase the maximum file descriptors if we can.
92
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93
+    MAX_FD_LIMIT=`ulimit -H -n`
94
+    if [ $? -eq 0 ] ; then
95
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96
+            MAX_FD="$MAX_FD_LIMIT"
97
+        fi
98
+        ulimit -n $MAX_FD
99
+        if [ $? -ne 0 ] ; then
100
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
101
+        fi
102
+    else
103
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104
+    fi
105
+fi
106
+
107
+# For Darwin, add options to specify how the application appears in the dock
108
+if $darwin; then
109
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110
+fi
111
+
112
+# For Cygwin, switch paths to Windows format before running java
113
+if $cygwin ; then
114
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
+    JAVACMD=`cygpath --unix "$JAVACMD"`
117
+
118
+    # We build the pattern for arguments to be converted via cygpath
119
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
+    SEP=""
121
+    for dir in $ROOTDIRSRAW ; do
122
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
123
+        SEP="|"
124
+    done
125
+    OURCYGPATTERN="(^($ROOTDIRS))"
126
+    # Add a user-defined pattern to the cygpath arguments
127
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
+    fi
130
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
+    i=0
132
+    for arg in "$@" ; do
133
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
135
+
136
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
137
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
+        else
139
+            eval `echo args$i`="\"$arg\""
140
+        fi
141
+        i=$((i+1))
142
+    done
143
+    case $i in
144
+        (0) set -- ;;
145
+        (1) set -- "$args0" ;;
146
+        (2) set -- "$args0" "$args1" ;;
147
+        (3) set -- "$args0" "$args1" "$args2" ;;
148
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
+    esac
155
+fi
156
+
157
+# Escape application args
158
+save () {
159
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
+    echo " "
161
+}
162
+APP_ARGS=$(save "$@")
163
+
164
+# Collect all arguments for the java command, following the shell quoting and substitution rules
165
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
+
167
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169
+  cd "$(dirname "$0")"
170
+fi
171
+
172
+exec "$JAVACMD" "$@"

+ 84
- 0
example/android/gradlew.bat View File

@@ -0,0 +1,84 @@
1
+@if "%DEBUG%" == "" @echo off
2
+@rem ##########################################################################
3
+@rem
4
+@rem  Gradle startup script for Windows
5
+@rem
6
+@rem ##########################################################################
7
+
8
+@rem Set local scope for the variables with windows NT shell
9
+if "%OS%"=="Windows_NT" setlocal
10
+
11
+set DIRNAME=%~dp0
12
+if "%DIRNAME%" == "" set DIRNAME=.
13
+set APP_BASE_NAME=%~n0
14
+set APP_HOME=%DIRNAME%
15
+
16
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
+set DEFAULT_JVM_OPTS=
18
+
19
+@rem Find java.exe
20
+if defined JAVA_HOME goto findJavaFromJavaHome
21
+
22
+set JAVA_EXE=java.exe
23
+%JAVA_EXE% -version >NUL 2>&1
24
+if "%ERRORLEVEL%" == "0" goto init
25
+
26
+echo.
27
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
+echo.
29
+echo Please set the JAVA_HOME variable in your environment to match the
30
+echo location of your Java installation.
31
+
32
+goto fail
33
+
34
+:findJavaFromJavaHome
35
+set JAVA_HOME=%JAVA_HOME:"=%
36
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
+
38
+if exist "%JAVA_EXE%" goto init
39
+
40
+echo.
41
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
+echo.
43
+echo Please set the JAVA_HOME variable in your environment to match the
44
+echo location of your Java installation.
45
+
46
+goto fail
47
+
48
+:init
49
+@rem Get command-line arguments, handling Windows variants
50
+
51
+if not "%OS%" == "Windows_NT" goto win9xME_args
52
+
53
+:win9xME_args
54
+@rem Slurp the command line arguments.
55
+set CMD_LINE_ARGS=
56
+set _SKIP=2
57
+
58
+:win9xME_args_slurp
59
+if "x%~1" == "x" goto execute
60
+
61
+set CMD_LINE_ARGS=%*
62
+
63
+:execute
64
+@rem Setup the command line
65
+
66
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
+
68
+@rem Execute Gradle
69
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
+
71
+:end
72
+@rem End local scope for the variables with windows NT shell
73
+if "%ERRORLEVEL%"=="0" goto mainEnd
74
+
75
+:fail
76
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
+rem the _cmd.exe /c_ return code!
78
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
+exit /b 1
80
+
81
+:mainEnd
82
+if "%OS%"=="Windows_NT" endlocal
83
+
84
+:omega

+ 8
- 0
example/android/keystores/BUCK View File

@@ -0,0 +1,8 @@
1
+keystore(
2
+    name = "debug",
3
+    properties = "debug.keystore.properties",
4
+    store = "debug.keystore",
5
+    visibility = [
6
+        "PUBLIC",
7
+    ],
8
+)

+ 4
- 0
example/android/keystores/debug.keystore.properties View File

@@ -0,0 +1,4 @@
1
+key.store=debug.keystore
2
+key.alias=androiddebugkey
3
+key.store.password=android
4
+key.alias.password=android

+ 7
- 0
example/android/settings.gradle View File

@@ -0,0 +1,7 @@
1
+rootProject.name = 'WebViewExample'
2
+
3
+include ':app'
4
+include ':ReactNativeWebView'
5
+
6
+
7
+project(':ReactNativeWebView').projectDir = new File(rootProject.projectDir, '../../android')

+ 19
- 0
example/ios/RNCWebViewExample.xcodeproj/project.pbxproj View File

@@ -522,6 +522,7 @@
522 522
 			buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "RNCWebViewExample" */;
523 523
 			buildPhases = (
524 524
 				13B07F871A680F5B00A75B9A /* Sources */,
525
+				382B320523C3B76000E88E8C /* Launch Packager */,
525 526
 				13B07F8C1A680F5B00A75B9A /* Frameworks */,
526 527
 				13B07F8E1A680F5B00A75B9A /* Resources */,
527 528
 				00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
@@ -889,6 +890,24 @@
889 890
 			shellPath = /bin/sh;
890 891
 			shellScript = "export NODE_BINARY=node\n../../node_modules/react-native/scripts/react-native-xcode.sh\n";
891 892
 		};
893
+		382B320523C3B76000E88E8C /* Launch Packager */ = {
894
+			isa = PBXShellScriptBuildPhase;
895
+			buildActionMask = 2147483647;
896
+			files = (
897
+			);
898
+			inputFileListPaths = (
899
+			);
900
+			inputPaths = (
901
+			);
902
+			name = "Launch Packager";
903
+			outputFileListPaths = (
904
+			);
905
+			outputPaths = (
906
+			);
907
+			runOnlyForDeploymentPostprocessing = 0;
908
+			shellPath = /bin/sh;
909
+			shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n  if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n    if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n      echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n      exit 2\n    fi\n  else\n    open \"$SRCROOT/../../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n  fi\nfi\n";
910
+		};
892 911
 /* End PBXShellScriptBuildPhase section */
893 912
 
894 913
 /* Begin PBXSourcesBuildPhase section */

+ 92
- 0
example/ios/RNCWebViewExample.xcodeproj/xcshareddata/xcschemes/RNCWebViewExample.xcscheme View File

@@ -0,0 +1,92 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<Scheme
3
+   LastUpgradeVersion = "1120"
4
+   version = "1.3">
5
+   <BuildAction
6
+      parallelizeBuildables = "NO"
7
+      buildImplicitDependencies = "YES">
8
+      <BuildActionEntries>
9
+         <BuildActionEntry
10
+            buildForTesting = "YES"
11
+            buildForRunning = "YES"
12
+            buildForProfiling = "YES"
13
+            buildForArchiving = "YES"
14
+            buildForAnalyzing = "YES">
15
+            <BuildableReference
16
+               BuildableIdentifier = "primary"
17
+               BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
18
+               BuildableName = "libReact.a"
19
+               BlueprintName = "React"
20
+               ReferencedContainer = "container:../../node_modules/react-native/React/React.xcodeproj">
21
+            </BuildableReference>
22
+         </BuildActionEntry>
23
+         <BuildActionEntry
24
+            buildForTesting = "YES"
25
+            buildForRunning = "YES"
26
+            buildForProfiling = "YES"
27
+            buildForArchiving = "YES"
28
+            buildForAnalyzing = "YES">
29
+            <BuildableReference
30
+               BuildableIdentifier = "primary"
31
+               BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
32
+               BuildableName = "RNCWebViewExample.app"
33
+               BlueprintName = "RNCWebViewExample"
34
+               ReferencedContainer = "container:RNCWebViewExample.xcodeproj">
35
+            </BuildableReference>
36
+         </BuildActionEntry>
37
+      </BuildActionEntries>
38
+   </BuildAction>
39
+   <TestAction
40
+      buildConfiguration = "Debug"
41
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
42
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
43
+      shouldUseLaunchSchemeArgsEnv = "YES">
44
+      <Testables>
45
+      </Testables>
46
+   </TestAction>
47
+   <LaunchAction
48
+      buildConfiguration = "Debug"
49
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
50
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
51
+      launchStyle = "0"
52
+      useCustomWorkingDirectory = "NO"
53
+      ignoresPersistentStateOnLaunch = "NO"
54
+      debugDocumentVersioning = "YES"
55
+      debugServiceExtension = "internal"
56
+      allowLocationSimulation = "YES">
57
+      <BuildableProductRunnable
58
+         runnableDebuggingMode = "0">
59
+         <BuildableReference
60
+            BuildableIdentifier = "primary"
61
+            BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
62
+            BuildableName = "RNCWebViewExample.app"
63
+            BlueprintName = "RNCWebViewExample"
64
+            ReferencedContainer = "container:RNCWebViewExample.xcodeproj">
65
+         </BuildableReference>
66
+      </BuildableProductRunnable>
67
+   </LaunchAction>
68
+   <ProfileAction
69
+      buildConfiguration = "Release"
70
+      shouldUseLaunchSchemeArgsEnv = "YES"
71
+      savedToolIdentifier = ""
72
+      useCustomWorkingDirectory = "NO"
73
+      debugDocumentVersioning = "YES">
74
+      <BuildableProductRunnable
75
+         runnableDebuggingMode = "0">
76
+         <BuildableReference
77
+            BuildableIdentifier = "primary"
78
+            BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
79
+            BuildableName = "RNCWebViewExample.app"
80
+            BlueprintName = "RNCWebViewExample"
81
+            ReferencedContainer = "container:RNCWebViewExample.xcodeproj">
82
+         </BuildableReference>
83
+      </BuildableProductRunnable>
84
+   </ProfileAction>
85
+   <AnalyzeAction
86
+      buildConfiguration = "Debug">
87
+   </AnalyzeAction>
88
+   <ArchiveAction
89
+      buildConfiguration = "Release"
90
+      revealArchiveInOrganizer = "YES">
91
+   </ArchiveAction>
92
+</Scheme>

+ 4
- 0
package.json View File

@@ -12,6 +12,10 @@
12 12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13 13
   "scripts": {
14 14
     "start": "node node_modules/react-native/local-cli/cli.js start",
15
+    "start:android": "react-native run-android --root example/",
16
+    "start:ios": "react-native run-ios --project-path example/ios --scheme RNCWebViewExample",
17
+    "build:e2e:ios": "detox build -c ios",
18
+    "build:e2e:android": "detox build -c android",
15 19
     "ci": "CI=true && yarn lint && yarn test",
16 20
     "ci:publish": "yarn semantic-release",
17 21
     "lint": "yarn tsc --noEmit && yarn eslint ./src --ext .ts,.tsx",