Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Support #28

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4be4960
Moving files
connected-jallen Nov 8, 2016
f5653e4
changing search path for iOS subdirectory
connected-jallen Nov 8, 2016
c271da7
Initial port of react-native-sensor-manager, https://github.com/kprim…
connected-jallen Nov 8, 2016
574dd7a
Upgrade cradle
connected-jallen Nov 8, 2016
b93608a
gradlew
connected-jallen Nov 8, 2016
400ceec
Gyroscope to new method
connected-jallen Nov 8, 2016
4a1e266
Data
connected-jallen Nov 8, 2016
8f7ce3a
Merge pull request #1 from connected-lab/merge-android
connected-jallen Nov 9, 2016
9427041
More accurate on Android
connected-jallen Nov 14, 2016
3206a17
Merge remote-tracking branch 'origin/master' into android-accuracy
connected-jallen Nov 14, 2016
2931f73
Merge pull request #2 from connected-lab/android-accuracy
Josh-Allen-ConnectedLab Nov 14, 2016
1ebb6d9
Android migration
connected-lkaliazine Nov 22, 2016
cc2786f
[#134781127] Fixed project structure
connected-lkaliazine Nov 23, 2016
8d7983a
[#134781127] migrated js changes over
connected-lkaliazine Nov 23, 2016
73adadf
[#134781127] moved index.ios.js logic into a file; to share with android
connected-lkaliazine Nov 23, 2016
7d4b072
[#134781127] more modules
connected-lkaliazine Nov 23, 2016
b5a58b2
[#134781127] refactoring, simplified code; button font size increase
connected-lkaliazine Nov 23, 2016
be6f629
Merge pull request #3 from connected-lab/android-telemetry
connected-lkaliazine Nov 23, 2016
aa5d5ea
[#134781127] connected-common
connected-lkaliazine Nov 25, 2016
1adf1e8
[#134929997] added common library as an aar dependency
connected-lkaliazine Nov 28, 2016
369d651
[#134929997] fixed multiple invoke call bug, fixed build by adding li…
connected-lkaliazine Nov 28, 2016
99d0317
[#134929997] bringing back a readme that was deleted in a previous co…
connected-lkaliazine Nov 29, 2016
aa24c91
[#134929997] changing common lib dependency from branch to master
connected-lkaliazine Nov 29, 2016
4cdd3fa
Merge pull request #4 from connected-lab/android-telemetry
connected-lkaliazine Nov 29, 2016
2d8c0e8
MC: Accelerometer, Gyroscope, Magnetometer:
connected-tlip Dec 21, 2016
65d941f
Merge pull request #5 from connected-lab/update-syntax
connected-jallen Dec 22, 2016
c77bfc3
npm test
connected-jallen Dec 27, 2016
e900299
iOS > iOS
connected-jallen Dec 27, 2016
f039812
iOS > ios
connected-jallen Dec 27, 2016
bea8e0b
Delete video and react-native link connected-common
connected-jallen Dec 28, 2016
71629f5
remove iOS connected-common
connected-jallen Jan 2, 2017
9a8674d
remove connected common
connected-jallen Jan 2, 2017
044cf53
removing video again
connected-jallen Jan 3, 2017
8442d1b
updated
connected-jallen Jan 3, 2017
72c035b
docs
connected-jallen Jan 3, 2017
678fd4e
Connected-common
joshallenit Jan 4, 2017
2aa3275
delete settings.gradle
connected-jallen Jan 4, 2017
9d3a829
Merge pull request #6 from connected-lab/android-with-tests
connected-jallen Jan 4, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Example/MotionExample/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions Example/MotionExample/.buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
59 changes: 59 additions & 0 deletions Example/MotionExample/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[ignore]

# We fork some components by platform.
.*/*[.]android.js

# Ignore templates with `@flow` in header
.*/local-cli/generator.*

# Ignore malformed json
.*/node_modules/y18n/test/.*\.json

# Ignore the website subdir
<PROJECT_ROOT>/website/.*

# Ignore BUCK generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
.*/node_modules/.*/node_modules/fbjs/.*

# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
flow/

[options]
module.system=haste

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

experimental.strict_type_args=true

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true

[version]
^0.33.0
40 changes: 40 additions & 0 deletions Example/MotionExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IJ
#
*.iml
.idea
.gradle
local.properties

# node.js
#
node_modules/
npm-debug.log

# BUCK
buck-out/
\.buckd/
*.keystore
1 change: 1 addition & 0 deletions Example/MotionExample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
12 changes: 6 additions & 6 deletions Example/MotionExample/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# react-native-motion-manager

# MotionManager
This is a react app that shows how to write obj-c wrappers around the iOS [CMMotionManager](https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionManager_Class/)
library.
This is a react app that shows how to write obj-c and Android wrappers around the iOS [CMMotionManager](https://developer.apple.com/library/ios/documentation/CoreMotion/Reference/CMMotionManager_Class/) and Android Sensor
libraries.
# Usage

If you just want to see this code in action, checkout the code and fire up the xcodeproj and run it.

If you're trying to integrate this into your app, its a little bit tricky. I don't quite know how to package this up so you can just `npm install` it. Coming soon though!

At this point, just copy and paste `iOS/Accelerometer.h` + `iOS/Accelerometer.m` (or Gyroscope or Magnetomer) into your `iOS` folder.
At this point, just copy and paste `iOS/Accelerometer.h` + `iOS/Accelerometer.m` (or Gyroscope or Magnetomer) into your `iOS` folder.


Does anyone know how to share react-native components that are wrappers around native utilities?
There must be a better way to package this stuff...
Does anyone know how to share react-native components that are wrappers around native utilities?
There must be a better way to package this stuff...

# Api

Expand Down Expand Up @@ -77,4 +77,4 @@ Magnetometer.stopMagnetometerUpdates();
![](http://pwmckenna.com/react-native-motion-manager/motion.png)
![](http://pwmckenna.com/react-native-motion-manager/accelerometer.png)
![](http://pwmckenna.com/react-native-motion-manager/gyroscope.png)
![](http://pwmckenna.com/react-native-motion-manager/magnetometer.png)
![](http://pwmckenna.com/react-native-motion-manager/magnetometer.png)
66 changes: 66 additions & 0 deletions Example/MotionExample/android/app/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import re

# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#

lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)

for aarfile in glob(['libs/*.aar']):
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)

android_library(
name = 'all-libs',
exported_deps = lib_deps
)

android_library(
name = 'app-code',
srcs = glob([
'src/main/java/**/*.java',
]),
deps = [
':all-libs',
':build_config',
':res',
],
)

android_build_config(
name = 'build_config',
package = 'com.motionexample',
)

android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.motionexample',
)

android_binary(
name = 'app',
package_type = 'debug',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//android/keystores:debug',
deps = [
':app-code',
],
)
148 changes: 148 additions & 0 deletions Example/MotionExample/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"]
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/

apply from: "../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false

/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.motionexample"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}

repositories {
flatDir {
dirs 'libs'
}
}

dependencies {
compile 'com.connectedlab.reactnative.commonlib:commonlib:1.0@aar'
compile project(':react-native-motion-manager')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'org.apache.commons:commons-lang3:3.5'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Binary file not shown.