Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
react-native-device-info
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
放牛的园子
react-native-device-info
Commits
1ec397f3
Commit
1ec397f3
authored
Feb 05, 2018
by
Mehdi Achour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: reformat files
parent
ed5bc527
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
RNDeviceInfo.java
...src/main/java/com/learnium/RNDeviceInfo/RNDeviceInfo.java
+4
-5
RNDeviceModule.java
...c/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
+25
-25
No files found.
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceInfo.java
View file @
1ec397f3
...
...
@@ -13,8 +13,7 @@ import java.util.List;
public
class
RNDeviceInfo
implements
ReactPackage
{
@Override
public
List
<
NativeModule
>
createNativeModules
(
ReactApplicationContext
reactContext
)
{
public
List
<
NativeModule
>
createNativeModules
(
ReactApplicationContext
reactContext
)
{
List
<
NativeModule
>
modules
=
new
ArrayList
<>();
modules
.
add
(
new
RNDeviceModule
(
reactContext
));
...
...
@@ -24,13 +23,13 @@ public class RNDeviceInfo implements ReactPackage {
// Deprecated RN 0.47
public
List
<
Class
<?
extends
JavaScriptModule
>>
createJSModules
()
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
@Override
public
List
<
ViewManager
>
createViewManagers
(
ReactApplicationContext
reactContext
)
{
return
Collections
.
emptyList
();
ReactApplicationContext
reactContext
)
{
return
Collections
.
emptyList
();
}
}
android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
View file @
1ec397f3
...
...
@@ -51,7 +51,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
}
private
WifiInfo
getWifiInfo
()
{
if
(
this
.
wifiInfo
==
null
)
{
if
(
this
.
wifiInfo
==
null
)
{
WifiManager
manager
=
(
WifiManager
)
reactContext
.
getApplicationContext
().
getSystemService
(
Context
.
WIFI_SERVICE
);
this
.
wifiInfo
=
manager
.
getConnectionInfo
();
}
...
...
@@ -59,18 +59,18 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
}
private
String
getCurrentLanguage
()
{
Locale
current
=
getReactApplicationContext
().
getResources
().
getConfiguration
().
locale
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
current
.
toLanguageTag
();
}
else
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
current
.
getLanguage
());
if
(
current
.
getCountry
()
!=
null
)
{
builder
.
append
(
"-"
);
builder
.
append
(
current
.
getCountry
());
}
return
builder
.
toString
();
Locale
current
=
getReactApplicationContext
().
getResources
().
getConfiguration
().
locale
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
current
.
toLanguageTag
();
}
else
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
current
.
getLanguage
());
if
(
current
.
getCountry
()
!=
null
)
{
builder
.
append
(
"-"
);
builder
.
append
(
current
.
getCountry
());
}
return
builder
.
toString
();
}
}
private
String
getCurrentCountry
()
{
...
...
@@ -80,13 +80,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
private
Boolean
isEmulator
()
{
return
Build
.
FINGERPRINT
.
startsWith
(
"generic"
)
||
Build
.
FINGERPRINT
.
startsWith
(
"unknown"
)
||
Build
.
MODEL
.
contains
(
"google_sdk"
)
||
Build
.
MODEL
.
contains
(
"Emulator"
)
||
Build
.
MODEL
.
contains
(
"Android SDK built for x86"
)
||
Build
.
MANUFACTURER
.
contains
(
"Genymotion"
)
||
(
Build
.
BRAND
.
startsWith
(
"generic"
)
&&
Build
.
DEVICE
.
startsWith
(
"generic"
))
||
"google_sdk"
.
equals
(
Build
.
PRODUCT
);
||
Build
.
FINGERPRINT
.
startsWith
(
"unknown"
)
||
Build
.
MODEL
.
contains
(
"google_sdk"
)
||
Build
.
MODEL
.
contains
(
"Emulator"
)
||
Build
.
MODEL
.
contains
(
"Android SDK built for x86"
)
||
Build
.
MANUFACTURER
.
contains
(
"Genymotion"
)
||
(
Build
.
BRAND
.
startsWith
(
"generic"
)
&&
Build
.
DEVICE
.
startsWith
(
"generic"
))
||
"google_sdk"
.
equals
(
Build
.
PRODUCT
);
}
private
Boolean
isTablet
()
{
...
...
@@ -135,12 +135,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
}
@Override
public
@Nullable
Map
<
String
,
Object
>
getConstants
()
{
public
@Nullable
Map
<
String
,
Object
>
getConstants
()
{
HashMap
<
String
,
Object
>
constants
=
new
HashMap
<
String
,
Object
>();
PackageManager
packageManager
=
this
.
reactContext
.
getPackageManager
();
String
packageName
=
this
.
reactContext
.
getPackageName
();
constants
.
put
(
"appVersion"
,
"not available"
);
constants
.
put
(
"appName"
,
"not available"
);
constants
.
put
(
"buildVersion"
,
"not available"
);
...
...
@@ -175,7 +176,6 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
}
try
{
if
(
Class
.
forName
(
"com.google.android.gms.iid.InstanceID"
)
!=
null
)
{
constants
.
put
(
"instanceId"
,
com
.
google
.
android
.
gms
.
iid
.
InstanceID
.
getInstance
(
this
.
reactContext
).
getId
());
...
...
@@ -208,11 +208,11 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants
.
put
(
"isTablet"
,
this
.
isTablet
());
constants
.
put
(
"is24Hour"
,
this
.
is24Hour
());
if
(
getCurrentActivity
()
!=
null
&&
(
getCurrentActivity
().
checkCallingOrSelfPermission
(
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
||
(
getCurrentActivity
().
checkCallingOrSelfPermission
(
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
||
getCurrentActivity
().
checkCallingOrSelfPermission
(
Manifest
.
permission
.
READ_SMS
)
==
PackageManager
.
PERMISSION_GRANTED
||
getCurrentActivity
().
checkCallingOrSelfPermission
(
"android.permission.READ_PHONE_NUMBERS"
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
TelephonyManager
telMgr
=
(
TelephonyManager
)
this
.
reactContext
.
getApplicationContext
().
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
constants
.
put
(
"phoneNumber"
,
telMgr
.
getLine1Number
());
TelephonyManager
telMgr
=
(
TelephonyManager
)
this
.
reactContext
.
getApplicationContext
().
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
constants
.
put
(
"phoneNumber"
,
telMgr
.
getLine1Number
());
}
constants
.
put
(
"carrier"
,
this
.
getCarrier
());
constants
.
put
(
"totalDiskCapacity"
,
this
.
getTotalDiskCapacity
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment