@pulseboard/react-native 0.4.2 → 0.4.4
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.
package/android/build.gradle
CHANGED
|
@@ -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
|
|