Skip to content

Commit 45147d3

Browse files
committed
[Android] Initial Android files
1 parent 9c02f49 commit 45147d3

22 files changed

+592
-7
lines changed

.flowconfig

+22-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
# Ignore react-tools where there are overlaps, but don't ignore anything that
1111
# react-native relies on
12-
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
13-
.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js
14-
.*/node_modules/react-tools/src/browser/ui/React.js
15-
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
16-
.*/node_modules/react-tools/src/event/EventPropagators.js
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
1716

1817
# Ignore commoner tests
1918
.*/node_modules/commoner/test/.*
@@ -22,7 +21,10 @@
2221
.*/react-tools/node_modules/commoner/lib/reader.js
2322

2423
# Ignore jest
25-
.*/react-native/node_modules/jest-cli/.*
24+
.*/node_modules/jest-cli/.*
25+
26+
# Ignore Website
27+
.*/website/.*
2628

2729
[include]
2830

@@ -32,5 +34,18 @@ node_modules/react-native/Libraries/react-native/react-native-interface.js
3234
[options]
3335
module.system=haste
3436

37+
munge_underscores=true
38+
39+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
40+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
41+
42+
suppress_type=$FlowIssue
43+
suppress_type=$FlowFixMe
44+
suppress_type=$FixMe
45+
46+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-7]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-7]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
49+
3550
[version]
36-
0.11.0
51+
0.17.0

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ DerivedData
5353
*.ipa
5454
*.xcuserstate
5555
project.xcworkspace
56+
57+
### Android/IJ ###
58+
#
59+
.idea
60+
.gradle
61+
local.properties

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

android/app/build.gradle

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
applicationId "com.reactnativenwreactcalculator"
9+
minSdkVersion 16
10+
targetSdkVersion 22
11+
versionCode 1
12+
versionName "1.0"
13+
ndk {
14+
abiFilters "armeabi-v7a", "x86"
15+
}
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false // Set this to true to enable Proguard
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
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.13.+'
29+
}

android/app/proguard-rules.pro

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
#}
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.**
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.reactnativenwreactcalculator">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:allowBackup="true"
8+
android:label="@string/app_name"
9+
android:icon="@mipmap/ic_launcher"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name=".MainActivity"
13+
android:label="@string/app_name">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
<category android:name="android.intent.category.LAUNCHER" />
17+
</intent-filter>
18+
</activity>
19+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
20+
</application>
21+
22+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.reactnativenwreactcalculator;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.view.KeyEvent;
6+
7+
import com.facebook.react.LifecycleState;
8+
import com.facebook.react.ReactInstanceManager;
9+
import com.facebook.react.ReactRootView;
10+
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
11+
import com.facebook.react.shell.MainReactPackage;
12+
import com.facebook.soloader.SoLoader;
13+
14+
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
15+
16+
private ReactInstanceManager mReactInstanceManager;
17+
private ReactRootView mReactRootView;
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
mReactRootView = new ReactRootView(this);
23+
24+
mReactInstanceManager = ReactInstanceManager.builder()
25+
.setApplication(getApplication())
26+
.setBundleAssetName("index.android.bundle")
27+
.setJSMainModuleName("index.android")
28+
.addPackage(new MainReactPackage())
29+
.setUseDeveloperSupport(BuildConfig.DEBUG)
30+
.setInitialLifecycleState(LifecycleState.RESUMED)
31+
.build();
32+
33+
mReactRootView.startReactApplication(mReactInstanceManager, "ReactNativeNWReactCalculator", null);
34+
35+
setContentView(mReactRootView);
36+
}
37+
38+
@Override
39+
public boolean onKeyUp(int keyCode, KeyEvent event) {
40+
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
41+
mReactInstanceManager.showDevOptionsDialog();
42+
return true;
43+
}
44+
return super.onKeyUp(keyCode, event);
45+
}
46+
47+
@Override
48+
public void onBackPressed() {
49+
if (mReactInstanceManager != null) {
50+
mReactInstanceManager.onBackPressed();
51+
} else {
52+
super.onBackPressed();
53+
}
54+
}
55+
56+
@Override
57+
public void invokeDefaultOnBackPressed() {
58+
super.onBackPressed();
59+
}
60+
61+
@Override
62+
protected void onPause() {
63+
super.onPause();
64+
65+
if (mReactInstanceManager != null) {
66+
mReactInstanceManager.onPause();
67+
}
68+
}
69+
70+
@Override
71+
protected void onResume() {
72+
super.onResume();
73+
74+
if (mReactInstanceManager != null) {
75+
mReactInstanceManager.onResume(this);
76+
}
77+
}
78+
}

android/app/src/main/main.iml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$" />
6+
<orderEntry type="inheritedJdk" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">ReactNativeNWReactCalculator</string>
3+
</resources>
Original file line numberDiff line numberDiff line change
@@ -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>

android/build.gradle

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
3+
buildscript {
4+
repositories {
5+
jcenter()
6+
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:1.3.1'
9+
10+
// NOTE: Do not place your application dependencies here; they belong
11+
// in the individual module build.gradle files
12+
}
13+
}
14+
15+
allprojects {
16+
repositories {
17+
mavenLocal()
18+
jcenter()
19+
}
20+
}

android/gradle.properties

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
android.useDeprecatedNdk=true
51 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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-2.4-all.zip

0 commit comments

Comments
 (0)