Skip to content

Commit bab2bc4

Browse files
committed
Example updated
1 parent 5877365 commit bab2bc4

21 files changed

+244
-181
lines changed

Example/.flowconfig

+21-9
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77
# Some modules have their own node_modules with overlap
88
.*/node_modules/node-haste/.*
99

10-
# Ignore react-tools where there are overlaps, but don't ignore anything that
11-
# react-native relies on
12-
.*/node_modules/react-tools/src/React.js
13-
.*/node_modules/react-tools/src/renderers/shared/event/EventPropagators.js
14-
.*/node_modules/react-tools/src/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
15-
.*/node_modules/react-tools/src/shared/vendor/core/ExecutionEnvironment.js
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs-haste/.*/__tests__/.*
18+
.*/node_modules/fbjs-haste/__forks__/Map.js
19+
.*/node_modules/fbjs-haste/__forks__/Promise.js
20+
.*/node_modules/fbjs-haste/__forks__/fetch.js
21+
.*/node_modules/fbjs-haste/core/ExecutionEnvironment.js
22+
.*/node_modules/fbjs-haste/core/isEmpty.js
23+
.*/node_modules/fbjs-haste/crypto/crc32.js
24+
.*/node_modules/fbjs-haste/stubs/ErrorUtils.js
25+
.*/node_modules/react-haste/React.js
26+
.*/node_modules/react-haste/renderers/dom/ReactDOM.js
27+
.*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js
1628

1729
# Ignore commoner tests
1830
.*/node_modules/commoner/test/.*
@@ -43,9 +55,9 @@ suppress_type=$FlowIssue
4355
suppress_type=$FlowFixMe
4456
suppress_type=$FixMe
4557

46-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
47-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
58+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
59+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-8]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
4860
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4961

5062
[version]
51-
0.16.0
63+
0.18.1

Example/.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25+
# Android/IJ
26+
#
27+
.idea
28+
.gradle
29+
local.properties
30+
2531
# node.js
2632
#
2733
node_modules/
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#Fri Oct 09 15:36:36 EDT 2015
1+
#Thu Dec 10 17:52:41 EST 2015
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Example/android/app/build.gradle

+55-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
1-
apply plugin: 'com.android.application'
1+
apply plugin: "com.android.application"
2+
3+
/**
4+
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
5+
* These basically call `react-native bundle` with the correct arguments during the Android build
6+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
7+
* bundle directly from the development server. Below you can see all the possible configurations
8+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
9+
* `apply from: "react.gradle"` line.
10+
*
11+
* project.ext.react = [
12+
* // the name of the generated asset file containing your JS bundle
13+
* bundleAssetName: "index.android.bundle",
14+
*
15+
* // the entry file for bundle generation
16+
* entryFile: "index.android.js",
17+
*
18+
* // whether to bundle JS and assets in debug mode
19+
* bundleInDebug: false,
20+
*
21+
* // whether to bundle JS and assets in release mode
22+
* bundleInRelease: true,
23+
*
24+
* // the root of your project, i.e. where "package.json" lives
25+
* root: "../../",
26+
*
27+
* // where to put the JS bundle asset in debug mode
28+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
29+
*
30+
* // where to put the JS bundle asset in release mode
31+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
32+
*
33+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
34+
* // require('./image.png')), in debug mode
35+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
36+
*
37+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
38+
* // require('./image.png')), in release mode
39+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
40+
*
41+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
42+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
43+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
44+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
45+
* // for example, you might want to remove it from here.
46+
* inputExcludes: ["android/**", "ios/**"]
47+
* ]
48+
*/
49+
50+
apply from: "react.gradle"
251

352
android {
453
compileSdkVersion 23
@@ -16,14 +65,14 @@ android {
1665
}
1766
buildTypes {
1867
release {
19-
minifyEnabled false
20-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
68+
minifyEnabled false // Set this to true to enable Proguard
69+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
2170
}
2271
}
2372
}
2473

2574
dependencies {
26-
compile fileTree(dir: 'libs', include: ['*.jar'])
27-
compile 'com.android.support:appcompat-v7:23.0.1'
28-
compile 'com.facebook.react:react-native:0.12.+'
75+
compile fileTree(dir: "libs", include: ["*.jar"])
76+
compile "com.android.support:appcompat-v7:23.0.1"
77+
compile "com.facebook.react:react-native:0.16.+"
2978
}

Example/android/app/proguard-rules.pro

+43
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,46 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
# Disabling obfuscation is useful if you collect stack traces from production crashes
20+
# (unless you are using a system that supports de-obfuscate the stack traces).
21+
-dontobfuscate
22+
23+
# React Native
24+
25+
# Keep our interfaces so they can be used by other ProGuard rules.
26+
# See http://sourceforge.net/p/proguard/bugs/466/
27+
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28+
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29+
30+
# Do not strip any method/class that is annotated with @DoNotStrip
31+
-keep @com.facebook.proguard.annotations.DoNotStrip class *
32+
-keepclassmembers class * {
33+
@com.facebook.proguard.annotations.DoNotStrip *;
34+
}
35+
36+
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
37+
void set*(***);
38+
*** get*();
39+
}
40+
41+
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
42+
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
43+
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
44+
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
45+
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
46+
47+
# okhttp
48+
49+
-keepattributes Signature
50+
-keepattributes *Annotation*
51+
-keep class com.squareup.okhttp.** { *; }
52+
-keep interface com.squareup.okhttp.** { *; }
53+
-dontwarn com.squareup.okhttp.**
54+
55+
# okio
56+
57+
-keep class sun.misc.Unsafe { *; }
58+
-dontwarn java.nio.file.*
59+
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
60+
-dontwarn okio.**

