Skip to content

Commit 19c60c4

Browse files
committed
Migrate the NetInfo module from React Native core to the community repo
1 parent 6fa1bd8 commit 19c60c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+9043
-52
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

.gitignore

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules/
9+
npm-debug.log
10+
yarn-error.log
11+
12+
13+
# Xcode
14+
#
15+
build/
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
xcuserdata
25+
*.xccheckout
26+
*.moved-aside
27+
DerivedData
28+
*.hmap
29+
*.ipa
30+
*.xcuserstate
31+
project.xcworkspace
32+
33+
34+
# Android/IntelliJ
35+
#
36+
build/
37+
.idea
38+
.gradle
39+
local.properties
40+
*.iml
41+
42+
# BUCK
43+
buck-out/
44+
\.buckd/
45+
*.keystore
46+
47+
# Editor config
48+
.vscode

.npmignore

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# JS
2+
node_modules
3+
yarn.lock
4+
5+
# Project files
6+
CONTRIBUTING.md
7+
CODE_OF_CONDUCT.md
8+
README.md
9+
10+
# Config files
11+
.babelrc
12+
babel.config.js
13+
.editorconfig
14+
.eslintrc
15+
.flowconfig
16+
.watchmanconfig
17+
jsconfig.json
18+
.npmrc
19+
.gitattributes
20+
.circleci
21+
*.coverage.json
22+
.opensource
23+
.circleci
24+
.eslintignore
25+
codecov.yml
26+
27+
# Example
28+
example/
29+
30+
# Android
31+
android/*/build/
32+
android/gradlew
33+
android/build
34+
android/gradlew.bat
35+
android/gradle/
36+
android/com_crashlytics_export_strings.xml
37+
android/local.properties
38+
android/.gradle/
39+
android/.signing/
40+
android/.idea/gradle.xml
41+
android/.idea/libraries/
42+
android/.idea/workspace.xml
43+
android/.idea/tasks.xml
44+
android/.idea/.name
45+
android/.idea/compiler.xml
46+
android/.idea/copyright/profiles_settings.xml
47+
android/.idea/encodings.xml
48+
android/.idea/misc.xml
49+
android/.idea/modules.xml
50+
android/.idea/scopes/scope_settings.xml
51+
android/.idea/vcs.xml
52+
android/*.iml
53+
android/.settings
54+
55+
# iOS
56+
ios/*.xcodeproj/xcuserdata
57+
*.pbxuser
58+
*.mode1v3
59+
*.mode2v3
60+
*.perspectivev3
61+
*.xcuserstate
62+
project.xcworkspace/
63+
xcuserdata/
64+
65+
# Misc
66+
.DS_Store
67+
.DS_Store?
68+
*.DS_Store
69+
coverage.android.json
70+
coverage.ios.json
71+
coverage
72+
npm-debug.log
73+
.github
74+
._*
75+
.Spotlight-V100
76+
.Trashes
77+
ehthumbs.db
78+
Thumbs.dbandroid/gradle
79+
docs
80+
.idea
81+
tests/
82+
bin/test.js
83+
codorials
84+
.vscode
85+
.nyc_output

LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2015-present, Facebook, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
# `@react-native-community/netinfo`
3+
React Native Network Info API for iOS & Android
4+
5+
## Getting started
6+
7+
`yarn add @react-native-community/netinfo`
8+
9+
or
10+
11+
`npm install @react-native-community/netinfo --save`
12+
13+
### Mostly automatic installation
14+
15+
`react-native link @react-native-community/netinfo`
16+
17+
### Manual installation
18+
19+
TODO
20+
21+
## Usage
22+
23+
TODO

android/build.gradle

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
buildscript {
3+
repositories {
4+
google()
5+
jcenter()
6+
}
7+
8+
dependencies {
9+
classpath 'com.android.tools.build:gradle:3.2.1'
10+
}
11+
}
12+
13+
def getExtOrDefault(name) {
14+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeNetInfo_' + name]
15+
}
16+
17+
def getExtOrIntegerDefault(name) {
18+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeNetInfo_' + name]).toInteger()
19+
}
20+
21+
apply plugin: 'com.android.library'
22+
23+
android {
24+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
25+
buildToolsVersion getExtOrDefault('buildToolsVersion')
26+
27+
defaultConfig {
28+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
29+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
30+
}
31+
}
32+
33+
repositories {
34+
google()
35+
jcenter()
36+
mavenCentral()
37+
}
38+
39+
dependencies {
40+
//noinspection GradleDynamicVersion
41+
api 'com.facebook.react:react-native:+'
42+
}

android/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ReactNativeNetInfo_compileSdkVersion=28
2+
ReactNativeNetInfo_buildToolsVersion=28.0.3
3+
ReactNativeNetInfo_targetSdkVersion=27
4+
ReactNativeNetInfo_minSdkVersion=16

android/src/main/AndroidManifest.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.reactnativecommunity.netinfo">
4+
5+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
6+
7+
</manifest>
8+

NetInfoModule.java android/src/main/java/com/reactnativecommunity/netinfo/NetInfoModule.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
package com.facebook.react.modules.netinfo;
8+
package com.reactnativecommunity.netinfo;
99

1010
import android.annotation.SuppressLint;
1111
import android.content.BroadcastReceiver;
@@ -24,15 +24,13 @@
2424
import com.facebook.react.bridge.ReactMethod;
2525
import com.facebook.react.bridge.WritableMap;
2626
import com.facebook.react.bridge.WritableNativeMap;
27-
import com.facebook.react.module.annotations.ReactModule;
2827

2928
import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
3029

3130
/**
3231
* Module that monitors and provides information about the connectivity state of the device.
3332
*/
3433
@SuppressLint("MissingPermission")
35-
@ReactModule(name = NetInfoModule.NAME)
3634
public class NetInfoModule extends ReactContextBaseJavaModule
3735
implements LifecycleEventListener {
3836

@@ -61,7 +59,7 @@ public class NetInfoModule extends ReactContextBaseJavaModule
6159
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />";
6260

6361
private static final String ERROR_MISSING_PERMISSION = "E_MISSING_PERMISSION";
64-
public static final String NAME = "NetInfo";
62+
public static final String NAME = "RNCNetInfo";
6563

6664
private final ConnectivityManager mConnectivityManager;
6765
private final ConnectivityBroadcastReceiver mConnectivityBroadcastReceiver;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.reactnativecommunity.netinfo;
9+
10+
import java.util.Arrays;
11+
import java.util.Collections;
12+
import java.util.List;
13+
14+
import com.facebook.react.ReactPackage;
15+
import com.facebook.react.bridge.NativeModule;
16+
import com.facebook.react.bridge.ReactApplicationContext;
17+
import com.facebook.react.uimanager.ViewManager;
18+
import com.facebook.react.bridge.JavaScriptModule;
19+
20+
public class NetInfoPackage implements ReactPackage {
21+
@Override
22+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
23+
return Arrays.<NativeModule>asList(new NetInfoModule(reactContext));
24+
}
25+
26+
// Deprecated from RN 0.47
27+
public List<Class<? extends JavaScriptModule>> createJSModules() {
28+
return Collections.emptyList();
29+
}
30+
31+
@Override
32+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
33+
return Collections.emptyList();
34+
}
35+
}

babel.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: ["module:metro-react-native-babel-preset"],
3+
plugins: [
4+
[
5+
"module-resolver",
6+
{
7+
alias: {
8+
"@react-native-community/netinfo": "./js"
9+
},
10+
cwd: "babelrc"
11+
}
12+
]
13+
]
14+
};

example/.gitignore

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle

0 commit comments

Comments
 (0)