@pulseboard/react-native 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,8 +4,8 @@ import android.content.Context
|
|
|
4
4
|
import android.os.Build
|
|
5
5
|
import android.util.DisplayMetrics
|
|
6
6
|
import android.view.WindowManager
|
|
7
|
-
import com.facebook.react.bridge.Promise
|
|
8
7
|
import com.facebook.react.bridge.Arguments
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
10
|
import com.pulseboard.NativePulseBoardDeviceSpec
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ class PulseBoardDeviceModule(
|
|
|
17
17
|
|
|
18
18
|
override fun getDeviceInfo(promise: Promise) {
|
|
19
19
|
try {
|
|
20
|
-
val context =
|
|
20
|
+
val context = getReactApplicationContext()
|
|
21
21
|
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
22
22
|
val metrics = DisplayMetrics()
|
|
23
23
|
|
|
@@ -64,9 +64,9 @@ class PulseBoardDeviceModule(
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private fun isTablet(context: Context): Boolean {
|
|
67
|
-
val m
|
|
68
|
-
val wDp
|
|
69
|
-
val hDp
|
|
67
|
+
val m = context.resources.displayMetrics
|
|
68
|
+
val wDp = m.widthPixels / m.density
|
|
69
|
+
val hDp = m.heightPixels / m.density
|
|
70
70
|
return minOf(wDp, hDp) >= 600f
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -18,15 +18,16 @@ class PulseBoardNetworkModule(
|
|
|
18
18
|
|
|
19
19
|
override fun getNetworkInfo(promise: Promise) {
|
|
20
20
|
try {
|
|
21
|
-
val
|
|
22
|
-
|
|
21
|
+
val context = getReactApplicationContext()
|
|
22
|
+
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE)
|
|
23
|
+
as ConnectivityManager
|
|
23
24
|
|
|
24
25
|
val result = Arguments.createMap().apply {
|
|
25
|
-
putString("type",
|
|
26
|
-
putBoolean("isConnected",
|
|
26
|
+
putString("type", getConnectionType(cm))
|
|
27
|
+
putBoolean("isConnected", isConnected(cm))
|
|
27
28
|
putBoolean("isWifiEnabled", isWifi(cm))
|
|
28
|
-
putString("carrier",
|
|
29
|
-
putString("ipAddress",
|
|
29
|
+
putString("carrier", getCarrier())
|
|
30
|
+
putString("ipAddress", getIPAddress() ?: "unknown")
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
promise.resolve(result)
|
|
@@ -59,8 +60,9 @@ class PulseBoardNetworkModule(
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
private fun getCarrier(): String = try {
|
|
62
|
-
val
|
|
63
|
-
|
|
63
|
+
val context = getReactApplicationContext()
|
|
64
|
+
val tm = context.getSystemService(Context.TELEPHONY_SERVICE)
|
|
65
|
+
as TelephonyManager
|
|
64
66
|
tm.networkOperatorName.takeIf { it.isNotEmpty() } ?: "unknown"
|
|
65
67
|
} catch (e: Exception) { "unknown" }
|
|
66
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulseboard/react-native",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Official PulseBoard SDK for React Native",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
+
"src/specs",
|
|
27
28
|
"ios",
|
|
28
29
|
"android/src",
|
|
29
30
|
"android/build.gradle",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type DeviceInfo = {
|
|
5
|
+
model: string;
|
|
6
|
+
manufacturer: string;
|
|
7
|
+
brand: string;
|
|
8
|
+
os: string;
|
|
9
|
+
osVersion: string;
|
|
10
|
+
appVersion: string;
|
|
11
|
+
buildNumber: string;
|
|
12
|
+
bundleId: string;
|
|
13
|
+
screenWidth: number;
|
|
14
|
+
screenHeight: number;
|
|
15
|
+
isTablet: boolean;
|
|
16
|
+
isEmulator: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface Spec extends TurboModule {
|
|
20
|
+
getDeviceInfo(): Promise<DeviceInfo>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default TurboModuleRegistry.get<Spec>("PulseBoardDevice");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type NetowrkInfo = {
|
|
5
|
+
type: string;
|
|
6
|
+
isConnected: boolean;
|
|
7
|
+
isWifiEnabled: boolean;
|
|
8
|
+
carrier: string;
|
|
9
|
+
ipAddress: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export interface Spec extends TurboModule {
|
|
13
|
+
getNetworkInfo(): Promise<NetowrkInfo>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TurboModuleRegistry.get<Spec>("PulseBoardNetwork");
|