From 47e3b02f61546e54a6c1ecb724914e8583472280 Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Fri, 18 Nov 2016 15:50:21 +0500 Subject: [PATCH 01/11] - Min SDK version to 16 - Removed unused dependency --- android/build.gradle | 3 +-- .../reactnativeheading/ReactNativeHeadingModule.java | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 55dc946..44b81d3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -15,7 +15,7 @@ android { buildToolsVersion "23.0.1" defaultConfig { - minSdkVersion 18 + minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" @@ -31,5 +31,4 @@ repositories { dependencies { compile 'com.facebook.react:react-native:0.20.+' - compile "com.joshblour.discovery:discovery:0.0.3" } diff --git a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java index 6875d34..67d147d 100755 --- a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java +++ b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java @@ -20,8 +20,6 @@ import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.modules.core.DeviceEventManagerModule; -import com.joshblour.discovery.BLEUser; -import com.joshblour.discovery.Discovery; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -37,7 +35,7 @@ public class ReactNativeHeadingModule extends ReactContextBaseJavaModule impleme private static Context mApplicationContext; private int mAzimuth = 0; // degree private int newAzimuth = 0; // degree - private float mFilter = 5; + private int mFilter = 5; private SensorManager mSensorManager; private Sensor mSensor; private float[] orientation = new float[3]; From c9b5c698a9f3af8e6887c5ee11f2d695d8b167d3 Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Thu, 18 Jan 2018 14:46:56 +0500 Subject: [PATCH 02/11] Refactoring and RN version update --- .gitignore | 1 + ReactNativeHeading.android.js | 10 --------- ReactNativeHeading.h | 5 ++--- ReactNativeHeading.ios.js | 6 ----- ReactNativeHeading.js | 12 ++++++++++ ReactNativeHeading.m | 8 ++++--- android/build.gradle | 2 +- .../ReactNativeHeadingModule.java | 3 --- .../ReactNativeHeadingPackage.java | 5 ----- react-native-heading.podspec | 22 +++++++++++++++++++ 10 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 .gitignore delete mode 100644 ReactNativeHeading.android.js delete mode 100644 ReactNativeHeading.ios.js create mode 100644 ReactNativeHeading.js create mode 100644 react-native-heading.podspec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/ReactNativeHeading.android.js b/ReactNativeHeading.android.js deleted file mode 100644 index 87dac21..0000000 --- a/ReactNativeHeading.android.js +++ /dev/null @@ -1,10 +0,0 @@ -/** * - * @providesModule ReactNativeHeading - * @flow - */ -'use strict'; - -var React = require('react-native'); -var ReactNativeHeading = React.NativeModules.ReactNativeHeading; - -module.exports = ReactNativeHeading; diff --git a/ReactNativeHeading.h b/ReactNativeHeading.h index 2ae0d8d..f760db6 100644 --- a/ReactNativeHeading.h +++ b/ReactNativeHeading.h @@ -6,9 +6,8 @@ // Copyright © 2016 Yonah Forst. All rights reserved. // #import +#import -#import - -@interface ReactNativeHeading : NSObject +@interface ReactNativeHeading : RCTEventEmitter @end diff --git a/ReactNativeHeading.ios.js b/ReactNativeHeading.ios.js deleted file mode 100644 index b3e92e4..0000000 --- a/ReactNativeHeading.ios.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var React = require('react-native'); -var Heading = React.NativeModules.ReactNativeHeading; - -module.exports = Heading; diff --git a/ReactNativeHeading.js b/ReactNativeHeading.js new file mode 100644 index 0000000..b79b49b --- /dev/null +++ b/ReactNativeHeading.js @@ -0,0 +1,12 @@ +/** + * + * @providesModule ReactNativeHeading + * + */ +'use strict'; + +import { + NativeModules +} from 'react-native'; + +export default NativeModules.ReactNativeHeading; \ No newline at end of file diff --git a/ReactNativeHeading.m b/ReactNativeHeading.m index d573b45..bca329e 100644 --- a/ReactNativeHeading.m +++ b/ReactNativeHeading.m @@ -54,6 +54,10 @@ - (instancetype)init [self.locManager stopUpdatingHeading]; } +- (NSArray *)supportedEvents { + return @[@"headingUpdated"]; +} + - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { if (newHeading.headingAccuracy < 0) return; @@ -62,9 +66,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading CLLocationDirection heading = ((newHeading.trueHeading > 0) ? newHeading.trueHeading : newHeading.magneticHeading); - NSDictionary *headingEvent = @{@"heading": @(heading)}; - - [self.bridge.eventDispatcher sendDeviceEventWithName:@"headingUpdated" body:headingEvent]; + [self sendEventWithName:@"headingUpdated" body:@(heading)]; } @end diff --git a/android/build.gradle b/android/build.gradle index 44b81d3..dc4f79d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -30,5 +30,5 @@ repositories { } dependencies { - compile 'com.facebook.react:react-native:0.20.+' + compile 'com.facebook.react:react-native:+' } diff --git a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java index 67d147d..c62b481 100755 --- a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java +++ b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingModule.java @@ -51,9 +51,6 @@ public String getName() { return "ReactNativeHeading"; } - - - @ReactMethod public void start(int filter, Promise promise) { diff --git a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingPackage.java b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingPackage.java index df0e4be..24e0bf7 100755 --- a/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingPackage.java +++ b/android/src/main/java/com/joshblour/reactnativeheading/ReactNativeHeadingPackage.java @@ -24,11 +24,6 @@ public List createNativeModules(ReactApplicationContext reactConte modules.add(new ReactNativeHeadingModule(reactContext)); return modules; } - @Override - public List> createJSModules() { - return Collections.emptyList(); - } - @Override public List createViewManagers(ReactApplicationContext reactContext) { return Arrays.asList(); diff --git a/react-native-heading.podspec b/react-native-heading.podspec new file mode 100644 index 0000000..c7a3f5e --- /dev/null +++ b/react-native-heading.podspec @@ -0,0 +1,22 @@ +require 'json' + +package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) + +Pod::Spec.new do |s| + s.name = 'react-native-heading' + s.version = package['version'] + s.summary = package['description'] + s.description = package['description'] + s.license = package['license'] + s.author = package['author'] + s.homepage = package['homepage'] + s.source = { :git => 'https://github.com/zsajjad/react-native-heading', :tag => s.version } + + s.requires_arc = true + s.platform = :ios, '8.0' + + s.preserve_paths = 'LICENSE', 'README.md', 'package.json', 'ReactNativeHeading.ios.js' + s.source_files = '*.{h,m}' + + s.dependency 'React' +end From 0f3f00a67deda9f82a1bc77e6a50db70e7ea0b2b Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Thu, 18 Jan 2018 14:50:31 +0500 Subject: [PATCH 03/11] Update documentation --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f6cc73..b6d5bf1 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Report back device orientation in degrees, 0-360, with 0 being North. #### Example ```java -const { DeviceEventEmitter } = require('react-native'); -const ReactNativeHeading = require('react-native-heading'); +import { DeviceEventEmitter } from 'react-native'; +import ReactNativeHeading from 'react-native-heading'; //.... componentDidMount() { @@ -18,8 +18,8 @@ const ReactNativeHeading = require('react-native-heading'); }) }) - DeviceEventEmitter.addListener('headingUpdated', data => { - console.log('New heading is:', data.heading); + DeviceEventEmitter.addListener('headingUpdated', heading => { + console.log('New heading is:', heading); }); } From 38a45d3220bf5db745af3a7ff25791aa582063e5 Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Thu, 18 Jan 2018 14:52:33 +0500 Subject: [PATCH 04/11] Update documentation --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b6d5bf1..8764d69 100644 --- a/README.md +++ b/README.md @@ -45,9 +45,9 @@ import ReactNativeHeading from 'react-native-heading'; ## Setup -```` -npm install --save react-native-heading -```` +``` +yarn add https://github.com/zsajjad/react-native-heading.git +``` ### iOS * Run open node_modules/react-native-heading From b0c75120668ce17f860c61d04ee866d18ab901ae Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Thu, 18 Jan 2018 14:53:37 +0500 Subject: [PATCH 05/11] Update documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8764d69..aee38fa 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Get device heading information on iOS or Android Report back device orientation in degrees, 0-360, with 0 being North. #### Example -```java +```javascript import { DeviceEventEmitter } from 'react-native'; import ReactNativeHeading from 'react-native-heading'; From 7b7037a1ac5b4e5d3ae5e5cfc6da91fa21f1f93b Mon Sep 17 00:00:00 2001 From: Cristiano Santos Date: Mon, 5 Mar 2018 11:20:11 +0000 Subject: [PATCH 06/11] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aee38fa..461dacf 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Report back device orientation in degrees, 0-360, with 0 being North. #### Example ```javascript import { DeviceEventEmitter } from 'react-native'; -import ReactNativeHeading from 'react-native-heading'; +import ReactNativeHeading from '@zsajjad/react-native-heading'; //.... componentDidMount() { @@ -50,8 +50,9 @@ yarn add https://github.com/zsajjad/react-native-heading.git ``` ### iOS -* Run open node_modules/react-native-heading -* Drag ReactNativeHeading.xcodeproj into your Libraries group +* Run open node_modules/@zsajjad/react-native-heading +* Drag ReactNativeHeading.xcodeproj into your Libraries group of XCode's project navigator +* In XCode add Libraries/ReactNativeHeading.xcodeproj/Products/libReactNativeHeading.a to the "Link Binary with Libraries" section of the Build Phases ### Android ##### Step 1 - Update Gradle Settings @@ -61,7 +62,7 @@ yarn add https://github.com/zsajjad/react-native-heading.git ... include ':react-native-heading' -project(':react-native-heading').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-heading/android') +project(':react-native-heading').projectDir = new File(rootProject.projectDir, '../node_modules/@zsajjad/react-native-heading/android') ``` ##### Step 2 - Update Gradle Build From 6ab5f023d799a8b6f84af4b88038c2bc4f865b1b Mon Sep 17 00:00:00 2001 From: Cristiano Santos Date: Mon, 5 Mar 2018 11:43:09 +0000 Subject: [PATCH 07/11] Updated README according to react-native 0.49.3 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 461dacf..6bbe0a3 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,12 @@ Report back device orientation in degrees, 0-360, with 0 being North. #### Example ```javascript -import { DeviceEventEmitter } from 'react-native'; +import { NativeEventEmitter } from 'react-native'; import ReactNativeHeading from '@zsajjad/react-native-heading'; //.... componentDidMount() { + this.listener = new NativeEventEmitter(ReactNativeHeading) ReactNativeHeading.start(1) .then(didStart => { this.setState({ @@ -18,14 +19,14 @@ import ReactNativeHeading from '@zsajjad/react-native-heading'; }) }) - DeviceEventEmitter.addListener('headingUpdated', heading => { + this.listener.addListener('headingUpdated', heading => { console.log('New heading is:', heading); }); } componentWillUnmount() { ReactNativeHeading.stop(); - DeviceEventEmitter.removeAllListeners('headingUpdated'); + this.listener.removeAllListeners('headingUpdated'); } //... ``` From 2f2498c7f727a57aa42bca39bad197f66d23a4d7 Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Fri, 20 Jul 2018 12:22:56 +0500 Subject: [PATCH 08/11] Fixed pod issue --- package.json | 2 ++ react-native-heading.podspec | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e24bcb4..fa70433 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "type": "git", "url": "https://github.com/joshblour/react-native-heading.git" }, + "homepage": "https://github.com/zsajjad/react-native-heading.git", + "summary": "RN Package for head sensor detection", "license": "MIT", "keywords": ["react-native", "react-component"], "main": "ReactNativeHeading", diff --git a/react-native-heading.podspec b/react-native-heading.podspec index c7a3f5e..212c0ee 100644 --- a/react-native-heading.podspec +++ b/react-native-heading.podspec @@ -5,7 +5,7 @@ package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) Pod::Spec.new do |s| s.name = 'react-native-heading' s.version = package['version'] - s.summary = package['description'] + s.summary = package['summary'] s.description = package['description'] s.license = package['license'] s.author = package['author'] From 09cb64ca4502f8be799b6d33d646569aadce72e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Elsd=C3=B6rfer?= Date: Sun, 16 Sep 2018 20:48:10 +0100 Subject: [PATCH 09/11] Point links back to original repo. --- README.md | 8 ++++---- package.json | 2 +- react-native-heading.podspec | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6bbe0a3..b91753b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Report back device orientation in degrees, 0-360, with 0 being North. #### Example ```javascript import { NativeEventEmitter } from 'react-native'; -import ReactNativeHeading from '@zsajjad/react-native-heading'; +import ReactNativeHeading from 'react-native-heading'; //.... componentDidMount() { @@ -47,11 +47,11 @@ import ReactNativeHeading from '@zsajjad/react-native-heading'; ## Setup ``` -yarn add https://github.com/zsajjad/react-native-heading.git +yarn add https://github.com/joshblour/react-native-heading.git ``` ### iOS -* Run open node_modules/@zsajjad/react-native-heading +* Run open node_modules/react-native-heading * Drag ReactNativeHeading.xcodeproj into your Libraries group of XCode's project navigator * In XCode add Libraries/ReactNativeHeading.xcodeproj/Products/libReactNativeHeading.a to the "Link Binary with Libraries" section of the Build Phases @@ -63,7 +63,7 @@ yarn add https://github.com/zsajjad/react-native-heading.git ... include ':react-native-heading' -project(':react-native-heading').projectDir = new File(rootProject.projectDir, '../node_modules/@zsajjad/react-native-heading/android') +project(':react-native-heading').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-heading/android') ``` ##### Step 2 - Update Gradle Build diff --git a/package.json b/package.json index fa70433..ce6b25f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "git", "url": "https://github.com/joshblour/react-native-heading.git" }, - "homepage": "https://github.com/zsajjad/react-native-heading.git", + "homepage": "https://github.com/joshblour/react-native-heading.git", "summary": "RN Package for head sensor detection", "license": "MIT", "keywords": ["react-native", "react-component"], diff --git a/react-native-heading.podspec b/react-native-heading.podspec index 212c0ee..2c13115 100644 --- a/react-native-heading.podspec +++ b/react-native-heading.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.license = package['license'] s.author = package['author'] s.homepage = package['homepage'] - s.source = { :git => 'https://github.com/zsajjad/react-native-heading', :tag => s.version } + s.source = { :git => 'https://github.com/joshblour/react-native-heading', :tag => s.version } s.requires_arc = true s.platform = :ios, '8.0' From 78e6ae9797e51da79f6cf266e6c5a826da448ec8 Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Tue, 23 Oct 2018 09:42:26 +0100 Subject: [PATCH 10/11] Update README.md Co-Authored-By: miracle2k --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b91753b..7901dd9 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ import ReactNativeHeading from 'react-native-heading'; ## Setup ``` -yarn add https://github.com/joshblour/react-native-heading.git +yarn add react-native-heading ``` ### iOS From f5347c3f6879a1d0f434a9a938cb0f71a1ea3e0f Mon Sep 17 00:00:00 2001 From: Zain Sajjad Date: Tue, 23 Oct 2018 09:42:31 +0100 Subject: [PATCH 11/11] Update react-native-heading.podspec Co-Authored-By: miracle2k --- react-native-heading.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-native-heading.podspec b/react-native-heading.podspec index 2c13115..f4418a8 100644 --- a/react-native-heading.podspec +++ b/react-native-heading.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.license = package['license'] s.author = package['author'] s.homepage = package['homepage'] - s.source = { :git => 'https://github.com/joshblour/react-native-heading', :tag => s.version } + s.source = { :git => 'https://github.com/yonahforst/react-native-heading', :tag => s.version } s.requires_arc = true s.platform = :ios, '8.0'