Skip to content

Commit

Permalink
Replace hated Mapbox with react-native-maps from AirBnb. Upgrade to l…
Browse files Browse the repository at this point in the history
…atest RN 0.42.0
  • Loading branch information
christocracy committed Mar 12, 2017
1 parent 4e435ad commit f3405b2
Show file tree
Hide file tree
Showing 91 changed files with 2,653 additions and 5,443 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
31 changes: 18 additions & 13 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

# We fork some components by platform.
.*/*.android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

# Ignore templates with `@flow` in header
.*/local-cli/generator.*
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

# Ignore malformed json
.*/node_modules/y18n/test/.*\.json
; 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

[include]

Expand All @@ -17,25 +22,25 @@ node_modules/react-native/flow
flow/

[options]
module.system=haste
emoji=true

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
module.system=haste

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\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|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.27.0
^0.38.0
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
2 changes: 1 addition & 1 deletion android/RNBackgroundGeolocationSample.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="RNBackgroundGeolocationSample" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$USER_HOME$/workspace/react/background-geolocation/rn-background-geolocation-demo/android" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="RNBackgroundGeolocationSample" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$USER_HOME$/workspace/react/background-geolocation/tmp/rn-background-geolocation-demo/android" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion android/app/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import re
# - 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`
# - `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
#
Expand Down
12 changes: 9 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def enableProguardInReleaseBuilds = true
android {
compileSdkVersion 23
buildToolsVersion "25.0.1"

defaultConfig {
applicationId "com.transistorsoft.backgroundgeolocation.react"
minSdkVersion 16
Expand All @@ -95,6 +94,7 @@ android {
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
signingConfigs {
release {
Expand Down Expand Up @@ -147,13 +147,19 @@ repositories {
}

dependencies {
compile project(':react-native-maps')
compile project(':react-native-device-info')
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 project(':react-native-background-geolocation')
compile(name: 'tslocationmanager', ext: 'aar')
compile project(':react-native-vector-icons')
compile project(':reactnativemapboxgl')
compile project(':RNDeviceInfo')
}

// 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'
}
10 changes: 1 addition & 9 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,10 @@
</activity>

<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

<service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService"/>

<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCx44mBvcd9vOgrRdqw0-ZhwwFJFh4sXDM"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyCINS2dyuBipK8MZzOQnzyKdrS2I1_b5I4"/>

<meta-data android:name="com.transistorsoft.locationmanager.license" android:value="YOUR_LICENSE_KEY_HERE" />

</application>

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
package com.transistorsoft.backgroundgeolocation.react;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.airbnb.android.react.maps.MapsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

import com.transistorsoft.rnbackgroundgeolocation.*;
import com.oblador.vectoricons.VectorIconsPackage;
import com.mapbox.reactnativemapboxgl.ReactNativeMapboxGLPackage;
import com.learnium.RNDeviceInfo.*;
import com.learnium.RNDeviceInfo.RNDeviceInfo;

public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MapsPackage(),
new RNBackgroundGeolocation(), // <-- for background-geolocation
new VectorIconsPackage(),
new ReactNativeMapboxGLPackage(),
new RNDeviceInfo() // react-native-device-info
);
}
};
);
}
};

