Commit 1ec397f3 authored by Mehdi Achour's avatar Mehdi Achour

style: reformat files

parent ed5bc527
...@@ -13,8 +13,7 @@ import java.util.List; ...@@ -13,8 +13,7 @@ import java.util.List;
public class RNDeviceInfo implements ReactPackage { public class RNDeviceInfo implements ReactPackage {
@Override @Override
public List<NativeModule> createNativeModules( public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>(); List<NativeModule> modules = new ArrayList<>();
modules.add(new RNDeviceModule(reactContext)); modules.add(new RNDeviceModule(reactContext));
...@@ -24,13 +23,13 @@ public class RNDeviceInfo implements ReactPackage { ...@@ -24,13 +23,13 @@ public class RNDeviceInfo implements ReactPackage {
// Deprecated RN 0.47 // Deprecated RN 0.47
public List<Class<? extends JavaScriptModule>> createJSModules() { public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @Override
public List<ViewManager> createViewManagers( public List<ViewManager> createViewManagers(
ReactApplicationContext reactContext) { ReactApplicationContext reactContext) {
return Collections.emptyList(); return Collections.emptyList();
} }
} }
...@@ -51,7 +51,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -51,7 +51,7 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
} }
private WifiInfo getWifiInfo() { private WifiInfo getWifiInfo() {
if ( this.wifiInfo == null ) { if (this.wifiInfo == null) {
WifiManager manager = (WifiManager) reactContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiManager manager = (WifiManager) reactContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
this.wifiInfo = manager.getConnectionInfo(); this.wifiInfo = manager.getConnectionInfo();
} }
...@@ -59,18 +59,18 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -59,18 +59,18 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
} }
private String getCurrentLanguage() { private String getCurrentLanguage() {
Locale current = getReactApplicationContext().getResources().getConfiguration().locale; Locale current = getReactApplicationContext().getResources().getConfiguration().locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return current.toLanguageTag(); return current.toLanguageTag();
} else { } else {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(current.getLanguage()); builder.append(current.getLanguage());
if (current.getCountry() != null) { if (current.getCountry() != null) {
builder.append("-"); builder.append("-");
builder.append(current.getCountry()); builder.append(current.getCountry());
}
return builder.toString();
} }
return builder.toString();
}
} }
private String getCurrentCountry() { private String getCurrentCountry() {
...@@ -80,13 +80,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -80,13 +80,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
private Boolean isEmulator() { private Boolean isEmulator() {
return Build.FINGERPRINT.startsWith("generic") return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown") || Build.FINGERPRINT.startsWith("unknown")
|| Build.MODEL.contains("google_sdk") || Build.MODEL.contains("google_sdk")
|| Build.MODEL.contains("Emulator") || Build.MODEL.contains("Emulator")
|| Build.MODEL.contains("Android SDK built for x86") || Build.MODEL.contains("Android SDK built for x86")
|| Build.MANUFACTURER.contains("Genymotion") || Build.MANUFACTURER.contains("Genymotion")
|| (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
|| "google_sdk".equals(Build.PRODUCT); || "google_sdk".equals(Build.PRODUCT);
} }
private Boolean isTablet() { private Boolean isTablet() {
...@@ -135,12 +135,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -135,12 +135,13 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
} }
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable
Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();
PackageManager packageManager = this.reactContext.getPackageManager(); PackageManager packageManager = this.reactContext.getPackageManager();
String packageName = this.reactContext.getPackageName(); String packageName = this.reactContext.getPackageName();
constants.put("appVersion", "not available"); constants.put("appVersion", "not available");
constants.put("appName", "not available"); constants.put("appName", "not available");
constants.put("buildVersion", "not available"); constants.put("buildVersion", "not available");
...@@ -175,7 +176,6 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -175,7 +176,6 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
} }
try { try {
if (Class.forName("com.google.android.gms.iid.InstanceID") != null) { if (Class.forName("com.google.android.gms.iid.InstanceID") != null) {
constants.put("instanceId", com.google.android.gms.iid.InstanceID.getInstance(this.reactContext).getId()); constants.put("instanceId", com.google.android.gms.iid.InstanceID.getInstance(this.reactContext).getId());
...@@ -208,11 +208,11 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -208,11 +208,11 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
constants.put("isTablet", this.isTablet()); constants.put("isTablet", this.isTablet());
constants.put("is24Hour", this.is24Hour()); constants.put("is24Hour", this.is24Hour());
if (getCurrentActivity() != null && 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(Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED ||
getCurrentActivity().checkCallingOrSelfPermission("android.permission.READ_PHONE_NUMBERS") == PackageManager.PERMISSION_GRANTED)) { getCurrentActivity().checkCallingOrSelfPermission("android.permission.READ_PHONE_NUMBERS") == PackageManager.PERMISSION_GRANTED)) {
TelephonyManager telMgr = (TelephonyManager) this.reactContext.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telMgr = (TelephonyManager) this.reactContext.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
constants.put("phoneNumber", telMgr.getLine1Number()); constants.put("phoneNumber", telMgr.getLine1Number());
} }
constants.put("carrier", this.getCarrier()); constants.put("carrier", this.getCarrier());
constants.put("totalDiskCapacity", this.getTotalDiskCapacity()); constants.put("totalDiskCapacity", this.getTotalDiskCapacity());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment