@pulseboard/react-native 0.4.2 → 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 = reactContext
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 = context.resources.displayMetrics
68
- val wDp = m.widthPixels / m.density
69
- val hDp = m.heightPixels / m.density
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 cm = reactContext
22
- .getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
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", getConnectionType(cm))
26
- putBoolean("isConnected", isConnected(cm))
26
+ putString("type", getConnectionType(cm))
27
+ putBoolean("isConnected", isConnected(cm))
27
28
  putBoolean("isWifiEnabled", isWifi(cm))
28
- putString("carrier", getCarrier())
29
- putString("ipAddress", getIPAddress() ?: "unknown")
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 tm = reactContext
63
- .getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
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.2",
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",