@Override
public ReactNativeHost getReactNativeHost() {
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 14 17:14:11 EST 2016
#Sat Mar 11 11:57:01 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
8 changes: 8 additions & 0 deletions android/keystores/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
keystore(
name = 'debug',
store = 'debug.keystore',
properties = 'debug.keystore.properties',
visibility = [
'PUBLIC',
],
)
4 changes: 4 additions & 0 deletions android/keystores/debug.keystore.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
key.store=debug.keystore
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android
7 changes: 4 additions & 3 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
rootProject.name = 'RNBackgroundGeolocationSample'
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

include ':app'

Expand All @@ -8,8 +12,5 @@ project(':react-native-background-geolocation').projectDir = new File(rootProjec
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')

include ':RNDeviceInfo'
project(':RNDeviceInfo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')

include ':reactnativemapboxgl'
project(':reactnativemapboxgl').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mapbox-gl/android')
9 changes: 7 additions & 2 deletions components/BottomToolbarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ var BottomToolbarView = React.createClass({
spinner = Config.icons.spinner;
}
return (
<View style={styles.paceButtonContainer}>{spinner}{button}</View>
<View style={styles.paceButtonContainer}>
{spinner}
<View style={[style, {flexDirection: 'row'}]}>{button}</View>
</View>
);
},

render: function() {
return (
<View style={styles.bottomToolbar}>
<View style={styles.navigateContainer}>
<Icon.Button name={Config.icons.navigate} onPress={this.onClickLocate} size={30} color="#000" backgroundColor="transparent" style={styles.btnNavigate} />
<Icon.Button name={Config.icons.navigate} onPress={this.onClickLocate} size={30} color="black" backgroundColor="transparent" style={styles.btnNavigate} />
{Config.getLocationProviders(this.state.currentProvider)}
</View>
<View style={styles.statusContainer}>
Expand All @@ -166,6 +169,8 @@ var BottomToolbarView = React.createClass({

var styles = StyleSheet.create({
bottomToolbar: {
borderTopColor: '#ccc',
borderTopWidth: 1,
backgroundColor: '#eee',
flexDirection: 'row',
height: 50
Expand Down
41 changes: 38 additions & 3 deletions components/DebugView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const logLevelOptions = ["OFF", "ERROR", "WARN", "ALL"];
const distanceFilterOptions = [0, 10, 20, 50, 100, 500];
const geofenceProximityRadiusOptions = ['1km', '2km', '5km', '10km'];
const autoSyncThresholdOptions = [0, 5, 10, 25, 50, 100];
const heartbeatIntervalOptions = [60, 120, 240, 600];

function renderRadioOption(option, selected, onSelect, index){
var containerStyle, textStyle = {};
Expand Down Expand Up @@ -88,12 +89,14 @@ var DebugView = React.createClass({
batchSync: state.batchSync,
stopOnTerminate: state.stopOnTerminate,
startOnBoot: state.startOnBoot,
heartbeatInterval: state.heartbeatInterval,
logLevel: logLevel,
debug: state.debug,
trackingMode: trackingMode,
// Platform: Android
foregroundService: state.foregroundService,
foo: state.bar
// Platform: iOS
preventSuspend: state.preventSuspend
});
}.bind(this));

Expand All @@ -115,6 +118,7 @@ var DebugView = React.createClass({
batchSync: false,
stopOnTerminate: true,
startOnBoot: false,
heartbeatInterval: 60,
email: undefined,
logLevel: 'ALL',
debug: true,
Expand All @@ -127,7 +131,9 @@ var DebugView = React.createClass({
isSyncing: false,
isEmailingLog: false,
// Platform: Android
foregroundService: false
foregroundService: false,
// Platform: iOS
preventSuspend: false
};
},

Expand Down Expand Up @@ -167,6 +173,12 @@ var DebugView = React.createClass({
this.setState(state);
},

onClickResetOdometer() {
var bgGeo = this.bgGeo;
this.bgGeo.playSound(SettingsService.getSoundId('BUTTON_CLICK'));
bgGeo.resetOdometer();
},

onClickSync() {
this.setState({isSyncing: true});
var bgGeo = this.bgGeo;
Expand Down Expand Up @@ -315,6 +327,13 @@ var DebugView = React.createClass({
<Switch value={this.state.foregroundService} onValueChange={this.createSetter('foregroundService')} />
</View>
);
} else if (platform === 'ios') {
return (
<View style={styles.setting}>
<Text style={styles.label}>preventSuspend</Text>
<Switch value={this.state.preventSuspend} onValueChange={this.createSetter('preventSuspend')} />
</View>
);
}
}
},
Expand Down Expand Up @@ -373,7 +392,13 @@ var DebugView = React.createClass({
renderContainer={renderRadioContainer}
/>
</View>

<View style={styles.setting}>
<View style={styles.label}>
<Button onPress={this.onClickResetOdometer} activeOpacity={0.7} style={[styles.button, styles.redButton]} textStyle={styles.buttonLabel}>
Reset Odometer
</Button>
</View>
</View>
</View>
</View>

Expand Down Expand Up @@ -443,6 +468,16 @@ var DebugView = React.createClass({
/>
</View>
{this.getPlatformSettings('application')}
<View style={styles.setting}>
<Text style={styles.label}>heartbeatInterval</Text>
<RadioButtons
options={ heartbeatIntervalOptions }
onSelection={this.createSetter('heartbeatInterval')}
selectedOption={this.state.heartbeatInterval }
renderOption={ renderRadioOption }
renderContainer={renderRadioContainer}
/>
</View>
</View>
</View>

Expand Down
Loading

0 comments on commit f3405b2

Please sign in to comment.