Example/android/app/react.gradle

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import org.apache.tools.ant.taskdefs.condition.Os
2+
3+
def config = project.hasProperty("react") ? project.react : [];
4+
5+
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
6+
def entryFile = config.entryFile ?: "index.android.js"
7+
8+
// because elvis operator
9+
def elvisFile(thing) {
10+
return thing ? file(thing) : null;
11+
}
12+
13+
def reactRoot = elvisFile(config.root) ?: file("../../")
14+
def jsBundleDirDebug = elvisFile(config.jsBundleDirDebug) ?:
15+
file("$buildDir/intermediates/assets/debug")
16+
def jsBundleDirRelease = elvisFile(config.jsBundleDirRelease) ?:
17+
file("$buildDir/intermediates/assets/release")
18+
def resourcesDirDebug = elvisFile(config.resourcesDirDebug) ?:
19+
file("$buildDir/intermediates/res/merged/debug")
20+
def resourcesDirRelease = elvisFile(config.resourcesDirRelease) ?:
21+
file("$buildDir/intermediates/res/merged/release")
22+
def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
23+
24+
def jsBundleFileDebug = file("$jsBundleDirDebug/$bundleAssetName")
25+
def jsBundleFileRelease = file("$jsBundleDirRelease/$bundleAssetName")
26+
27+
task bundleDebugJsAndAssets(type: Exec) {
28+
// create dirs if they are not there (e.g. the "clean" task just ran)
29+
doFirst {
30+
jsBundleDirDebug.mkdirs()
31+
resourcesDirDebug.mkdirs()
32+
}
33+
34+
// set up inputs and outputs so gradle can cache the result
35+
inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
36+
outputs.dir jsBundleDirDebug
37+
outputs.dir resourcesDirDebug
38+
39+
// set up the call to the react-native cli
40+
workingDir reactRoot
41+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
42+
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
43+
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
44+
} else {
45+
commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
46+
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
47+
}
48+
49+
enabled config.bundleInDebug ?: false
50+
}
51+
52+
task bundleReleaseJsAndAssets(type: Exec) {
53+
// create dirs if they are not there (e.g. the "clean" task just ran)
54+
doFirst {
55+
jsBundleDirRelease.mkdirs()
56+
resourcesDirRelease.mkdirs()
57+
}
58+
59+
// set up inputs and outputs so gradle can cache the result
60+
inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
61+
outputs.dir jsBundleDirRelease
62+
outputs.dir resourcesDirRelease
63+
64+
// set up the call to the react-native cli
65+
workingDir reactRoot
66+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
67+
commandLine "cmd","/c", "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
68+
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
69+
} else {
70+
commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
71+
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
72+
}
73+
74+
enabled config.bundleInRelease ?: true
75+
}
76+
77+
gradle.projectsEvaluated {
78+
// hook bundleDebugJsAndAssets into the android build process
79+
bundleDebugJsAndAssets.dependsOn mergeDebugResources
80+
bundleDebugJsAndAssets.dependsOn mergeDebugAssets
81+
processDebugResources.dependsOn bundleDebugJsAndAssets
82+
83+
// hook bundleReleaseJsAndAssets into the android build process
84+
bundleReleaseJsAndAssets.dependsOn mergeReleaseResources
85+
bundleReleaseJsAndAssets.dependsOn mergeReleaseAssets
86+
processReleaseResources.dependsOn bundleReleaseJsAndAssets
87+
}

Example/android/app/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
android:theme="@style/AppTheme">
1111
<activity
1212
android:name=".MainActivity"
13-
android:label="@string/app_name">
13+
android:label="@string/app_name"
14+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
1415
<intent-filter>
1516
<action android:name="android.intent.action.MAIN" />
1617
<category android:name="android.intent.category.LAUNCHER" />

Example/android/app/src/main/java/com/example/MainActivity.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ protected void onCreate(Bundle savedInstanceState) {
2323

2424
mReactInstanceManager = ReactInstanceManager.builder()
2525
.setApplication(getApplication())
26-
.setBundleAssetName("index.bundle")
27-
.setJSMainModuleName("index")
26+
.setBundleAssetName("index.android.bundle")
27+
.setJSMainModuleName("index.android")
2828
.addPackage(new MainReactPackage())
2929
.setUseDeveloperSupport(BuildConfig.DEBUG)
3030
.setInitialLifecycleState(LifecycleState.RESUMED)
@@ -72,7 +72,7 @@ protected void onResume() {
7272
super.onResume();
7373

7474
if (mReactInstanceManager != null) {
75-
mReactInstanceManager.onResume(this);
75+
mReactInstanceManager.onResume(this, this);
7676
}
7777
}
7878
}

Example/android/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ allprojects {
1616
repositories {
1717
mavenLocal()
1818
jcenter()
19+
jcenter {
20+
url "http://dl.bintray.com/mkonicek/maven"
21+
}
1922
}
2023
}

Example/iOS/main.jsbundle

-8
This file was deleted.

Example/index.android.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./index.ios');

Example/index.js renamed to Example/index.ios.js

-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ var styles = StyleSheet.create({
2323
alignItems: 'center'
2424
},
2525

26-
modal1: {
27-
flex: 1
28-
},
29-
3026
modal2: {
3127
height: 230,
3228
backgroundColor: "#3B5998"

0 commit comments

Comments
 (0)